Skip to content

nightly: Linker error / wasm-bindgen pulling in env library in generated JS #141085

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

Closed
TimJentzsch opened this issue May 16, 2025 · 3 comments
Closed
Labels
C-bug Category: This is a bug.

Comments

@TimJentzsch
Copy link

TimJentzsch commented May 16, 2025

See bevyengine/bevy#19225.

On Bevy, we have run into an issue on nightly where we either get a linker error or invalid bindings with wasm-bindgen.

Linker error on native
   Compiling bug_wasm-bindgen_env v0.1.0 (/home/tim/dev/bug_wasm-bindgen_env)
error: linking with `clang` failed: exit status: 1
  |
  = note:  "clang" "-m64" "/tmp/rustchNoW7Y/symbols.o" "<9 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/home/tim/dev/bug_wasm-bindgen_env/target/debug/deps/{libbevy-ef0075a494fc9a41.rlib,libbevy_internal-c2bcb90895ea819c.rlib,libbevy_core_pipeline-bab6b10223073b9b.rlib,libradsort-6329291d828cca19.rlib,libbevy_render-9a077a73871d3ec8.rlib,libnaga_oil-81aa3be42d198123.rlib,libdata_encoding-4734587c2136160c.rlib,libunicode_ident-54469ad67d8d644e.rlib,liboffset_allocator-0e824df91134ebd0.rlib,libbevy_mesh-6fda00499cbe02fd.rlib,libbevy_mikktspace-5aa232ba0ad0d418.rlib,libhexasphere-dccbf6cde1886eb0.rlib,libconstgebra-714585bddf9ce304.rlib,libconst_soft_float-7f2e0915060da76e.rlib,libbevy_diagnostic-e5c3c88f1d96f8ee.rlib,libbevy_time-38fe796ed0940269.rlib,libconst_fnv1a_hash-77eb2fa24874ff2a.rlib,libbevy_window-ed83a6b52bad542f.rlib,libbevy_input-e411114b3b15b3a9.rlib,libbevy_transform-1726a6fe3ced9881.rlib,libbevy_log-66c11619c9d13ab4.rlib,libtracing_subscriber-3170deef8cfa84fa.rlib,libsharded_slab-656e8964720dc0fd.rlib,liblazy_static-0af248c60e3341bb.rlib,libmatchers-1aa9e22010a9f7ef.rlib,libregex_automata-e57c4be15c22dcee.rlib,libregex_syntax-ffe6f02b7f9724aa.rlib,libregex-a4eefe4ee24ebca2.rlib,libregex_automata-7c4763cfbfcbff74.rlib,libaho_corasick-b4415a5282eb66c7.rlib,libmemchr-65c39dbadf63ffa7.rlib,libregex_syntax-270303fda92effcb.rlib,libnu_ansi_term-955034470a1d261d.rlib,liboverload-813976810a62da31.rlib,libtracing_log-e3e4481d2e6d5b92.rlib,libbevy_image-6d74ab3cefb47b1a.rlib,libruzstd-6b1582d7da8d6795.rlib,libtwox_hash-b5c53df6ea70d1da.rlib,libhalf-dc1846b96aad7308.rlib,libimage-cde913bf557c7121.rlib,libbyteorder_lite-7729a87c995421d4.rlib,librectangle_pack-ea1a6d48f5d84f98.rlib,libktx2-b550a1512a83b20e.rlib,libbitflags-688de6b475a0b73d.rlib,libguillotiere-de16af04330aefd6.rlib,libsvg_fmt-1aadd9587fac8a01.rlib,libeuclid-34ec3713a2eba5f9.rlib,libwgpu-5113bbe4bb20ddf5.rlib,libstatic_assertions-8294e59c87507aae.rlib,libwgpu_core-324a98183b6d8113.rlib,libwgpu_hal-42a3d97ae113a4f8.rlib,librenderdoc_sys-f9b7126daa7a3d62.rlib,libkhronos_egl-41bc52b539257aa1.rlib,libprofiling-f51f7ad8ebd14960.rlib,libordered_float-3ae115dde9cfd386.rlib,libgpu_descriptor-a1353172de2b80a1.rlib,libgpu_descriptor_types-b4275cb8d16aa4c9.rlib,libgpu_alloc-b1dc718e41164744.rlib,libgpu_alloc_types-b5bb98b30212b52a.rlib,libash-38259bfb3a66c7d6.rlib,liblibloading-946316b210ef23e9.rlib,libnaga-c97e46432f14f734.rlib,librustc_hash-0f7bf4aa538a7118.rlib,libhexf_parse-c910edf68332a273.rlib,libunicode_xid-1a03320b44bbbc72.rlib,libbit_set-ef0c96be94aae5c1.rlib,libbit_vec-8a8b48c5ffe3bb87.rlib,libstrum-149823e023935f52.rlib,libcodespan_reporting-ac874c2c7e35c707.rlib,libunicode_width-13d7d876a11a147c.rlib,libtermcolor-f796f917ac4f0785.rlib,libspirv-9137f97759907312.rlib,libglow-c975fff40b5c26e1.rlib,libraw_window_handle-2ff942af3b0fe117.rlib,libbevy_asset-8c1708478ce03395.rlib,libblake3-67f47cfeedc6e0dd.rlib,libconstant_time_eq-88724876ad2013f3.rlib,libarrayvec-12e3b0cc34d592f4.rlib,libarrayref-b0edf9d0a1b3f42e.rlib,libasync_broadcast-6d1d3e0157b78f91.rlib,libasync_fs-5fcdcf5286892404.rlib,libblocking-e5007c5eb4cd7b24.rlib,libpiper-8af838fb393a3ca9.rlib,libatomic_waker-34fbabedd9c5c617.rlib,libasync_channel-463532a9589418f2.rlib,libron-ab2139fe4b2af294.rlib,libbase64-8d4296a2c510f17a.rlib,libstackfuture-d99fdcf773f7df88.rlib,libatomicow-890fdacc118e22ae.rlib,libasync_lock-592afffa317dc612.rlib,libevent_listener_strategy-a9f15f412c785eaa.rlib,libevent_listener-2cfefdb77d4b8f52.rlib,libparking_lot-1208259ea968fe0a.rlib,libparking_lot_core-da09f58d79728360.rlib,liblock_api-d48de99c4c05fa58.rlib,libscopeguard-8243eeae16d7eb0a.rlib,libcrossbeam_channel-1889265b6329594b.rlib,libtracing-e6f54618678a0e5f.rlib,libtracing_core-a2b382a8e55f99c0.rlib,libbevy_color-ef2b181f3373ee28.rlib,libencase-6c7024347c1eab32.rlib,libconst_panic-f15ef77cecaf1b17.rlib,libthiserror-34da62fd789710cb.rlib,libwgpu_types-47a6c11751931435.rlib,libbevy_math-a86942e8ea2cd0b2.rlib,librand_distr-c384ce303cf43c9f.rlib,libnum_traits-f063ebf7679bdb38.rlib,libitertools-38ce46052fb01b62.rlib,libeither-12a5559181fe8091.rlib,libbevy_app-145e9bdd29a8a373.rlib,libctrlc-cbf6fce545802a17.rlib,libnix-b2e3736a2f91d1b9.rlib,libbevy_ecs-fbd297d7b6497cb5.rlib,libbitflags-0337ea3f28e745e0.rlib,libnonmax-7b4bfdb8bea0b3f6.rlib,libbevy_tasks-3bed577ff3c50da6.rlib,libasync_executor-7f3061b112beac16.rlib,libslab-c60455d8a08412c4.rlib,libconcurrent_queue-782e5f3de4c9e6c2.rlib,libcrossbeam_utils-9825ba4b5b6a119f.rlib,libasync_task-b88a0a410f3f7c16.rlib,libfutures_lite-06ca46672ca43d3c.rlib,libfutures_io-79115c52a099b19e.rlib,libfutures_core-de705675c4dbc62b.rlib,libparking-71d690fe5a098fdf.rlib,libfastrand-aaecaa6ded02aab3.rlib,libpin_project_lite-cb87049b5092e64c.rlib,libfixedbitset-981d4f7d025c5793.rlib,liblog-2a054680744da8c1.rlib,libindexmap-127951a1f1048a30.rlib,libbumpalo-ccc5e3f4cba5df6e.rlib,libdisqualified-3e561cd156bc4705.rlib,libbevy_reflect-d03a55c4d0c690a5.rlib,libuuid-00f3208ddf8d7f16.rlib,libgetrandom-1927210e6d7b8c46.rlib,libsmol_str-3cbd9290031892b9.rlib,liberased_serde-3548ea0717f46b74.rlib,libtypeid-ac254e85443b4c89.rlib,libsmallvec-c7cb44a6c3a971b4.rlib,libglam-20e8d97fe30a52a3.rlib,librand-8b9d7de4c682ec56.rlib,librand_chacha-6b6937633d454ef1.rlib,libppv_lite86-d9d2adb87120fd95.rlib,libzerocopy-480c4365116581a3.rlib,librand_core-6e84585a073ebb84.rlib,libgetrandom-150aa34999b9c3b1.rlib,liblibc-624fd5fe8e7a43e4.rlib,libbytemuck-32851a5491fa8a2b.rlib,libdowncast_rs-d722b2e729ac1674.rlib,libderive_more-0eae41a88591c87b.rlib,libthiserror-e8f9c50036fa4645.rlib,libbevy_utils-79559f322e53a86d.rlib,libthread_local-b4f0f37b04c44ac7.rlib,libonce_cell-4b2232a86ac1d897.rlib,libbevy_ptr-9982770dab4ed33d.rlib,libbevy_platform-7acd264ebcad05bf.rlib,libcfg_if-b504d80cfa2d2179.rlib,libhashbrown-53e6b4c8ecf6480d.rlib,libequivalent-07de994024779776.rlib,libserde-c3ce3506ee874b55.rlib,libfoldhash-8913adb87b30492a.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" "-ldl" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustchNoW7Y/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/tim/dev/bug_wasm-bindgen_env/target/debug/build/blake3-bfe811c77feedc28/out" "-L" "/home/tim/dev/bug_wasm-bindgen_env/target/debug/build/blake3-bfe811c77feedc28/out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/tim/dev/bug_wasm-bindgen_env/target/debug/deps/bug_wasm_bindgen_env-3f186b0f5b6b56a4" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-fuse-ld=/usr/bin/mold"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: mold: error: undefined symbol: /home/tim/dev/bug_wasm-bindgen_env/target/debug/deps/libbevy_core_pipeline-bab6b10223073b9b.rlib(bevy_core_pipeline-bab6b10223073b9b.bevy_core_pipeline.6683a2557f8da2a7-cgu.12.rcgu.o): _$LT$bevy_render..view..ViewDepthTexture$u20$as$u20$bevy_ecs..component..Component$GT$::clone_behavior::hf37de333d534ddb3
          mold: error: undefined symbol: /home/tim/dev/bug_wasm-bindgen_env/target/debug/deps/libbevy_core_pipeline-bab6b10223073b9b.rlib(bevy_core_pipeline-bab6b10223073b9b.bevy_core_pipeline.6683a2557f8da2a7-cgu.12.rcgu.o): _$LT$bevy_render..experimental..occlusion_culling..OcclusionCullingSubview$u20$as$u20$bevy_ecs..component..Component$GT$::clone_behavior::h57f403d5f2a476c2
          mold: error: undefined symbol: /home/tim/dev/bug_wasm-bindgen_env/target/debug/deps/libbevy_core_pipeline-bab6b10223073b9b.rlib(bevy_core_pipeline-bab6b10223073b9b.bevy_core_pipeline.6683a2557f8da2a7-cgu.12.rcgu.o): _$LT$bevy_render..view..ViewDepthTexture$u20$as$u20$bevy_ecs..component..Component$GT$::register_required_components::h25a6cf8a4a8744b4
          mold: error: undefined symbol: /home/tim/dev/bug_wasm-bindgen_env/target/debug/deps/libbevy_core_pipeline-bab6b10223073b9b.rlib(bevy_core_pipeline-bab6b10223073b9b.bevy_core_pipeline.6683a2557f8da2a7-cgu.12.rcgu.o): _$LT$bevy_render..experimental..occlusion_culling..OcclusionCullingSubview$u20$as$u20$bevy_ecs..component..Component$GT$::register_required_components::h2080aeda89222a9d
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `bug_wasm-bindgen_env` (bin "bug_wasm-bindgen_env") due to 1 previous error

Invalid bindings created by wasm-bindgen:

import * as __wbg_star0 from 'env';

So it's trying to import from an env package that doesn't exist.

I cannot reproduce the issue on beta or stable toolchains, not sure if this indicates a bug in the compiler.
We discovered that nightly 2025-05-14 still works, hopefully that helps to track down the issue.

To reproduce, see this repository: https://github.com/TimJentzsch/bug_wasm-bindgen_env
It includes scripts to reproduce the error.
I tried to minimize it as much as I could.

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (d97326eab 2025-05-15)
binary: rustc
commit-hash: d97326eabfc3b2c33abcb08d6bc117aefa697cb7
commit-date: 2025-05-15
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4

This bug report was brought to you by RustWeek 2025.
If you're at the venue, come talk to me in the Bevy unconf room!

@TimJentzsch TimJentzsch added the C-bug Category: This is a bug. label May 16, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 16, 2025
@workingjubilee
Copy link
Member

I wonder if this is wasm-bindgen reacting to some change in std or something...

@TimJentzsch TimJentzsch changed the title On nightly, wasm-bindgen is pulling in env library in generated JS nightly: Linker error / wasm-bindgen pulling in env library in generated JS May 17, 2025
@TimJentzsch
Copy link
Author

We discovered that wasm-bindgen is not required to reproduce the issue, on native we get a linker error.
I updated the reproduction repo with our findings.

Additionally, we found that the error is not present with nightly 2025-05-14.

@workingjubilee
Copy link
Member

It does not repro on the latest nightly.

Original regression

searched nightlies: from nightly-2025-05-14 to nightly-2025-05-17
regressed nightly: nightly-2025-05-16
searched commit range: 414482f...d97326e
regressed commit: c4e05e5

Unregression

searched nightlies: from nightly-2025-05-16 to nightly-2025-05-29
regressed nightly: nightly-2025-05-18
searched commit range: 16d2276...777d372
regressed commit: bf5a38d

Resolved.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants