[Aboriginal] Build error when system has a cross compiler already

Bobby Bingham koorogi at koorogi.info
Sun Jan 5 13:34:46 PST 2014


I know my mail was short on information.  I'm starting from a position
of knowing gcc does all sorts of crazy things you've had to work around,
but not knowing what these things are or where to look for them.

You've given me a couple places to start looking, so without further ado
...

On Sun, Jan 05, 2014 at 10:54:00AM -0600, Rob Landley wrote:
> [...]
> > First, the error itself.  When aboriginal tries to compile the kernel:
> >      sh4-ld: unrecognized option '--build-id'
>  >
> > Digging around in the kernel makefiles a bit, it looks like it does try
> > checking if the linker supports the --build-id flag.  Looks like the
> > check amounts roughly to:
> >      build/simple-cross-compiler-sh4/bin/sh4-gcc -Wl,--build-id -nostdlib -x c /dev/null -o /tmp/foo
>  >
> > Which on my system produces this output:
> >      /usr/libexec/gcc/sh-superh-linux/ld: warning: cannot find entry symbol _start; defaulting to 00000000004000d8
> >
> > Note the path to ld -- the sh4-gcc built by aboriginal is apparently
> > running the SH4 linker I have installed on my system, which is from
> > binutils 2.24, which supports the --build-id option.  That explains why
> > the kernel thinks the linker supports it.
>
> And it found a binary that's not in the $PATH at runtime. How? It's not
> in the $PATH when simple-cross-compiler.sh runs, is it? Because
> host-tools.sh ran already and populated build/host and the next script's
> include.sh should see that and trim the $PATH to point _just_ to that...

The $PATH during simple-cross-compiler.sh does not containing any system
directories.  It's got, in order:
    build/simple-cross-compiler-sh4/bin
    build/host
    build/host/fallback-1
    build/host/fallback-2

>
> Right, obviously I'm not currenty reproducing this here. Where did you
> get this toolchain? I have no idea how to reproduce it?'

I built this toolchain locally using Gentoo's crossdev tool.  I can put
together tarballs and upload them somewhere, but I think there's still
more investigation I can do myself before it comes to that.

>
> My first wild guess at fixing it would be the attached file. Put it in
> "sources/patches" and see if that fixes it? But... how would it find it
> there either? (How does gcc know this binary exists in the first place?)
> All I know about that patch it didn't _break_ anything obvious in my
> build...

The patch doesn't help.

>
> Another potential fix would be to tell it to make the second stage cross
> compiler, which it does with the original $PATH removed. But again, if I
> don't understand what's going wrong, I have no idea if that fixes it...

I don't think this will help.  See below, but it looks like it's trying
a whole bunch of directories that have nothing to do with the $PATH.

> [...]
> So a _third_ approach I could try is making ccwrap plug this leak.
> Except if it's a hardwired absolute path it's looking at (which is what
> that DEFAULT_CRAP did, I grepped for instances of "ld" and that looked
> most dubious), even the wrapper couldn't stop it short of ptracing the
> child process and vetoing the syscall (not going there).

I've started stracing gcc, and it looks like it is searching a hardcoded
list of paths, even with your patch.  I've attached the relevant looking
excerpt from the strace output.

It shows gcc searching a number of paths for collect2, which is
apparently then responsible for invoking the real linker [1].

The first several directories searched for collect2 are under the
aboriginal build directory, then it switches to looking under
/usr/libexec and /usr/lib, and then it switches back to more directories
under the aboriginal build directory and evantually finds the correct
collect2.

The system collect2 that I have is under /usr/libexec/gcc/sh-superh-linux/4.8.2,
which the aboriginal gcc doesn't find because of the different gcc
version.

But when collect2 runs, it _does_ find the system ld, because that's
part of binutils and not stored in a directory specific to the gcc
version.

Now, I still have to see if I can figure out where this fixed set of
directories is coming from ...

[1]: http://gcc.gnu.org/onlinedocs/gccint/Collect2.html

--
Bobby Bingham
-------------- next part --------------
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/sh-superh-linux/bin/../libexec/gcc/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/sh-superh-linux/bin/../libexec/gcc/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/libexec/gcc/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/libexec/gcc/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/libexec/gcc/sh-superh-linux/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/gcc/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/gcc/sh-superh-linux/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/usr/libexec/gcc/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/usr/libexec/gcc/sh-superh-linux/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/gcc/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/gcc/sh-superh-linux/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/sh-superh-linux/bin/../lib/gcc/sh-superh-linux/4.2.1/../../../../sh-superh-linux/bin/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/sh-superh-linux/bin/../lib/gcc/sh-superh-linux/4.2.1/../../../../sh-superh-linux/bin/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/../sh-superh-linux/bin/sh-superh-linux/4.2.1/collect2", 0x7fff4ca3fce0) = -1 ENOENT (No such file or directory)
stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/../sh-superh-linux/bin/collect2", {st_mode=S_IFREG|0755, st_size=1428755, ...}) = 0
access("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/../sh-superh-linux/bin/collect2", X_OK) = 0
vfork(Process 27720 attached
 <unfinished ...>
[pid 27720] execve("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/../sh-superh-linux/bin/collect2", ["/home/koorogi/projects/aborigina"..., "--eh-frame-hdr", "-m", "shlelf_linux", "-dynamic-linker", "/lib/ld-linux.so.2", "-o", "/tmp/foo", "-L/home/koorogi/projects/aborigi"..., "-L/home/koorogi/projects/aborigi"..., "-L/home/koorogi/projects/aborigi"..., "--dynamic-linker", "/lib/ld-uClibc.so.0", "-rpath-link", "/home/koorogi/projects/aborigina"..., "--build-id", ...], [/* 73 vars */] <unfinished ...>
[pid 27717] <... vfork resumed> )       = 27720
[pid 27717] wait4(27720,  <unfinished ...>
[pid 27720] <... execve resumed> )      = 0
[pid 27720] uname({sys="Linux", node="duality", ...}) = 0
[pid 27720] brk(0)                      = 0x1b3e000
[pid 27720] brk(0x1b3f1c0)              = 0x1b3f1c0
[pid 27720] arch_prctl(ARCH_SET_FS, 0x1b3e880) = 0
[pid 27720] brk(0x1b601c0)              = 0x1b601c0
[pid 27720] brk(0x1b61000)              = 0x1b61000
[pid 27720] rt_sigaction(SIGCHLD, {SIG_DFL, [CHLD], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGQUIT, {SIG_IGN, [QUIT], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGQUIT, {0x402990, [QUIT], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_IGN, [QUIT], SA_RESTORER|SA_RESTART, 0x413790}, 8) = 0
[pid 27720] rt_sigaction(SIGINT, {SIG_IGN, [INT], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGINT, {0x402990, [INT], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_IGN, [INT], SA_RESTORER|SA_RESTART, 0x413790}, 8) = 0
[pid 27720] rt_sigaction(SIGALRM, {SIG_IGN, [ALRM], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGALRM, {0x402990, [ALRM], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_IGN, [ALRM], SA_RESTORER|SA_RESTART, 0x413790}, 8) = 0
[pid 27720] rt_sigaction(SIGHUP, {SIG_IGN, [HUP], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGHUP, {0x402990, [HUP], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_IGN, [HUP], SA_RESTORER|SA_RESTART, 0x413790}, 8) = 0
[pid 27720] rt_sigaction(SIGSEGV, {SIG_IGN, [SEGV], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGSEGV, {0x402990, [SEGV], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_IGN, [SEGV], SA_RESTORER|SA_RESTART, 0x413790}, 8) = 0
[pid 27720] rt_sigaction(SIGBUS, {SIG_IGN, [BUS], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_DFL, [], 0}, 8) = 0
[pid 27720] rt_sigaction(SIGBUS, {0x402990, [BUS], SA_RESTORER|SA_RESTART, 0x413790}, {SIG_IGN, [BUS], SA_RESTORER|SA_RESTART, 0x413790}, 8) = 0
[pid 27720] stat("/usr/libexec/gcc/sh-superh-linux/real-ld", 0x7fff7f2da820) = -1 ENOENT (No such file or directory)
[pid 27720] stat("/usr/lib/gcc/sh-superh-linux/real-ld", 0x7fff7f2da820) = -1 ENOENT (No such file or directory)
[pid 27720] stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/../sh-superh-linux/bin/real-ld", 0x7fff7f2da820) = -1 ENOENT (No such file or directory)
[pid 27720] stat("/usr/libexec/gcc/sh-superh-linux/collect-ld", 0x7fff7f2da820) = -1 ENOENT (No such file or directory)
[pid 27720] stat("/usr/lib/gcc/sh-superh-linux/collect-ld", 0x7fff7f2da820) = -1 ENOENT (No such file or directory)
[pid 27720] stat("/home/koorogi/projects/aboriginal/build/simple-cross-compiler-sh4/lib/../sh-superh-linux/bin/collect-ld", 0x7fff7f2da820) = -1 ENOENT (No such file or directory)
[pid 27720] stat("/usr/libexec/gcc/sh-superh-linux/ld", {st_mode=S_IFREG|0755, st_size=4746880, ...}) = 0
[pid 27720] access("/usr/libexec/gcc/sh-superh-linux/ld", X_OK) = 0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.landley.net/pipermail/aboriginal-landley.net/attachments/20140105/70b86f8e/attachment-0003.pgp>


More information about the Aboriginal mailing list