Hi Kai,

On Sat, Nov 15, 2014 at 11:02 PM, Kai Noda <noda...@gmail.com> wrote:
> Hi Paul,
>
> I managed to get it working by manually tweaking linker options (this
> mustn't be the right way to go...)
>
> Rust devs: what is the official way to do this?  Simply adding "-C
> link-args=-static" doesn't work (see my second transcript)
>
> $ cat hello-rust.rs
> fn main() {
>     println!("Hello, world!");
> }
> $ rlibs=`rustc -Z print-link-args hello-rust.rs | sed -e 's/ /\n/g' | grep
> rlib`
> $ echo $rlibs
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustrt-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib'
> '/home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib'
> $ rustc -Z print-link-args --emit obj hello-rust.rs
> $ file hello-rust.o
> hello-rust.o: ELF 64-bit LSB relocatable, x86-64, version 1 (GNU/Linux), not
> stripped
> $ eval "gcc -static -static-libgcc hello-rust.o `tr $'\n' ' '<<<$rlibs`
> -lpthread -lm -ldl -lrt -o hello-rust"
> /home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib(std-4e7c5e5c.o):
> In function `dynamic_lib::dl::open_internal::hda8e305d06a14b844og':
> std.0.rs:(.text._ZN11dynamic_lib2dl13open_internal20hda8e305d06a14b844ogE+0x8):
> warning: Using 'dlopen' in statically linked applications requires at
> runtime the shared libraries from the glibc version used for linking
> /home/nodakai/local/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib(std-4e7c5e5c.o):
> In function `io::net::addrinfo::get_host_addresses::hf208fefd6f07b89awSi':
> std.0.rs:(.text._ZN2io3net8addrinfo18get_host_addresses20hf208fefd6f07b89awSiE+0xad):
> warning: Using 'getaddrinfo' in statically linked applications requires at
> runtime the shared libraries from the glibc version used for linking
> $ file ./hello-rust
> ./hello-rust: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
> statically linked, for GNU/Linux 2.6.24,
> BuildID[sha1]=0x7fa2ba5ebdec633b220a8e9c988c4632b26a17d9, not stripped
> $ ./hello-rust
> Hello, world!

Sure, this is a workaround. But it works, until rust will support
alternative libc implementations. Thanks a lot!

-- 
Paul
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to