Skip to content

Building rustc in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' #69222

Closed
@konimex

Description

@konimex

Hello, I'm trying to build a pure-LLVM Rust (no linking to libgcc_s.so at all). Building rust with clang set as cc in target.x86_64-unknown-linux-musl returns failure since Clang (the C compiler) doesn't allow std=c++11.

Here's my config.toml:

[llvm]
link-shared = true

[build]
build = "x86_64-unknown-linux-musl"
host = [ "x86_64-unknown-linux-musl" ]
target = [ "x86_64-unknown-linux-musl" ]
docs = false
extended = true
submodules = false
python = "python3"
locked-deps = true
vendor = true

[install]
prefix = "/usr"

[rust]
channel = "stable"
rpath = false
codegen-units = 1
debuginfo-level = 0
backtrace = false
jemalloc = false
codegen-tests = false
llvm-libunwind = true

[target.x86_64-unknown-linux-musl]
cc = "clang"
cxx = "clang++"
linker = "clang"
llvm-config = "/usr/bin/llvm-config"
crt-static = false

Here are the relevant bits of the log:

Building stage0 std artifacts (x86_64-unknown-linux-musl -> x86_64-unknown-linux-musl)
   Compiling cc v1.0.47
   Compiling core v0.0.0 (/home/koni/.cache/kiss/build-20469/rust/src/libcore)
   Compiling libc v0.2.64
   Compiling autocfg v0.1.6
   Compiling std v0.0.0 (/home/koni/.cache/kiss/build-20469/rust/src/libstd)
   Compiling hashbrown v0.6.2
   Compiling compiler_builtins v0.1.22
   Compiling unwind v0.0.0 (/home/koni/.cache/kiss/build-20469/rust/src/libunwind)
   Compiling backtrace-sys v0.1.32
   Compiling rustc-std-workspace-core v1.99.0 (/home/koni/.cache/kiss/build-20469/rust/src/tools/rustc-std-workspace-core)
error: failed to run custom build command for `unwind v0.0.0 (/home/koni/.cache/kiss/build-20469/rust/src/libunwind)`

Caused by:
  process didn't exit successfully: `/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0-std/release/build/unwind-078e32742eabfcea/build-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rustc-link-search=native=/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/build/unwind-ab6a3e65ec86ddbe/out
running: "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-D__LITTLE_ENDIAN__=1" "-o" "/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/build/unwind-ab6a3e65ec86ddbe/out/../llvm-project/libunwind/src/Unwind-EHABI.o" "-c" "../llvm-project/libunwind/src/Unwind-EHABI.cpp"
exit code: 0
running: "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-D__LITTLE_ENDIAN__=1" "-o" "/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/build/unwind-ab6a3e65ec86ddbe/out/../llvm-project/libunwind/src/Unwind-seh.o" "-c" "../llvm-project/libunwind/src/Unwind-seh.cpp"
exit code: 0
running: "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-D__LITTLE_ENDIAN__=1" "-o" "/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/build/unwind-ab6a3e65ec86ddbe/out/../llvm-project/libunwind/src/Unwind-sjlj.o" "-c" "../llvm-project/libunwind/src/Unwind-sjlj.c"
cargo:warning=error: invalid argument '-std=c++11' not allowed with 'C'
exit code: 1

--- stderr


error occurred: Command "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-D__LITTLE_ENDIAN__=1" "-o" "/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0-std/x86_64-unknown-linux-musl/release/build/unwind-ab6a3e65ec86ddbe/out/../llvm-project/libunwind/src/Unwind-sjlj.o" "-c" "../llvm-project/libunwind/src/Unwind-sjlj.c" with args "clang" did not execute successfully (status code exit code: 1).



warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "/home/koni/.cache/kiss/build-20469/rust/build/x86_64-unknown-linux-musl/stage0/bin/cargo" "build" "-Zconfig-profile" "--target" "x86_64-unknown-linux-musl" "-Zbinary-dep-depinfo" "-j" "4" "--release" "--locked" "--frozen" "--features" "panic-unwind llvm-libunwind compiler-builtins-c" "--manifest-path" "/home/koni/.cache/kiss/build-20469/rust/src/libtest/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
failed to run: /home/koni/.cache/kiss/build-20469/rust/build/bootstrap/debug/bootstrap build -j 4
Build completed unsuccessfully in 0:01:09

Thanks.

A complete log is available here:
http://termbin.com/ex3p

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-infraRelevant to the infrastructure team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions