Skip to content

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

Closed
@joshlf

Description

@joshlf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-macosOperating system: macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions