-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
static compiling rust for aarch64-unknown-linux-musl results in undefined reference to `getauxval' #264687
Comments
Perhaps also related: rust-lang/rust#89626 |
I made an example repo to hopefully make it easier to reproduce: https://github.com/n8henrie/nixpkgs-issue-264687 It seems that depending on / using $ nix build --builders '' github:n8henrie/nixpkgs-issue-264687
error: builder for '/nix/store/mzbkyvwj35n5wwv6bcw1b0h631ixff5g-nixpkgs-issue-264687-example-aarch64-unknown-linux-musl.drv' failed with exit code 101;
last 10 log lines:
> /nix/store/flrx5swv7a6g4lxb2004g5pfwg933nzi-aarch64-unknown-linux-musl-binutils-2.40/bin/aarch64-unknown-linux-musl-ld: /nix/store/imfslavps8w7la48kiyywnq08c56zyr0-aarch64-unknown-linux-musl-rustc-1.73.0/lib/rustlib/aarch64-unknown-linux-musl/lib/libcompiler_builtins-e29f93580d4466a0.rlib(d24dc0111d2d0654-cpu_model.o): in function `init_cpu_features':
> cpu_model.c:(.text.startup.init_cpu_features+0x24): undefined reference to `getauxval'
> /nix/store/flrx5swv7a6g4lxb2004g5pfwg933nzi-aarch64-unknown-linux-musl-binutils-2.40/bin/aarch64-unknown-linux-musl-ld: cpu_model.c:(.text.startup.init_cpu_features+0x30): undefined reference to `getauxval'
> collect2: error: ld returned 1 exit status
>
> = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
> = note: use the `-l` flag to specify native libraries to link
> = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
>
> error: could not compile `nixpkgs-issue-264687-example` (bin "nixpkgs-issue-264687-example") due to previous error |
For future readers that are just hoping to make a statically linked aarch64-linux rust-based executable that depends on openssl, after a bunch of trial and error I got the following flake to successfully build; the keys were:
{
description = "https://github.com/NixOS/nixpkgs/issues/264687";
inputs.nixpkgs.url = "github:nixos/nixpkgs/59e7944d2a7d49264525dd6d9a91a3d86b0f0526";
outputs = {
self,
nixpkgs,
}: let
pkgs = import nixpkgs {
system = "x86_64-linux";
crossSystem = {
config = "aarch64-linux";
rustc.config = "aarch64-unknown-linux-gnu";
};
};
in {
packages.x86_64-linux.default = pkgs.rustPlatform.buildRustPackage {
name = "nixpkgs-issue-264687-example";
version = "0.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
RUSTFLAGS = ["-Ctarget-feature=+crt-static"];
nativeBuildInputs = [pkgs.pkg-config];
buildInputs = with pkgs; [
glibc.static
pkgsStatic.openssl
];
};
};
} Aside from the above, the only other change required to get However, this is all for |
Yes, same issue |
#278798 says it fixes this and was merged. |
Describe the bug
I'm trying to cross-compile a static build of nix-index from an
x86_64-linux
host foraarch64-unknown-linux-musl
, but it fails with:Steps To Reproduce
Steps to reproduce the behavior:
nix-index
repocargo update
to generateCargo.lock
Expected behavior
I'm hoping for a successful cross compilation that looks like a static build when I
file
the output.Additional context
I have been able to cross-compile a
hello world
(example), so I'm not sure if this is a problem with a dependency? I've tried scatteringpkgsStatic
andpkgsMusl
around various places likebuildInputs
without a solution.There is an existing rustup issue that recommends using
CFLAGS=-mno-outline-atomics
: rust-lang/rustup#3324In the flake above, I've commented out my attempts to add this to both
NIX_CFLAGS_COMPILE
, which gives the same error, as well asRUSTFLAGS = "-C -mno-outline-atomics";
, which leads to> error: unknown codegen option: -mno-outline-atomics
Notify maintainers
teams.rust.members:
@figsoda
@Mic92
@tjni
@Winter
@zowoq
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.The text was updated successfully, but these errors were encountered: