#How to build rustc fully static with the llvm stack

13 messages · Page 1 of 1 (latest)

vernal adder
#

Hi, how can I build rust fully static from source with full llvm stack, ie libc++, uniwnd and compiler rt

currently I'm trying this bootstrap.toml

with no success

change-id = 147888
[llvm]
use-libcxx = true
download-ci-llvm = false
targets = "AArch64;ARM;RISCV;WebAssembly;X86"
experimental-targets = "Xtensa"
cflags = "-fuse-ld=lld -std=c23 -fPIC -nostdinc++ -isystem /home/mccakit/dev/libcxx/native/include/c++/v1"
cxxflags = "-fuse-ld=lld -std=c++26 -fPIC -nostdinc++ -isystem /home/mccakit/dev/libcxx/native/include/c++/v1"
ldflags = "-fuse-ld=lld -rtlib=compiler-rt -nostdlib++ /home/mccakit/dev/libcxx/native/lib/libc++.a /home/mccakit/dev/libcxx/native/lib/libc++abi.a /home/mccakit/dev/libcxx/native/lib/libunwind.a"
[rust]
codegen-tests = false
[target.x86_64-unknown-linux-gnu]
cc = "/home/mccakit/dev/llvm/bin/clang"
cxx = "/home/mccakit/dev/llvm/bin/clang++"
ar = "/home/mccakit/dev/llvm/bin/llvm-ar"
linker = "/home/mccakit/dev/llvm/bin/clang"
ranlib = "/home/mccakit/dev/llvm/bin/llvm-ranlib"
llvm-libunwind = 'in-tree'
[build]
cargo-native-static = true

I also export these flags before running./x build

export RUSTFLAGS="-C link-arg=-fuse-ld=lld -C link-arg=-rtlib=compiler-rt -C link-arg=-nostdlib++ -C link-arg=/home/mccakit/dev/libcxx/native/lib/libc++.a -C link-arg=/home/mccakit/dev/libcxx/native/lib/libc++abi.a -C link-arg=/home/mccakit/dev/libcxx/native/lib/libunwind.a"
surreal sundial
#

Not an answer, but #957720175619215380 may be able to help with that

restive niche
#

or at least, you can't just make all the C code statically linked in order to get a statically linked compiler

#

@misty apex may know better

vernal adder
misty apex
#

Be aware that a fully statically linked (as in also statically linking libc) rustc can't load proc macros.

#

For statically linking LLVM and libstdc++ (not libc++) you can use llvm.link-shared = false + llvm.static-libstdcpp = true.

misty apex
vernal adder
#

I'm having trouble with stdlib right now