Skip to content

Linking with ld.gold fails: "nostart-stop-gc: unknown -z option" #97

@dtolnay

Description

@dtolnay

I hit this in dtolnay/proc-macro2#494. Compilers nightly-2025-03-08 and older work, but nightly-2025-03-09 and newer fail as follows:

$ cargo hfuzz build
   Compiling semver v1.0.26
   Compiling honggfuzz v0.5.56
   Compiling proc-macro2 v1.0.94
   Compiling unicode-ident v1.0.18
   Compiling lazy_static v1.5.0
   Compiling arbitrary v1.4.1
   Compiling rustc_version v0.4.1
   Compiling proc-macro2-fuzz v0.0.0
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/rustcKwt18g/symbols.o" "<6 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "hfuzz_target/x86_64-unknown-linux-gnu/release/deps/{libproc_macro2-52b56881b388848b.rlib,libunicode_ident-c8c3ebc46cfbdef7.rlib,libhonggfuzz-ab26354189c9f60e.rlib,liblazy_static-5fed7bd649267e72.rlib,libarbitrary-c41b6f4856e8de4a.rlib}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcKwt18g/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,-znostart-stop-gc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "hfuzz_target/x86_64-unknown-linux-gnu/release/build/honggfuzz-0aa6eef419f64960/out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "hfuzz_target/x86_64-unknown-linux-gnu/release/deps/parse_token_stream-0d38af20dbe11731" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-fuse-ld=gold"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld.gold: nostart-stop-gc: unknown -z option
          /usr/bin/ld.gold: use the --help option for usage information
          collect2: error: ld returned 1 exit status
          
error: could not compile `proc-macro2-fuzz` (bin "parse_token_stream") due to 1 previous error

Bisects to rust-lang/rust#137685.

Workaround: dtolnay/proc-macro2#495 RUSTFLAGS=-Clink-arg=-fuse-ld=lld

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions