Hi Joseph, Joseph Myers skribis: > On Thu, 8 Jul 2021, Ludovic Courtès via Libc-alpha wrote: > >> > Hmm. Why doesn't '$CC -print-prog-name=objcopy' result in the right >> > command name? >> >> Is it supposed to? Looking at gcc/gcc.c:find_a_file, I’m not sure. >> For me it prints ‘objcopy’, and when I run: >> >> strace aarch64-linux-gnu-gcc -print-prog-name=objcopy >> >> … I only see it look for ‘objcopy’, not ‘aarch64-linux-gnu-objcopy’. > > I'd expect it to look for objcopy in $exec_prefix/$target/bin (binutils > installs it as objcopy in that directory and as $target-objcopy in > $exec_prefix/bin, see TOOL_PROGS in binutils/Makefile.am). (That path may > well in turn be computed via GCC's libexecsubdir, I see output such as > /scratch/jmyers/glibc-bot/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/12.0.0/../../../../aarch64-glibc-linux-gnu/bin/objcopy.) Oh, got it. That only works when GCC and Binutils are installed in the same prefix, then. In Guix, each package is installed in its own prefix. The cross Binutils has $exec_prefix/$target/bin as you write: --8<---------------cut here---------------start------------->8--- $ find /gnu/store/aj1zbw51fvngxrl1r2g6xcxfnlkshr82-binutils-cross-aarch64-linux-gnu-2.34/ -name objdump /gnu/store/aj1zbw51fvngxrl1r2g6xcxfnlkshr82-binutils-cross-aarch64-linux-gnu-2.34/aarch64-linux-gnu/bin/objdump --8<---------------cut here---------------end--------------->8--- … but GCC is instead looking for it in its own prefix: --8<---------------cut here---------------start------------->8--- $ strace -e stat aarch64-linux-gnu-gcc -print-prog-name=objdump stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/tls/haswell/x86_64", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/tls/haswell", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/tls/x86_64", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/tls", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/haswell/x86_64", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/haswell", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/x86_64", 0x7ffc8fcfb630) = -1 ENOENT (No such file or directory) stat("/gnu/store/1m16gz0q4v4j10k52i5q641sz6lvdwha-gcc-cross-aarch64-linux-gnu-7.5.0/bin/aarch64-linux-gnu-gcc", {st_mode=S_IFREG|0555, st_size=997752, ...}) = 0 stat("/gnu/store/1m16gz0q4v4j10k52i5q641sz6lvdwha-gcc-cross-aarch64-linux-gnu-7.5.0/bin/aarch64-linux-gnu-gcc", {st_mode=S_IFREG|0555, st_size=997752, ...}) = 0 stat("/gnu/store/1m16gz0q4v4j10k52i5q641sz6lvdwha-gcc-cross-aarch64-linux-gnu-7.5.0/libexec/gcc/aarch64-linux-gnu/7.5.0/lto-wrapper", {st_mode=S_IFREG|0555, st_size=909104, ...}) = 0 stat("/gnu/store/1m16gz0q4v4j10k52i5q641sz6lvdwha-gcc-cross-aarch64-linux-gnu-7.5.0/libexec/gcc/aarch64-linux-gnu/7.5.0/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) stat("/gnu/store/1m16gz0q4v4j10k52i5q641sz6lvdwha-gcc-cross-aarch64-linux-gnu-7.5.0/libexec/gcc/aarch64-linux-gnu/7.5.0/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) stat("/gnu/store/1m16gz0q4v4j10k52i5q641sz6lvdwha-gcc-cross-aarch64-linux-gnu-7.5.0/libexec/gcc/aarch64-linux-gnu/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) stat("/gnu/store/029zph27cyn3wvbxmlqh2xqrnk3h3323-gcc-cross-aarch64-linux-gnu-7.5.0-lib/lib/gcc/aarch64-linux-gnu/7.5.0/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) stat("/gnu/store/029zph27cyn3wvbxmlqh2xqrnk3h3323-gcc-cross-aarch64-linux-gnu-7.5.0-lib/lib/gcc/aarch64-linux-gnu/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) stat("/gnu/store/029zph27cyn3wvbxmlqh2xqrnk3h3323-gcc-cross-aarch64-linux-gnu-7.5.0-lib/lib/gcc/aarch64-linux-gnu/7.5.0/../../../../aarch64-linux-gnu/bin/aarch64-linux-gnu/7.5.0/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) stat("/gnu/store/029zph27cyn3wvbxmlqh2xqrnk3h3323-gcc-cross-aarch64-linux-gnu-7.5.0-lib/lib/gcc/aarch64-linux-gnu/7.5.0/../../../../aarch64-linux-gnu/bin/objdump", 0x7ffc8fcfc110) = -1 ENOENT (No such file or directory) objdump +++ exited with 0 +++ --8<---------------cut here---------------end--------------->8--- … which fails. > I'd expect the code to work both before and after the patch. If there is > some advantage to the change proposed in the patch, it would be a good > idea for the commit message to explain in more detail the circumstances > when the objcopy in $exec_prefix/$target/bin isn't found. I reworded the commit log of the two patches (attached). Let me know what you think. Thanks, Ludo’.