Open tigregalis opened 4 months ago
https://github.com/rust-lang/rustc_codegen_cranelift/issues/1480 seems to be the same issue. I wasn't able to reproduce it though.
What's strange to me is that I am compiling cg_clif with LLVM , while @chamons was compiling some third program using a precompiled cg_clif build. The only commonalities are Windows and LLD, and tangentially this project.
But I've not looked into what the build process for cg_clif itself involves; is building cg_clif independent of running cg_clif, or does it involve compiling anything with cg_clif (in which case I am also compiling with cg_clif)?
The build system of cg_clif will build the standard library using cg_clif.
Setup:
When trying to build
rustc_codegen_cranelift
(master branch) itselfI get the error:
(Open for full log) ``` error: linking with `rust-lld.exe` failed: exit code: 1 ... = note: rust-lld: error:: undefined symbol: compiler_builtins::mem::bcmp::h8cb5a07eeb6bf154
rust-lld: error: : undefined symbol: compiler_builtins::mem::memcmp::h6277a2f48d274cf5
rust-lld: error: : undefined symbol: compiler_builtins::mem::memcpy::h5859ecc1fff8d24c
rust-lld: error: : undefined symbol: compiler_builtins::mem::memset::h37585ad851c190e4
rust-lld: error: : undefined symbol: compiler_builtins::mem::strlen::he52a5644d461cab1
rust-lld: error: : undefined symbol: compiler_builtins::mem::memmove::h70315d5eef8ac200
rust-lld: error: undefined symbol: compiler_builtins::mem::bcmp::h8cb5a07eeb6bf154
>>> referenced by C:\Users\anakh\AppData\Local\Temp\rustcBzn86m\symbols.o
>>> referenced by libcompiler_builtins-dc3537b67d26a6c1.rlib(compiler_builtins-dc3537b67d26a6c1.compiler_builtins.626eaefd1ab08603-cgu.000.rcgu.o)
...
```
``` PS C:\Users\anakh\dev\rustc_codegen_cranelift> .\y.ps1 build [BUILD] build system Compiling y v0.1.0 (C:\Users\anakh\dev\rustc_codegen_cranelift\build_system) Finished `dev` profile [optimized + debuginfo] target(s) in 1.23s Running `C:/Users/anakh/dev/.cargo-target\debug\y.exe build` [BUILD] rustc_codegen_cranelift Compiling cfg-if v1.0.0 Compiling version_check v0.9.4 Compiling zerocopy v0.7.32 Compiling once_cell v1.19.0 Compiling cranelift-isle v0.109.0 Compiling equivalent v1.0.1 Compiling cranelift-codegen-shared v0.109.0 Compiling target-lexicon v0.12.14 Compiling slice-group-by v0.3.1 Compiling smallvec v1.13.2 Compiling log v0.4.21 Compiling rustc-hash v1.1.0 Compiling cranelift-codegen-meta v0.109.0 Compiling windows_x86_64_msvc v0.52.5 Compiling cranelift-entity v0.109.0 Compiling arbitrary v1.3.2 Compiling anyhow v1.0.82 Compiling bumpalo v3.16.0 Compiling ahash v0.8.11 Compiling cranelift-bforest v0.109.0 Compiling windows-targets v0.52.5 Compiling winapi v0.3.9 Compiling crc32fast v1.4.0 Compiling libc v0.2.153 Compiling windows-sys v0.52.0 Compiling bitflags v1.3.2 Compiling memchr v2.7.2 Compiling libloading v0.8.3 Compiling hashbrown v0.14.3 Compiling hashbrown v0.13.2 Compiling cranelift-control v0.109.0 Compiling wasmtime-jit-icache-coherence v22.0.0 Compiling indexmap v2.2.6 Compiling regalloc2 v0.9.3 Compiling cranelift-codegen v0.109.0 Compiling region v2.2.0 Compiling gimli v0.28.0 Compiling object v0.36.0 Compiling cranelift-module v0.109.0 Compiling cranelift-native v0.109.0 Compiling cranelift-frontend v0.109.0 Compiling cranelift-object v0.109.0 Compiling cranelift-jit v0.109.0 Compiling rustc_codegen_cranelift v0.1.0 (C:\Users\anakh\dev\rustc_codegen_cranelift) Finished `release` profile [optimized] target(s) in 1m 27s [BUILD] sysroot Clif [COPY] stdlib source [PATCH] "stdlib" <- "0027-stdlib-128bit-atomic-operations.patch" [PATCH] "stdlib" <- "0029-stdlib-rawdylib-processprng.patch" [PATCH] "stdlib" <- "0030-stdlib-Revert-use-raw-dylib-for-Windows-futex-APIs.patch" Compiling compiler_builtins v0.1.106 Compiling core v0.0.0 (C:\Users\anakh\dev\rustc_codegen_cranelift\build\stdlib\library\core) Compiling std v0.0.0 (C:\Users\anakh\dev\rustc_codegen_cranelift\build\stdlib\library\std) Compiling rustc-std-workspace-core v1.99.0 (C:\Users\anakh\dev\rustc_codegen_cranelift\build\stdlib\library\rustc-std-workspace-core) Compiling alloc v0.0.0 (C:\Users\anakh\dev\rustc_codegen_cranelift\build\stdlib\library\alloc) Compiling cfg-if v1.0.0 Compiling rustc-demangle v0.1.24 Compiling unwind v0.0.0 (C:\Users\anakh\dev\rustc_codegen_cranelift\build\stdlib\library\unwind) warning: unexpected `cfg` condition name: `bootstrap` --> library\unwind\src\lib.rs:5:13 | 5 | #![cfg_attr(bootstrap, feature(c_unwind))] | ^^^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)'] } = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(bootstrap)");` to the top of the `build.rs` = note: seeHowever, I had this in my global
.cargo/config.toml
:However, commenting out the rust-lld line so that it defaults to the default linker, I was able to build rustc_codegen_cranelift successfully.
Just wondering if this is an issue with the build for rustc_codegen_cranelift, or rust-lld, or MSVC, or my particular setup, or...
Also of note, the error seems almost identical to the one encountered in this issue (though usage is completely different) https://github.com/rust-lang/rustc_codegen_cranelift/issues/1480