Skip to content

Issue linking libunwind in release mode when using LTO #65

Closed
@jethrogb

Description

@jethrogb
ring$ cargo +nightly rustc --test quic_tests --release --target=x86_64-fortanix-unknown-sgx -- -C codegen-units=1
   Compiling ring v0.14.2 (~/projects/rust-sgx/hello/ring)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-fuse-ld=gold" "-nostdlib" "-shared" "-Wl,-e,sgx_entry" "-Wl,-Bstatic" "-Wl,--gc-sections" "-Wl,-z,text" "-Wl,-z,norelro" "-Wl,--rosegment" "-Wl,--no-undefined" "-Wl,--error-unresolved-symbols" "-Wl,--no-undefined-version" "-Wl,-Bsymbolic" "-Wl,--export-dynamic" "-L" "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-fortanix-unknown-sgx/lib" "~/projects/rust-sgx/hello/ring/target/x86_64-fortanix-unknown-sgx/release/deps/quic_tests-60cfc7f9614a1667.quic_tests.bo3mv8ta-cgu.0.rcgu.o" "-o" "~/projects/rust-sgx/hello/ring/target/x86_64-fortanix-unknown-sgx/release/deps/quic_tests-60cfc7f9614a1667" "-Wl,--gc-sections" "-pie" "-Wl,-O1" "-nodefaultlibs" "-L" "~/projects/rust-sgx/hello/ring/target/x86_64-fortanix-unknown-sgx/release/deps" "-L" "~/projects/rust-sgx/hello/ring/target/release/deps" "-L" "~/projects/rust-sgx/hello/ring/target/x86_64-fortanix-unknown-sgx/release/build/ring-9f5b619728470617/out" "-L" "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-fortanix-unknown-sgx/lib" "-Wl,-Bstatic" "/tmp/rustchwXbIV/libring-5d3d20b089bc71bf.rlib" "/tmp/rustchwXbIV/libbacktrace_sys-6741d64f34191261.rlib" "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-fortanix-unknown-sgx/lib/libcompiler_builtins-c8174d577f7ebb97.rlib" "-Wl,-Bdynamic" "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-fortanix-unknown-sgx/lib/libunwind.a"
  = note: ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-fortanix-unknown-sgx/lib/libunwind.a(UnwindRustSgx.c.o):UnwindRustSgx.c:function libuw_malloc: error: undefined reference to '__rust_alloc'
          ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-fortanix-unknown-sgx/lib/libunwind.a(UnwindRustSgx.c.o):UnwindRustSgx.c:function libuw_free: error: undefined reference to '__rust_dealloc'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `ring`.

To learn more, run the command again with --verbose.

But without LTO:

ring$ cargo +nightly rustc --test quic_tests --release --target=x86_64-fortanix-unknown-sgx -- -C lto=no
   Compiling ring v0.14.2 (~/projects/rust-sgx/hello/ring)
    Finished release [optimized] target(s) in 0.59s

Metadata

Metadata

Labels

bugstd/rustcRequires changes in Rust std/rustc

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions