Skip to content

0.16.0-rc.1 fails to build with mold #18499

@musjj

Description

@musjj

Bevy version

0.16.0-rc.1

[Optional] Relevant system information

$ cargo --version
cargo 1.87.0-nightly (307cbfda3 2025-03-20)

$ nixos-version
25.05.20250313.6607cf7 (Warbler)

What you did

Build bevy 0.16.0-rc.1 with mold as the linker. Changing it back to 0.15.3 fixes the error.

What went wrong

Here's the error log:

Error log
   Compiling bevy-016-mold-bug v0.1.0 (/tmp/bevy-016-mold-bug)
error: linking with `/nix/store/q87df3dw0x7r1k9gagir9a5sdi3gmw4a-clang-wrapper-19.1.7/bin/clang` failed: exit status: 1
  |
  = note:  "/nix/store/q87df3dw0x7r1k9gagir9a5sdi3gmw4a-clang-wrapper-19.1.7/bin/clang" "-m64" "/tmp/rustczjVsR2/symbols.o" "<9 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/tmp/bevy-016-mold-bug/target/x86_64-unknown-linux-gnu/debug/deps/{libbevy-1ecff6bbac99b899.rlib,libbevy_internal-6bc43b0947abd6f5.rlib,libbevy_diagnostic-62d6a743ef3221b7.rlib,libbevy_time-07f3fe8faf4eb3f1.rlib,libconst_fnv1a_hash-5560cad304114b34.rlib,libbevy_app-edadf848fd1866b9.rlib,libbevy_ecs-c002ce99a645b224.rlib,libbevy_tasks-c6d25798c12c645f.rlib,libcrossbeam_queue-f58b757e8b91de9e.rlib,libcrossbeam_utils-aa8ff3fddfff6f1a.rlib,libonce_cell-9db063a4c89774fd.rlib,libportable_atomic-aef3f9f55c4cb211.rlib,libcritical_section-02e6c46e61cc195f.rlib,libfutures_lite-bd92f80faa5f80ee.rlib,libfutures_core-aa79eedaeaf3ded4.rlib,libpin_project_lite-ce29122eec959af2.rlib,libatomic_waker-b123c0350b3e57be.rlib,libasync_task-b091def3d2f50903.rlib,libbitflags-af742551cd05d212.rlib,libnonmax-dfdbcef58135411c.rlib,libfixedbitset-f0d53a390727a74f.rlib,liblog-238ea7341e73e249.rlib,libindexmap-3b6af499f5cb8e26.rlib,libbumpalo-892db3b5c1484785.rlib,libdisqualified-09ad1953ab29d866.rlib,libbevy_reflect-7f725f7dc39488e0.rlib,liberased_serde-d6cbd47ca96c0cb7.rlib,libtypeid-ec6d1a4e1bc0249a.rlib,libsmallvec-389d302561e600c6.rlib,libdowncast_rs-00f5813fca2c4f0c.rlib,libderive_more-161db31572575072.rlib,libthiserror-c31ceb4f9469d9e8.rlib,libbevy_utils-985f85c59b33feb5.rlib,libbevy_ptr-c6cd660135f649b9.rlib,libbevy_platform_support-1f142ec953228405.rlib,libcfg_if-e4ddd72bc51b3e1c.rlib,libhashbrown-c0e77e0824b2f2da.rlib,libequivalent-b0c8894b2dc5a67e.rlib,libserde-2937defad2a20a81.rlib,libspin-ec8fa05df271a36a.rlib,libfoldhash-6868e57a75c60f5b.rlib}.rlib" "/nix/store/40fs2v7zv0yxgcdy2733nv1r4rz42a98-rust-std-1.87.0-nightly-2025-03-23-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-168b2af3cdbd9a8b.rlib,libpanic_unwind-50ee00a6fa5c5e39.rlib,libobject-e23f881d85955200.rlib,libmemchr-a49c48c72917b7fd.rlib,libaddr2line-3ca1e42d18edf654.rlib,libgimli-a781adec4bf6a44b.rlib,librustc_demangle-2968ce6079bb1f71.rlib,libstd_detect-5e63c5d4a51bde95.rlib,libhashbrown-054c4e8a42992d63.rlib,librustc_std_workspace_alloc-7b1b7572bf2bef56.rlib,libminiz_oxide-b1741068faf841b8.rlib,libadler2-f0b81b684679327b.rlib,libunwind-b6c8d2f9686f2666.rlib,libcfg_if-c93a46af375896b2.rlib,liblibc-7a21846f18ba2952.rlib,liballoc-96fab14884229a11.rlib,librustc_std_workspace_core-186a023b8864be69.rlib,libcore-74a8d2c13eeedc93.rlib,libcompiler_builtins-b294c1429f78dd04.rlib}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustczjVsR2/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/bevy-016-mold-bug/target/x86_64-unknown-linux-gnu/debug/deps/bevy_016_mold_bug-7b35dc8f5472fbcc" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-fuse-ld=/nix/store/sczaryb644w1m6pqw6m2sb26lp684b19-mold-2.37.1/bin/mold"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: mold: error: undefined symbol: _critical_section_1_0_acquire
          >>> referenced by bevy_tasks.fcd9869545d33bfa-cgu.0
          >>>               /tmp/bevy-016-mold-bug/target/x86_64-unknown-linux-gnu/debug/deps/libbevy_tasks-c6d25798c12c645f.rlib(bevy_tasks-c6d25798c12c645f.bevy_tasks.fcd9869545d33bfa-cgu.0.rcgu.o):(critical_section::with::h4a17da6764697c37)
          mold: error: undefined symbol: _critical_section_1_0_release
          >>> referenced by bevy_tasks.fcd9869545d33bfa-cgu.0
          >>>               /tmp/bevy-016-mold-bug/target/x86_64-unknown-linux-gnu/debug/deps/libbevy_tasks-c6d25798c12c645f.rlib(bevy_tasks-c6d25798c12c645f.bevy_tasks.fcd9869545d33bfa-cgu.0.rcgu.o):(core::ptr::drop_in_place$LT$critical_section..with..Guard$GT$::h1777b2dd99d84d48)
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Additional information

Here's a reproduction repository: https://github.com/musjj/bevy-016-mold-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions