Skip to content
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

glibc: fix build vs host tool confusion #125668

Merged
merged 1 commit into from
Jun 6, 2021

Conversation

thefloweringash
Copy link
Member

@thefloweringash thefloweringash commented Jun 4, 2021

Motivation for this change

Cross compilation from aarch64-linux -> armv7l-linux

#106759 (comment)

Edit: Upstream issue by @Ericson2314: https://sourceware.org/bugzilla/show_bug.cgi?id=23681

I don't know how this (source) is meant to work, or if it works elsewhere, so this is a very blunt solution. More elegant solutions very welcome. The -print-prog-name= flag to gcc (source) is a general search through a list of directories for the provided binary (with a couple of exceptions), for example:

$ strace $CC -print-prog-name=BANANAPHONE 2>&1 | grep BANANAPHONE
execve("/nix/store/ndwv24mf56w15hak6b4bi5nlzsc1qsjg-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-wrapper-10.2.0/bin/armv7l-unknown-linux-gnueabihf-gcc", ["armv7l-unknown-linux-gnueabihf-g"..., "-print-prog-name=BANANAPHONE"], 0xfffff1921018 /* 192 vars */) = 0
execve("/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/bin/armv7l-unknown-linux-gnueabihf-gcc", ["/nix/store/8cxq0frw1lwkfv1whzg87"..., "-fno-strict-overflow", "-Wformat", "-Wformat-security", "-Werror=format-security", "-fPIC", "-march=armv7-a", "-mfpu=vfpv3-d16", "-print-prog-name=BANANAPHONE", "-B/nix/store/wsyl89si5yimrl4ajij"..., "-B/nix/store/ndwv24mf56w15hak6b4"..., "-Wno-error=missing-attributes", "-ggdb", "-Wa,--compress-debug-sections", "-frandom-seed=4fhs4fj3y5", "-isystem", "/nix/store/3wdvnp51dv9v6r56zadj1"...], 0x2d8e0008 /* 209 vars */) = 0
newfstatat(AT_FDCWD, "/nix/store/wsyl89si5yimrl4ajijpnlz9545kk7ny-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0-lib/armv7l-unknown-linux-gnueabihf/lib/armv7l-unknown-linux-gnueabihf/10.2.0/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/wsyl89si5yimrl4ajijpnlz9545kk7ny-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0-lib/armv7l-unknown-linux-gnueabihf/lib/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/ndwv24mf56w15hak6b4bi5nlzsc1qsjg-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-wrapper-10.2.0/bin/armv7l-unknown-linux-gnueabihf/10.2.0/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/ndwv24mf56w15hak6b4bi5nlzsc1qsjg-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-wrapper-10.2.0/bin/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/libexec/gcc/armv7l-unknown-linux-gnueabihf/10.2.0/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/libexec/gcc/armv7l-unknown-linux-gnueabihf/10.2.0/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/libexec/gcc/armv7l-unknown-linux-gnueabihf/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/lib/gcc/armv7l-unknown-linux-gnueabihf/10.2.0/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/lib/gcc/armv7l-unknown-linux-gnueabihf/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/lib/gcc/armv7l-unknown-linux-gnueabihf/10.2.0/../../../../armv7l-unknown-linux-gnueabihf/bin/armv7l-unknown-linux-gnueabihf/10.2.0/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/8cxq0frw1lwkfv1whzg87xz22yw7mgpk-armv7l-unknown-linux-gnueabihf-stage-static-gcc-debug-10.2.0/lib/gcc/armv7l-unknown-linux-gnueabihf/10.2.0/../../../../armv7l-unknown-linux-gnueabihf/bin/BANANAPHONE", 0xffffc08d57a8, 0) = -1 ENOENT (No such file or directory)
write(1, "BANANAPHONE\n", 12BANANAPHONE

I don't expect any of these directories to contain tools from binutils.

cc @misuzu @TredwellGit @Ericson2314

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS (aarch64-linux -> armv7l-linux)
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Added a release notes entry if the change is major or breaking
  • Fits CONTRIBUTING.md.

Fixes cross compilation from aarch64-linux -> armv7l-linux
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 4, 2021
@bjornfor bjornfor added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jun 5, 2021
@misuzu
Copy link
Contributor

misuzu commented Jun 6, 2021

LGTM! The only thing that is failing to build for me is the Linux kernel, but it's most likely unrelated:

error: builder for '/nix/store/66r6q1d0wr10iz68i77qzfgrhfb2y5zk-linux-armv7l-unknown-linux-gnueabihf-5.12.7.drv' failed with exit code 1;
       last 10 log lines:
       >   MODPOST vmlinux.symvers
       >   MODINFO modules.builtin.modinfo
       >   GEN     modules.builtin
       >   LD      .tmp_vmlinux.kallsyms1
       > /nix/store/69v26s02bc8lqpflhc95rqn1gczv6dc2-armv7l-unknown-linux-gnueabihf-binutils-2.35.1/bin/armv7l-unknown-linux-gnueabihf-ld: warning: unrecognized --build-id style ignored
       > /nix/store/69v26s02bc8lqpflhc95rqn1gczv6dc2-armv7l-unknown-linux-gnueabihf-binutils-2.35.1/bin/armv7l-unknown-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_common.o: in function `ks8851_probe_common':
       > ks8851_common.c:(.text+0x179c): undefined reference to `__this_module'
       > /nix/store/69v26s02bc8lqpflhc95rqn1gczv6dc2-armv7l-unknown-linux-gnueabihf-binutils-2.35.1/bin/armv7l-unknown-linux-gnueabihf-ld: ks8851_common.c:(.text+0x17a0): undefined reference to `__this_module'
       > make[1]: *** [/build/linux-5.12.7/Makefile:1199: vmlinux] Error 1
       > make: *** [../Makefile:215: __sub-make] Error 2
       For full logs, run 'nix log /nix/store/66r6q1d0wr10iz68i77qzfgrhfb2y5zk-linux-armv7l-unknown-linux-gnueabihf-5.12.7.drv'.

@thefloweringash
Copy link
Member Author

There’s a fix for the kernel linker failure: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

@github-actions
Copy link
Contributor

Successfully created backport PR #126442 for release-21.05.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants