Skip to content

Can't compile for aarch64-pc-windows-msvc with the msvc toolchain during rustc bootstrap #430

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
wesleywiser opened this issue Jul 27, 2021 · 3 comments · Fixed by #431
Closed

Comments

@wesleywiser
Copy link
Member

The issue seems to be that we're trying to pass lse.s to cl but cl doesn't support this. It looks like this regressed in 4af6bc7 (#416).

Perhaps this just needs to be adjusted to exclude msvc?

compiler-builtins/build.rs

Lines 495 to 501 in 31cf80b

if target_arch == "aarch64" {
// See below for why we're building these as separate libraries.
build_aarch64_out_of_line_atomics_libraries(&src_dir, cfg);
// Some run-time CPU feature detection is necessary, as well.
sources.extend(&[("__aarch64_have_lse_atomics", "cpu_model.c")]);
}

Repro:

D:\code> git clone https://github.com/rust-lang/compiler-builtins
D:\code> cd compiler-builtins
D:\code\compiler-builtins> set RUST_COMPILER_RT_ROOT=D:\code\rust\src\llvm-project\compiler-rt
D:\code\compiler-builtins> cargo +nightly build --target aarch64-pc-windows-msvc --features c
   Compiling compiler_builtins v0.1.47 (D:\code\compiler-builtins)
The following warnings were emitted during compilation:

warning: cl : Command line warning D9024 : unrecognized source file type 'D:\code\rust\src\llvm-project\compiler-rt\lib/builtins\aarch64/lse.S', object file assumed
warning: cl : Command line warning D9027 : source file 'D:\code\rust\src\llvm-project\compiler-rt\lib/builtins\aarch64/lse.S' ignored

error: failed to run custom build command for `compiler_builtins v0.1.47 (D:\code\compiler-builtins)`
Caused by:
  process didn't exit successfully: `D:\code\compiler-builtins\target\debug\build\compiler_builtins-974b0678a8f36634\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:compiler-rt=D:\code\compiler-builtins\compiler-rt
  cargo:rustc-cfg=feature="unstable"
  cargo:rerun-if-changed=D:\code\rust\src\llvm-project\compiler-rt\lib/builtins\aarch64/lse.S
  TARGET = Some("aarch64-pc-windows-msvc")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-pc-windows-msvc")
  CC_aarch64-pc-windows-msvc = None
  CC_aarch64_pc_windows_msvc = None
  TARGET_CC = None
  CC = None
  CFLAGS_aarch64-pc-windows-msvc = None
  CFLAGS_aarch64_pc_windows_msvc = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fp,neon")
  DEBUG = Some("true")
  CC_aarch64-pc-windows-msvc = None
  CC_aarch64_pc_windows_msvc = None
  TARGET_CC = None
  CC = None
  CFLAGS_aarch64-pc-windows-msvc = None
  CFLAGS_aarch64_pc_windows_msvc = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fp,neon")
  running: "cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "D:\\code\\rust\\src\\llvm-project\\compiler-rt\\lib/builtins" "/Zl" "-D__func__=__FUNCTION__" "-DL_cas" "-DSIZE=1" "-DMODEL=1" "-FoD:\\code\\compiler-builtins\\target\\aarch64-pc-windows-msvc\\debug\\build\\compiler_builtins-8a216375ad68b403\\out\\lse.o" "-c" "D:\\code\\rust\\src\\llvm-project\\compiler-rt\\lib/builtins\\aarch64/lse.S"
  cargo:warning=cl : Command line warning D9024 : unrecognized source file type 'D:\code\rust\src\llvm-project\compiler-rt\lib/builtins\aarch64/lse.S', object file assumed
  cargo:warning=cl : Command line warning D9027 : source file 'D:\code\rust\src\llvm-project\compiler-rt\lib/builtins\aarch64/lse.S' ignored
  cl : Command line warning D9021 : no action performed
  exit code: 0
  AR_aarch64-pc-windows-msvc = None
  AR_aarch64_pc_windows_msvc = None
  TARGET_AR = None
  AR = None
  running: "lib.exe" "-out:D:\\code\\compiler-builtins\\target\\aarch64-pc-windows-msvc\\debug\\build\\compiler_builtins-8a216375ad68b403\\out\\liboutline_atomic_helper_cas1_relax.a" "-nologo" "D:\\code\\compiler-builtins\\target\\aarch64-pc-windows-msvc\\debug\\build\\compiler_builtins-8a216375ad68b403\\out\\lse.o"
  LINK : fatal error LNK1181: cannot open input file 'D:\code\compiler-builtins\target\aarch64-pc-windows-msvc\debug\build\compiler_builtins-8a216375ad68b403\out\lse.o'
  exit code: 1181

  --- stderr


  error occurred: Command "lib.exe" "-out:D:\\code\\compiler-builtins\\target\\aarch64-pc-windows-msvc\\debug\\build\\compiler_builtins-8a216375ad68b403\\out\\liboutline_atomic_helper_cas1_relax.a" "-nologo" "D:\\code\\compiler-builtins\\target\\aarch64-pc-windows-msvc\\debug\\build\\compiler_builtins-8a216375ad68b403\\out\\lse.o" with args "lib.exe" did not execute successfully (status code exit code: 1181).
@Amanieu
Copy link
Member

Amanieu commented Jul 28, 2021

These functions are needed, even on msvc targets, when the outlined atomics are used. Clang and GCC enable this by default, although rustc currently doesn't.

Is there a way to assemble lse.s in a way that works on msvc targets?

@wesleywiser
Copy link
Member Author

I'm not aware of a way. There is an assembler included as part of the msvc toolchain however, I don't think it's compatible with the syntax used in lse.s.

Is it possible to disable outlined atomics for aarch64-pc-windows-msvc?

@Amanieu
Copy link
Member

Amanieu commented Jul 28, 2021

Looking through the GCC & Clang code:

  • Clang only enables outlined atomics on Linux targets.
  • GCC doesn't support aarch64 on windows.

So I think it's fine to just disable it for msvc (or windows) targets.

tgross35 added a commit to tgross35/compiler-builtins that referenced this issue Feb 24, 2025
wasm32 and aarch64 intrinsics for rint and rintf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants