Bear icon indicating copy to clipboard operation
Bear copied to clipboard

build fails with Yocto Dunfell cross compiler

Open joakim-tjernlund opened this issue 2 years ago • 11 comments

 ARCH=arm64 CROSS_COMPILE=/opt/infn-xr/1.0/sysroots/x86_64-xrsdk-linux/usr/bin/aarch64-xr-linux-musl/aarch64-xr-linux-musl- bear -- make  -j9
/opt/infn-xr/1.0/sysroots/x86_64-xrsdk-linux/usr/bin/aarch64-xr-linux-musl/aarch64-xr-linux-musl-gcc: /opt/infn-xr/1.0/sysroots/x86_64-xrsdk-linux/lib/libc.so.6: version `GLIBC_2.34' not found (required by /usr/lib64/bear/libexec.so)
/opt/infn-xr/1.0/sysroots/x86_64-xrsdk-linux/usr/bin/aarch64-xr-linux-musl/aarch64-xr-linux-musl-gcc: /opt/infn-xr/1.0/sysroots/x86_64-xrsdk-linux/lib/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib64/bear/libexec.so)

joakim-tjernlund avatar Jul 15 '22 11:07 joakim-tjernlund

bear 3.0.19

joakim-tjernlund avatar Jul 15 '22 11:07 joakim-tjernlund

readelf on the cross compiler gives:

 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/../../lib]

[Requesting program interpreter: /opt/infn-xr/1.0/sysroots/x86_64-xrsdk-linux/lib/ld-linux-x86-64.so.2]

So I presume bear is then tricked into using this older glibc and it fails. Is it possible to build bear with static libs ?

joakim-tjernlund avatar Jul 15 '22 14:07 joakim-tjernlund

Alternatively you can try --force-wrapper flag for Bear. That case it will use compiler wrappers, and won't clash with the libC. The only thing you might want to pay attention for that case, the build system needs to respect the CC and CXX environment variables.

rizsotto avatar Jul 16 '22 00:07 rizsotto

Any luck @joakim-tjernlund ?

rizsotto avatar Jul 19 '22 10:07 rizsotto

On vacation ATM but I did a test build with --force-wrapper and it built the kernel/u-boot so it looks better. Looking at the compile_commands.json generated file I only see a few files in there, only files that are built with the host gcc like scripts/sorttable.c or lib/gen_crc32table.c

joakim-tjernlund avatar Jul 19 '22 12:07 joakim-tjernlund

The reason for that is, you specify the CROSS_COMPILE environment variable. The CC (or CXX) environment would be better for that. Can you change the build to use those environment variables instead? (Bear replace those env variables with a compile wrapper, and only those will get captured.)

rizsotto avatar Jul 23 '22 04:07 rizsotto

The reason for that is, you specify the CROSS_COMPILE environment variable. The CC (or CXX) environment would be better for that. Can you change the build to use those environment variables instead? (Bear replace those env variables with a compile wrapper, and only those will get captured.)

I don't think I can do that, both Linux kernel and u-boot depends hard on CROSS_COMPILE. It is an common way to express cross compilation and I think the best would be if bear supports the CROSS_COMPILE variable.

joakim-tjernlund avatar Jul 26 '22 12:07 joakim-tjernlund

Ok. Can you share some man page/link that explains this variable usage?

rizsotto avatar Jul 26 '22 13:07 rizsotto

That was harder to find but this is one page: https://hugh712.gitbooks.io/embeddedsystem/content/cross-compiling_the_kernel.html

Basically it an prefix like arm-linux- , then the build system construct a compiler/linker by appending gcc or ld. The CROSS_COMPILE var can be an absolute path like /opt//my-cross/arm-linux- or just arm-linux- and then the normal PATH is searched.

joakim-tjernlund avatar Jul 26 '22 13:07 joakim-tjernlund

Thanks @joakim-tjernlund , I see now... Can you try a workaround for me?

Bear install an executable called wrapper, which as the name suggests wraps program executions. It also install a directory called wrapper.d, which contains soft links to the wrapper. Could you create soft links in this directory with the cross compiler names? (eg.: arm-linux-gcc, arm-linux-ld, etc...)

Execute Bear with the --force-wrapper flag. You might also want to specify a config file location with --config <path>, where the config contains instructions to recognize these programs as compiler. (See more here .)

rizsotto avatar Jul 27 '22 02:07 rizsotto

been on vacation a few weeks and forgot about this, sorry. Question though, both u-boot and kernel needs both the host compiler (aka plain gcc) and the cross compiler. Will bear manage both?

joakim-tjernlund avatar Aug 17 '22 19:08 joakim-tjernlund