-
Notifications
You must be signed in to change notification settings - Fork 394
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
x86_64-unknown-linux-gnu target generates GLIBC 2.18 symbols #455
Comments
We discovered this as well trying to build
|
Confirmed. I dug into this and the This makes a lot of sense and as people using |
I made an experiment and pushed the image here https://github.com/OSSystems/rust-cross-images This might be a good way to work around this. We need to add CI there and clean it up a little but seems to work for me. |
We finished it up and created two images, based on Debian 6. You can use the [target.{{TARGET}}]
image = "ossystems/rust-cross:{{TAG}}" Refer to the table below for the
Please see our README at https://github.com/OSSystems/rust-cross-images for more details and please feel free to provide fixes there if need. |
@otavio Any plans to make a PR to this upstream? :) |
We can prepare a PR for sure, assuming upstream wishes it. If you look at the diff in commit OSSystems/rust-cross-images@e665cee you'll notice it is a little convoluted as we have to do some workarounds to allow the use with this old base system. So to do the PR, we'd need to receive some direction on how it'd be better to approach this so we work in a way it's likely to be accepted. @Hoverbear in meantime you could use those images and get the builds going ;-) |
@otavio Yeah! I'll take some time to give a look through myself, maybe I can try to offer some ideas. |
@otavio thanks for the image, works fine. |
Don't get me wrong, I do understand the reasoning of CentOS/RHEL in "freezing/locking" certain system libraries at a very specific version. And, yes, if you're trying to release binary-only software (i.e. "typical" commercial software) it's kinda a requirement. (Although I supppose Microsoft's approach with the WIN32 API is both better and worse - to maintain backwards compatibility, you can't really ever remove anything. I suspect glibc has introduced breaking changes somewhere along the way.) At the same time, glibc 2.17 was released was released 2012-12-25 and RHEL 7 first came out June 2014. It's still receiving updates, of course, 7.8 released March 2020. It just feels like such a terrible limitation to be so far behind. I guess a question comes up: aside from the pain of either (a) going for the lowest common denominator or (b) maintaining multiple configurations for the same architecture, what functional differences are lost with an older glibc? I mean, Rust originally came out in 2010? Rust 1.0 in 2015 (by which point glibc 2.17 was 2.5 years old and the current release was 2.21?) I know this comment is tangential to the original question and maybe it's really moot - I guess I just really really dislike seeing compatibility things like this that (in my view) detract from forward progress...
Back on direct topic: Could statically linking everything be a solution? |
In my specific use case, we need to provide a binary-only dynamic library (.so file) that must work on old systems. For binary-only applications, static linking is indeed the best choice. For the dynamic library case I see no other option. Do you? |
Just noting that I believe #501 addresses this issue. |
Still seeing this after #501 when trying to build for RHEL 7 from MacOS -- even with the alternative approach provided by @otavio: $ cargo clean
$ cross build --target x86_64-unknown-linux-gnu --release
$ scp target/x86_64-unknown-linux-gnu/release/my-app some-rhel7-box:
$ ssh some-rhel7-box
$ objdump -T ~/my-app | grep GLIBC_2.18
0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.18 __cxa_thread_atexit_impl Does this require a nightly toolchain and $ cat Cross.toml
# Add support for building RHEL 7 binaries, which only require glibc <= 2.17.
# Reference: <https://github.com/rust-embedded/cross/issues/455>
[target.x86_64-unknown-linux-gnu]
xargo = true
#image = "ossystems/rust-cross:x86_64-linux-compat-0.2.1"
$ rustup override set nightly
info: using existing install for 'nightly-x86_64-apple-darwin'
info: override toolchain for '/Users/d6lu/workspaces/bfd/beneficiary-fhir-data.git/apps/utils/db-query-checker' set to 'nightly-x86_64-apple-darwin'
nightly-x86_64-apple-darwin unchanged - rustc 1.55.0-nightly (014026d1a 2021-07-19)
$ cross build --target x86_64-unknown-linux-gnu --release
error: `rust-src` component not found. Run `rustup component add rust-src`.
note: run with `RUST_BACKTRACE=1` for a backtrace
$ rustup component add rust-src
info: component 'rust-src' is up to date
$ cross build --target x86_64-unknown-linux-gnu --release
error: `rust-src` component not found. Run `rustup component add rust-src`.
note: run with `RUST_BACKTRACE=1` for a backtrace 😞 |
Unfortunately static linking is not a perfect solution either when the kernel is too old on the target system. Statically linked GLIBC panics with |
I hit the same or similar problem just now, I'm trying to cross-compile to raspbian stretch (raspberry pi). My binary has C dependencies statically linked in using the cmake crate. What I did was, take The build works fine, but the binary it produces links to GLIBC 2.28 (which is installed on the host, debian buster). Weirdly, I got the same problem by running rustup inside the container (the project is in a bind mount at Dockerfile:
edit: removed |
608: add clang as a common build tool r=reitermarkus a=anatawa12 Closes #174 This PR adds clang as a common build tool. The libclang will be used by bindgen so It's better to have clang on all platforms so I add to common.sh This works for bindgen for the following targets with `ffmpeg-next` of `libavformat`, `libavcodec`, and `libavutil` with my built ffmpeg binaries: - `x86_64-pc-windows-gnu` - `x86_64-unknown-linux-musl` I couldn't test `x86_64-unknown-linux-gnu` because of #455 <details> <summary>#455 error message. This will be happened without this PR (with the image from DockerHub)</summary> ``` Compiling libc v0.2.107 Compiling ffmpeg-sys-next v4.4.0 error: failed to run custom build command for `libc v0.2.107` Caused by: process didn't exit successfully: `/target/release/build/libc-e4387d0c49bcd20f/build-script-build` (exit status: 1) --- stderr /target/release/build/libc-e4387d0c49bcd20f/build-script-build: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /target/release/build/libc-e4387d0c49bcd20f/build-script-build) warning: build failed, waiting for other jobs to finish... error: build failed ``` </details> Co-authored-by: anatawa12 <anatawa12@icloud.com>
It looks like this may be because calling Indeed:
That is because no new cross release was created since #501 was merged. Installing cross from github with:
will pull in |
Although GLIBC 2.15 is mentioned in the table the compiled binary contains multiple symbols from higher version:
GLIBC_2.18 __cxa_thread_atexit_impl
GLIBC_2.17 secure_getenv
The command used is:
cross build --target=x86_64-unknown-linux-gnu --release
I have tried earlier docker images as well: 0.1.15, 0.1.16, 0.2.0.
When I build the project directly under a Linux VM with an earlier GLIBC version it produces a correct binary.
The text was updated successfully, but these errors were encountered: