Skip to content
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

Failed LLVM8 compilation on Darwin: cmpxchg instructions cannot be unordered #69436

Closed
nmattia opened this issue Feb 24, 2020 · 3 comments
Closed
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-macos Operating system: macOS O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nmattia
Copy link

nmattia commented Feb 24, 2020

I tried building rust 1.41 on Darwin with LLVM 8 and it fails with the following:

Installing libLLVM.so to stage 0 (x86_64-apple-darwin)
Copying stage0 rustc from stage0 (x86_64-apple-darwin -> x86_64-apple-darwin / x86_64-apple-darwin)
Assembling stage1 compiler (x86_64-apple-darwin)
Building stage1 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
   Compiling cc v1.0.47
   Compiling core v0.0.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/libcore)
   Compiling libc v0.2.64
   Compiling build_helper v0.1.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/build_helper)
   Compiling autocfg v0.1.6
   Compiling std v0.0.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/libstd)
   Compiling cmake v0.1.38
   Compiling compiler_builtins v0.1.22
   Compiling backtrace-sys v0.1.32
   Compiling unwind v0.0.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/libunwind)
   Compiling rustc-std-workspace-core v1.99.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/tools/rustc-std-workspace-core)
   Compiling hashbrown v0.6.2
   Compiling rustc_tsan v0.0.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/librustc_tsan)
   Compiling rustc_asan v0.0.0 (/private/tmp/nix-build-rustc-1.41.0.drv-0/rustc-1.41.0-src/src/librustc_asan)
cmpxchg instructions cannot be unordered.
  %10 = cmpxchg i128* %9, i128 0, i128 0 unordered monotonic
in function __llvm_memcpy_element_unordered_atomic_16
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `compiler_builtins`.

Everything works with LLVM9, and everything works on Linux.

@nmattia nmattia added the C-bug Category: This is a bug. label Feb 24, 2020
@Centril Centril added O-macos Operating system: macOS A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-x86_64 Target: x86-64 processors (like x86_64-*) A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 24, 2020
@cuviper
Copy link
Member

cuviper commented Feb 25, 2020

x86_64-apple-darwin supports up to 128-bit atomics thanks to its core2 base, but x86_64-unknown-linux-gnu allows older CPUs and only supports up to 64-bit atomics.

base.max_atomic_width = Some(128); // core2 support cmpxchg16b

base.max_atomic_width = Some(64);

It may be that this was broken before LLVM 9 though...

@akien-mga
Copy link

As I landed here with a google search, I'll document @cuviper's fix for future readers:
https://src.fedoraproject.org/rpms/llvm/pull-request/35

@sanxiyn
Copy link
Member

sanxiyn commented Jan 19, 2022

Closing, Rust now requires LLVM >=12.

@sanxiyn sanxiyn closed this as completed Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-macos Operating system: macOS O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants