Files
Benjamin WoodruffandGitHub f9ad49fc6f test(turbopack): Add -Wl,--warn-unresolved-symbols to next-swc-napi on Linux (#64049)
I'm not sure why this issue is impacting me and seemingly not others,
but on Debian 12 with the default linker options (gcc with ld) I get the
following compilation error regarding unresolved symbols:

https://gist.github.com/bgw/92da94f46b0994514a144b8938aa2f6c

This flag downgrades that linker error to a warning (which cargo hides).

I've checked that this flag is supported by ld, gold, lld, and mold.
I've also tried building with mold in addition to ld. I'm restricting
the option to linux to avoid potentially breaking other platforms.

Tested by running:

```
cargo test -p next-swc-napi
```

Which now gives:

```
running 2 tests
test transform::test_deserialize_transform_regenerator ... ok
test transform::test_deser ... ok
```
2024-04-08 10:49:24 -07:00

19 lines
689 B
Rust

extern crate napi_build;
fn main() {
// Generates, stores build-time information as static values.
// There are some places relying on correct values for this (i.e telemetry),
// So failing build if this fails.
shadow_rs::new().expect("Should able to generate build time information");
napi_build::setup();
// Resolve a potential linker issue for unit tests on linux
// https://github.com/napi-rs/napi-rs/issues/1782
#[cfg(all(target_os = "linux", not(target_arch = "wasm32")))]
println!("cargo:rustc-link-arg=-Wl,--warn-unresolved-symbols");
#[cfg(not(target_arch = "wasm32"))]
turbopack_binding::turbo::tasks_build::generate_register();
}