Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThinLTO and multiple codegen units causes linking failure on Mac #45165

Closed
joshlf opened this issue Oct 10, 2017 · 3 comments
Closed

ThinLTO and multiple codegen units causes linking failure on Mac #45165

joshlf opened this issue Oct 10, 2017 · 3 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-macos Operating system: macOS

Comments

@joshlf
Copy link
Contributor

joshlf commented Oct 10, 2017

Compiling the elfc crate at this commit of elfmalloc causes a linking failure with:

  • the current nightly
  • on Mac
  • with ThinLTO enabled
  • in release mode
  • with codegen-units=16

(RUSTFLAGS='-C codegen-units=16 -Z thinlto' cargo build --release)

  = note: Undefined symbols for architecture x86_64:
            "___rg_realloc", referenced from:
                ___rust_realloc in elfc.crate.allocator.rust-cgu.o
            "___rg_dealloc", referenced from:
                ___rust_dealloc in elfc.crate.allocator.rust-cgu.o
            "___rg_oom", referenced from:
                ___rust_oom in elfc.crate.allocator.rust-cgu.o
            "___rg_alloc", referenced from:
                ___rust_alloc in elfc.crate.allocator.rust-cgu.o
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Version: cargo 0.23.0-nightly (e447ac7e9 2017-09-27)

Building with cargo build --release and either of -C codegen-units=16 or -Z thinlto on their own works fine.

@joshlf joshlf changed the title ThinLTO causes linking failure on Mac ThinLTO and multiple codegen units causes linking failure on Mac Oct 10, 2017
@michaelwoerister
Copy link
Member

cc @alexcrichton

@michaelwoerister
Copy link
Member

Thank you for the bug report, @joshlf!

@TimNN TimNN added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-macos Operating system: macOS labels Oct 10, 2017
@joshlf
Copy link
Contributor Author

joshlf commented Oct 10, 2017

np!

alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 11, 2017
This commit updates the reachability pass of the compiler to seed the local
worklist with `#[linkage]`-like items anywhere in a crate, not just those
reachable from public items.

Closes rust-lang#45165
kennytm added a commit to kennytm/rust that referenced this issue Oct 12, 2017
…michaelwoerister

rustc: Handle `#[no_mangle]` anywhere in a crate

This commit updates the reachability pass of the compiler to seed the local
worklist with `#[no_mangle]`-like items anywhere in a crate, not just those
reachable from public items.

Closes rust-lang#45165
alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 12, 2017
This commit updates the reachability pass of the compiler to seed the local
worklist with `#[linkage]`-like items anywhere in a crate, not just those
reachable from public items.

Closes rust-lang#45165
kennytm added a commit to kennytm/rust that referenced this issue Oct 13, 2017
…michaelwoerister

rustc: Handle `#[no_mangle]` anywhere in a crate

This commit updates the reachability pass of the compiler to seed the local
worklist with `#[no_mangle]`-like items anywhere in a crate, not just those
reachable from public items.

Closes rust-lang#45165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-macos Operating system: macOS
Projects
None yet
Development

No branches or pull requests

3 participants