Thanks, I had missed trying out buildInputs
! Unfortunately, whether I add glibc.static
to the nativeBuildInputs
or the buildInputs
doesn’t seem to make a difference, and I get the exact same behavior (the shared linking step now fails because only a static glibc is available).
I tried this shell.nix
(attempt #4):
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
gcc
];
buildInputs = with pkgs; [
glibc.static
];
}
And output:
$ nix-shell --pure
[nix-shell]$ ./build.sh
/nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin/ld: /nix/store/zxcqmz6sah8h9qqy4w7kknlbkd2m6d0p-glibc-2.31-74-static/lib/libc.a(dl-trampoline.o): relocation R_X86_64_PC32 against symbol `_dl_x86_cpu_features' can not be used when making a shared object; recompile with -fPIC
/nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
shared FAILED!
static worked!
I also tried variations of this, i.e., leaving the gcc
dependency out, adding it to buildInputs
instead of nativeBuildInputs
, trying nativeBuildInputs = [ glibc.static ]
and buildInputs = [ gcc ]
, but they all result in the same result/output as above.
Also, as long as I add glibc
to either the nativeBuildInputs
or the buildInputs
, the same “cannot find stdlib-headers”-bug from attempt #3 occurs.
Is this what you meant or am I missing something? Thanks!