Skip to content

Compiling std atomic with thread sanitizer causes broken LLVM emission. #122476

Closed
@Lee-Janggun

Description

@Lee-Janggun

Update: I forgot to write the command, its

RUSTFLAGS="-Z sanitizer=thread" cargo +nightly test -Z build-std --target aarch64-apple-darwin "$@"

I tried this code:

// A blank lib.rs for a library project also works.

use core::sync::atomic::AtomicUsize;

fn main() {
    println!("Hello, world!",);
}

I expected to see this happen: compiles fine

Instead, this happened: I get an rustc-LLVM ERROR: Broken function found, compilation aborted!.

This does not occur on nightly-2024-03-12.

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (3cbb93223 2024-03-13)
binary: rustc
commit-hash: 3cbb93223f33024db464a4df27a13c7cce870173
commit-date: 2024-03-13
host: aarch64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0
Backtrace

janggun@J-Lee-MacBook-Air RUSTFLAGS="-Z sanitizer=thread" cargo +nightly test -Z build-std --target aarch64-apple-darwin "$@"
   Compiling std v0.0.0 (/Users/janggun/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
   Compiling rustc-std-workspace-std v1.99.0 (/Users/janggun/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-std)
   Compiling proc_macro v0.0.0 (/Users/janggun/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/proc_macro)
   Compiling unicode-width v0.1.11
   Compiling getopts v0.2.21
   Compiling test v0.0.0 (/Users/janggun/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/test)
ZExt only operates on integer
  %13 = zext ptr %1 to i64, !dbg !6602
ZExt only operates on integer
  %16 = zext ptr %1 to i64, !dbg !6603
ZExt only operates on integer
  %19 = zext ptr %1 to i64, !dbg !6604
ZExt only operates on integer
  %22 = zext ptr %1 to i64, !dbg !6605
ZExt only operates on integer
  %25 = zext ptr %1 to i64, !dbg !6606
in function _ZN4core4sync6atomic11atomic_swap17hd7a3400f2ad7716aE
rustc-LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `std` (lib)
warning: build failed, waiting for other jobs to finish...
ZExt only operates on integer
  %13 = zext ptr %1 to i64, !dbg !5113
ZExt only operates on integer
  %16 = zext ptr %1 to i64, !dbg !5114
ZExt only operates on integer
  %19 = zext ptr %1 to i64, !dbg !5115
ZExt only operates on integer
  %22 = zext ptr %1 to i64, !dbg !5116
ZExt only operates on integer
  %25 = zext ptr %1 to i64, !dbg !5117
in function _ZN4core4sync6atomic11atomic_swap17h83c92551d8fdbc7aE
rustc-LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `test` (lib)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-atomicArea: Atomics, barriers, and sync primitivesA-sanitizersArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesrequires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions