Hi. I'm trying to build the Rust compiler using toolchains installed by Nix on non-NixOS Linux (WSL2 Ubuntu).
However, when I run ./x.py, the command fails to bootstrap with the following error:
[nix-shell:~/rust]$ ./x.py
info: Downloading and building bootstrap before processing --help
command. See src/bootstrap/README.md for help with common
commands.
Updating only changed submodules
Submodules updated in 0.01 seconds
Compiling proc-macro-error v1.0.4
Compiling serde v1.0.125
error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/pan/rust/build/bootstrap/debug/deps/libproc_macro_error_attr-d5982b949b70dcd0.so)
--> /home/pan/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro-error-1.0.4/src/lib.rs:284:9
|
284 | pub use proc_macro_error_attr::proc_macro_error;
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: could not compile `proc-macro-error`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/pan/rust/build/bootstrap/debug/deps/libserde_derive-913893717e9d98bd.so)
--> /home/pan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.125/src/lib.rs:293:1
|
293 | extern crate serde_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: build failed
failed to run: /home/pan/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/pan/rust/src/bootstrap/Cargo.toml
I am confused because the error message points to the system libc, but when I use ldd it points to the libc managed by Nix.
[nix-shell:~/rust]$ ldd build/bootstrap/debug/deps/libserde_derive-913893717e9d98bd.so
linux-vdso.so.1 (0x00007ffc33bfb000)
libgcc_s.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libgcc_s.so.1 (0x00007f09c0618000)
libpthread.so.0 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libpthread.so.0 (0x00007f09c05f7000)
libdl.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libdl.so.2 (0x00007f09c05f2000)
libc.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libc.so.6 (0x00007f09c0431000)
/nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib64/ld-linux-x86-64.so.2 (0x00007f09c0d5e000)
[nix-shell:~/rust]$ ldd build/x86_64-unknown-linux-gnu/stage0/bin/cargo
linux-vdso.so.1 (0x00007ffe47739000)
libgcc_s.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libgcc_s.so.1 (0x00007fa0fda28000)
librt.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/librt.so.1 (0x00007fa0fda1d000)
libpthread.so.0 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libpthread.so.0 (0x00007fa0fd9fc000)
libm.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libm.so.6 (0x00007fa0fd8b9000)
libdl.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libdl.so.2 (0x00007fa0fd8b4000)
libc.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libc.so.6 (0x00007fa0fd6f3000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib64/ld-linux-x86-64.so.2 (0x00007fa0feaad000)
Do you have any idea what is the cause of this problem?
bjorn3
July 24, 2021, 4:48pm
2
Glibc uses symbol versioning. This means that if you link against a certain version of glibc, you must use at least this version at runtime. NixOS likely has a more recent version of glibc than Ubuntu. This means that you can't use executables built on NixOS on Ubuntu. The standard solution for this is building inside a container (or nix environment I think) that has an older glibc version installed. The rustc CI uses CentOS I think as they use a pretty old version of glibc.
1 Like
I guess I'm hitting this:
opened 11:28AM - 22 Jan 19 UTC
A-linkage
C-bug
**Problem**
It's been just two months I have not touched Rust but today aft… er upgrading to the most recent version I was no longer able to use `cargo install`.
**Steps**
1. update to rust 1.32: `rustup update` + `rustup default stable`
2. `cargo install ripgrep`
at the end of compilation the error message shows up:
...
Compiling globset v0.4.2
Compiling grep-regex v0.1.1
Compiling grep-cli v0.1.1
Compiling ignore v0.4.6
Compiling grep-printer v0.1.1
error: /usr/lib64/libc.so.6: version `GLIBC_2.18' not found (required by /tmp/cargo-installkV0c2k/release/deps/libserde_derive-615594b83ebc865a.so)
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/grep-printer-0.1.1/src/lib.rs:81:1
|
81 | extern crate serde_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: failed to compile `ripgrep v0.10.0`, intermediate artifacts can be found at `/tmp/cargo-installkV0c2k`
I think the problem happens at linking time so I don't know if the additional error message at the end was really helpful.
This should not happen because `rustc` is not supposed to link against `/usr/lib64/libc.so.6`:
➜ ~ ldd /tmp/cargo-installkV0c2k/release/deps/libserde_derive-615594b83ebc865a.so
linux-vdso.so.1 (0x00007fffe41ba000)
libdl.so.2 => /home/linuxbrew/.linuxbrew/lib/libdl.so.2 (0x00007ff1ce55a000)
librt.so.1 => /home/linuxbrew/.linuxbrew/lib/librt.so.1 (0x00007ff1ce352000)
libpthread.so.0 => /home/linuxbrew/.linuxbrew/lib/libpthread.so.0 (0x00007ff1ce135000)
libgcc_s.so.1 => /home/linuxbrew/.linuxbrew/lib/libgcc_s.so.1 (0x00007ff1cdf1e000)
libc.so.6 => /home/linuxbrew/.linuxbrew/lib/libc.so.6 (0x00007ff1cdb7f000)
/home/linuxbrew/.linuxbrew/Cellar/glibc/2.23/lib64/ld-linux-x86-64.so.2 (0x00007ff1cea71000)
and `/home/linuxbrew/.linuxbrew/lib/libc.so.6` is an updated version of glibc:
➜ ~ strings /home/linuxbrew/.linuxbrew/lib/libc.so.6 | grep ^GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_PRIVATE
GLIBC_2.23
GLIBC_2.8
GLIBC_2.5
GLIBC_2.9
GLIBC_2.7
GLIBC_2.6
GLIBC_2.18
GLIBC_2.11
GLIBC_2.16
GLIBC_2.10
GLIBC_2.17
GLIBC_2.13
GLIBC_2.2.6
**Notes**
Output of `cargo version`:
➜ ~ cargo version
cargo 1.32.0 (8610973aa 2019-01-02)
➜ ~ rustc --version
rustc 1.32.0 (9fda7c223 2019-01-16)
The platform I have is CentOS 7. And if I downgrade rust to 1.31.0, it works without any problem. So this should be related to the version update.
opened 07:09AM - 12 Feb 19 UTC
closed 11:42PM - 13 Feb 19 UTC
A-linkage
T-compiler
If the versions of system glibc and linuxbrew glibc are different, building crat… es using proc_macro (ex. serde_derive, structopt_derive) is failed at Rust 1.32.0.
In Rust 1.31.1, this issue don't occur.
## Environment
CentOS Linux release 7.6.1810 (Core)
Rust 1.32.0, 1.31.1
System glibc: 2.17
linuxbrew glibc: 2.23
## Step
### Source code
Cargo.toml
```toml
[package]
name = "temp"
version = "0.1.0"
[dependencies]
structopt = "0.2.14"
```
src/main.rs
```
#[macro_use]
extern crate structopt;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct Opt {}
fn main() {
let _ = Opt::from_args();
println!("Hello, world!");
}
```
### Build result
```
$ rustup override set 1.32.0
$ cargo clean; cargo run
Compiling structopt v0.2.14
error: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/dalance/work/repos/temp/target/debug/deps/libstructopt_derive-cdf0ae629ff7e333.so)
--> /home/dalance/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-0.2.14/src/lib.rs:490:1
|
490 | extern crate structopt_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: Could not compile `structopt`.
```
The `ldd` result of `libstructopt_derive....so` is below.
In this result, linker should search to linuxbrew's glibc, but actually search to system glibc.
```
$ ldd /home/dalance/work/repos/temp/target/debug/deps/libstructopt_derive-cdf0ae629ff7e333.so
linux-vdso.so.1 (0x00007fffac483000)
libdl.so.2 => /home/dalance/.linuxbrew/lib/libdl.so.2 (0x00007f2c95292000)
librt.so.1 => /home/dalance/.linuxbrew/lib/librt.so.1 (0x00007f2c95288000)
libpthread.so.0 => /home/dalance/.linuxbrew/lib/libpthread.so.0 (0x00007f2c95268000)
libgcc_s.so.1 => /home/dalance/.linuxbrew/lib/libgcc_s.so.1 (0x00007f2c95051000)
libc.so.6 => /home/dalance/.linuxbrew/lib/libc.so.6 (0x00007f2c94eb3000)
/home/dalance/.linuxbrew/Cellar/glibc/2.23/lib64/ld-linux-x86-64.so.2 (0x00007f2c9566a000)
```
### Workaround
If `.cargo/config` set to below, build is passed at Rust 1.32.0.
```
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/cc"
```
## Broken revision
I run `git bisect` from 1.31.1 to 1.32.0. The result is below.
```
188d2dafcdd4d0dbd54315412503fb8011d716b6 is the first bad commit
commit 188d2dafcdd4d0dbd54315412503fb8011d716b6
Author: Eduard-Mihai Burtescu <edy.burt@gmail.com>
Date: Thu Apr 26 14:11:08 2018 +0300
Statically link proc_macro into proc macros.
:040000 040000 a218f2092aad86632374db4fc3ba0effe6705d7f b8357a8a11394a8ab0f6e20875802930dd0ecc9f M src
bisect run success
```
`git bisect log` is below.
```
# bad: [9fda7c2237db910e41d6a712e9a2139b352e558b] Auto merge of #57600 - rust-lang:stable-next, r=alexcrichton
# good: [b6c32da9b0481e3e9d737153286b3ff8aa39a22c] Auto merge of #56960 - pietroalbini:gpg-stable, r=pietroalbini
git bisect start '1.32.0' '1.31.1'
# good: [4bd4e4130ed531a644263db26bf8461704215c77] Auto merge of #54490 - wesleywiser:rewrite_it_in_mir, r=oli-obk
git bisect good 4bd4e4130ed531a644263db26bf8461704215c77
# good: [6ca7bc0eb8648abc8673a971c85b777a6bc62e16] Rollup merge of #55781 - pnkfelix:issue-54382-more-precise-spans-for-temps-and-their-drops, r=davidtwco
git bisect good 6ca7bc0eb8648abc8673a971c85b777a6bc62e16
# good: [45e5a856a6551ae1b77fe8c5585e80f886b44b6e] Rollup merge of #56100 - RalfJung:visiting-generators, r=oli-obk
git bisect good 45e5a856a6551ae1b77fe8c5585e80f886b44b6e
# bad: [fb2b2f5582b9eff3ee5d98ec5c9461847b6f0b2d] Rollup merge of #56367 - alexreg:move-feature-gate-tests-1, r=Centril
git bisect bad fb2b2f5582b9eff3ee5d98ec5c9461847b6f0b2d
# good: [5d7717360c8f343f70a33455029355f00e39dea2] fix test
git bisect good 5d7717360c8f343f70a33455029355f00e39dea2
# good: [1fe2085441c5c9afc1523c19c1c1ddbf86bae462] Rollup merge of #56322 - petrochenkov:edlints, r=eddyb
git bisect good 1fe2085441c5c9afc1523c19c1c1ddbf86bae462
# bad: [b8198da4d2a9e643a9863bf4cddd82d01ebc3f71] Rollup merge of #55821 - ljedrz:cached_key_sorts, r=michaelwoerister
git bisect bad b8198da4d2a9e643a9863bf4cddd82d01ebc3f71
# good: [67afeef9e472812ba85341114c21289c75790a3e] proc_macro: move to a dependency of libtest.
git bisect good 67afeef9e472812ba85341114c21289c75790a3e
# bad: [eb2c71cdf2d154a217e155d96474f4988e04a253] bootstrap: don't use libraries from MUSL_ROOT on non-musl targets.
git bisect bad eb2c71cdf2d154a217e155d96474f4988e04a253
# bad: [fcca22cb4072097fc2cd1ae78ff84c7d59aacda2] tests: move all proc_macro tests from -fulldeps.
git bisect bad fcca22cb4072097fc2cd1ae78ff84c7d59aacda2
# bad: [d3ab4a74efad266155fcd402c8d159af9e443e3d] tests: remove ignore-stage1 where possible in proc_macro tests.
git bisect bad d3ab4a74efad266155fcd402c8d159af9e443e3d
# bad: [188d2dafcdd4d0dbd54315412503fb8011d716b6] Statically link proc_macro into proc macros.
git bisect bad 188d2dafcdd4d0dbd54315412503fb8011d716b6
# first bad commit: [188d2dafcdd4d0dbd54315412503fb8011d716b6] Statically link proc_macro into proc macros.
```
## Related issue
This issue seems to be the same.
https://github.com/rust-lang/cargo/issues/6582
According to these issues, the cause of this problem seems to be the mismatch between glibc used for building proc macros and used by rustc's dlopen invocation.
However, both proc macro and rustc seem to be linked against the same glibc (installed by Nix), and this glibc does support GLIBC_2_32:
[nix-shell:~/rust]$ ldd ./build/x86_64-unknown-linux-gnu/stage0/bin/rustc
linux-vdso.so.1 (0x00007fd499819000)
librustc_driver-07fada1ea7dc8755.so => /home/pan/rust/./build/x86_64-unknown-linux-gnu/stage0/bin/../lib/librustc_driver-07fada1ea7dc8755.so (0x00007fd495a7f000)
libstd-55e6ef8aa4a5856f.so => /home/pan/rust/./build/x86_64-unknown-linux-gnu/stage0/bin/../lib/libstd-55e6ef8aa4a5856f.so (0x00007fd495703000)
libpthread.so.0 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libpthread.so.0 (0x00007fd4956e2000)
librt.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/librt.so.1 (0x00007fd4956d7000)
libdl.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libdl.so.2 (0x00007fd4956d2000)
libc.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libc.so.6 (0x00007fd495511000)
libLLVM-12-rust-1.54.0-beta.so => /home/pan/rust/./build/x86_64-unknown-linux-gnu/stage0/bin/../lib/../lib/libLLVM-12-rust-1.54.0-beta.so (0x00007fd4902e8000)
libgcc_s.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libgcc_s.so.1 (0x00007fd4902ce000)
libm.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libm.so.6 (0x00007fd49018b000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib64/ld-linux-x86-64.so.2 (0x00007fd49981b000)
libz.so.1 => not found
[nix-shell:~/rust]$ ldd ./build/bootstrap/debug/deps/libproc_macro_error_attr-d5982b949b70dcd0.so
linux-vdso.so.1 (0x00007ffc6fffc000)
libgcc_s.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libgcc_s.so.1 (0x00007f1538de8000)
libpthread.so.0 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libpthread.so.0 (0x00007f1538dc7000)
libdl.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libdl.so.2 (0x00007f1538dc2000)
libc.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libc.so.6 (0x00007f1538c01000)
/nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib64/ld-linux-x86-64.so.2 (0x00007f1539055000)
I don't get why system libc (/lib/x86_64-linux-gnu/libc.so.6) is used and appears in the error message in the first place😅
I don't think I'm using binaries built on NixOS but bootstrapping binaries automatically downloaded by x.py.
Yes, at runtime. However, your error:
indicates that the system libc is being used during the build. I suspect that your Nix environment is either not set up properly or rpath entries are missing.
1 Like
I found that LD_TRACE_LOADED_OBJECTS=1 and ldd return different libc paths for the bootstrap rustc😂
[nix-shell:~/rust]$ LD_TRACE_LOADED_OBJECTS=1 ./build/x86_64-unknown-linux-gnu/stage0/bin/rustc
linux-vdso.so.1 (0x00007ffd63d88000)
librustc_driver-07fada1ea7dc8755.so => /home/pan/rust/build/x86_64-unknown-linux-gnu/stage0/bin/../lib/librustc_driver-07fada1ea7dc8755.so (0x00007f5b8e049000)
libstd-55e6ef8aa4a5856f.so => /home/pan/rust/build/x86_64-unknown-linux-gnu/stage0/bin/../lib/libstd-55e6ef8aa4a5856f.so (0x00007f5b8dccd000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5b8dca2000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5b8dc97000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5b8dc91000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5b8da9f000)
libLLVM-12-rust-1.54.0-beta.so => /home/pan/rust/build/x86_64-unknown-linux-gnu/stage0/bin/../lib/../lib/libLLVM-12-rust-1.54.0-beta.so (0x00007f5b88876000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5b8885b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5b8870c000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5b9196d000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f5b886f0000)
[nix-shell:~/rust]$ ldd ./build/x86_64-unknown-linux-gnu/stage0/bin/rustc
linux-vdso.so.1 (0x00007ffca0eb4000)
librustc_driver-07fada1ea7dc8755.so => /home/pan/rust/./build/x86_64-unknown-linux-gnu/stage0/bin/../lib/librustc_driver-07fada1ea7dc8755.so (0x00007f5119adc000)
libstd-55e6ef8aa4a5856f.so => /home/pan/rust/./build/x86_64-unknown-linux-gnu/stage0/bin/../lib/libstd-55e6ef8aa4a5856f.so (0x00007f5119760000)
libpthread.so.0 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libpthread.so.0 (0x00007f511973f000)
librt.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/librt.so.1 (0x00007f5119734000)
libdl.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libdl.so.2 (0x00007f511972f000)
libc.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libc.so.6 (0x00007f511956e000)
libLLVM-12-rust-1.54.0-beta.so => /home/pan/rust/./build/x86_64-unknown-linux-gnu/stage0/bin/../lib/../lib/libLLVM-12-rust-1.54.0-beta.so (0x00007f5114345000)
libgcc_s.so.1 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libgcc_s.so.1 (0x00007f511432b000)
libm.so.6 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib/libm.so.6 (0x00007f51141e8000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/v8q6nxyppy1myi3rxni2080bv8s9jxiy-glibc-2.32-40/lib64/ld-linux-x86-64.so.2 (0x00007f511d873000)
libz.so.1 => not found
So yes, system libc is used by rustc. Then I need to find a way to override these paths...
bjorn3
July 25, 2021, 7:29pm
7
Bootstrap patches rustc automatically on NixOS. It probably doesn't do this for you. The normal way to patch it for Nix would be using patchelf to override the interpreter and append the rpath. It is probably easier to convince bootstrap that you are on NixOS though. I think removing
will do the trick.
1 Like
Commenting out these lines did the trick. Thanks!
It makes sense that the bootstrap binaries were not patched because my environment is a usual Linux with Nix, not NixOS.
Now I am wondering if it would be a good idea to send a patch to add a config that overrides this check to compile rustc with Nix's toolchain.
system
Closed
October 24, 2021, 3:58am
9
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.