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

build fails with Yocto Dunfell cross compiler #472

Open
joakim-tjernlund opened this issue Jul 15, 2022 · 11 comments
Open

build fails with Yocto Dunfell cross compiler #472

joakim-tjernlund opened this issue Jul 15, 2022 · 11 comments

Comments

@joakim-tjernlund
Copy link

 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
Copy link
Author

bear 3.0.19

@joakim-tjernlund
Copy link
Author

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 ?

@rizsotto
Copy link
Owner

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
Copy link
Owner

Any luck @joakim-tjernlund ?

@joakim-tjernlund
Copy link
Author

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

@rizsotto
Copy link
Owner

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.)

@joakim-tjernlund
Copy link
Author

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.

@rizsotto
Copy link
Owner

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

@joakim-tjernlund
Copy link
Author

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.

@rizsotto
Copy link
Owner

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 .)

@joakim-tjernlund
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants