Issues building rattler-build due to linking errors when using conda-forge rust
I'm running into a linking issue when trying to build rattler-build using the rust toolchain provided by conda-forge.
For reference, here's the package list in my environment:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓
┃ Name ┃ Version ┃ Type ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩
│ _libgcc_mutex │ 0.1 │ conda │
│ _openmp_mutex │ 4.5 │ conda │
│ binutils │ 2.43 │ conda │
│ binutils_impl_linux-64 │ 2.43 │ conda │
│ binutils_linux-64 │ 2.43 │ conda │
│ bzip2 │ 1.0.8 │ conda │
│ c-compiler │ 1.9.0 │ conda │
│ ca-certificates │ 2025.1.31 │ conda │
│ cxx-compiler │ 1.9.0 │ conda │
│ gcc │ 13.3.0 │ conda │
│ gcc_impl_linux-64 │ 13.3.0 │ conda │
│ gcc_linux-64 │ 13.3.0 │ conda │
│ gxx │ 13.3.0 │ conda │
│ gxx_impl_linux-64 │ 13.3.0 │ conda │
│ gxx_linux-64 │ 13.3.0 │ conda │
│ kernel-headers_linux-64 │ 3.10.0 │ conda │
│ ld_impl_linux-64 │ 2.43 │ conda │
│ libcxx │ 19.1.7 │ conda │
│ libcxx-devel │ 19.1.7 │ conda │
│ libcxxabi │ 19.1.7 │ conda │
│ libexpat │ 2.6.4 │ conda │
│ libffi │ 3.4.6 │ conda │
│ libgcc │ 14.2.0 │ conda │
│ libgcc-devel_linux-64 │ 13.3.0 │ conda │
│ libgcc-ng │ 14.2.0 │ conda │
│ libgomp │ 14.2.0 │ conda │
│ liblzma │ 5.6.4 │ conda │
│ libnsl │ 2.0.1 │ conda │
│ libsanitizer │ 13.3.0 │ conda │
│ libsqlite │ 3.49.1 │ conda │
│ libstdcxx │ 14.2.0 │ conda │
│ libstdcxx-devel_linux-64 │ 13.3.0 │ conda │
│ libstdcxx-ng │ 14.2.0 │ conda │
│ libuuid │ 2.38.1 │ conda │
│ libxcrypt │ 4.4.36 │ conda │
│ libzlib │ 1.3.1 │ conda │
│ ncurses │ 6.5 │ conda │
│ openssl │ 3.4.1 │ conda │
│ patchelf │ 0.17.2 │ conda │
│ pip │ 25.0.1 │ conda │
│ python │ 3.12.9 │ conda │
│ readline │ 8.2 │ conda │
│ rust │ 1.85.0 │ conda │
│ rust-std-x86_64-unknown-linux-gnu │ 1.85.0 │ conda │
│ setuptools │ 75.8.2 │ conda │
│ sysroot_linux-64 │ 2.17 │ conda │
│ tk │ 8.6.13 │ conda │
│ tzdata │ 2025a │ conda │
│ wheel │ 0.45.1 │ conda │
I get the following linking error when running cargo build:
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: /home/alfredo_luque/.airconda-environments/local--rattler_build--v0.0.1/bin/../lib/gcc/x86_64-conda-linux-gnu/13.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/alfredo_luque/.airconda-environments/local--rattler_build--v0.0.1/bin/../x86_64-conda-linux-gnu/sysroot/usr/lib/../lib/Scrt1.o: in function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/home/alfredo_luque/.airconda-environments/local--rattler_build--v0.0.1/bin/../lib/gcc/x86_64-conda-linux-gnu/13.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: (.text+0x19): undefined reference to `__libc_csu_init'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
error: could not compile `rattler-build` (bin "rattler-build") due to 1 previous error
(this is on an x86_64 Linux development instance).
I'm newer to the rust ecosystem so it's totally possible I'm missing something obvious :)
My host does have libc and libc-dev installed as well in case those are needed from the host.
I think we have a activation scritp in pixi to work around this: https://github.com/prefix-dev/rattler-build/blob/main/scripts/activate.sh
Does that help?
Oh sorry, just seeing that this si a linux issue :/
Oh sorry, just seeing that this si a linux issue :/
Yeah, funny enough it builds+links just fine on OSX.
Can you try installing lld, clang (basically compiler and linker) in your set up and try again? Linux, on my end, always required linkers to be installed separately for rust. (with or without pixi, on all codebases) Because I have them installed I can’t reproduce this issue at all.