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

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

Closed
konimex opened this issue Feb 17, 2020 · 1 comment · Fixed by #84124
Closed
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Comments

@konimex
Copy link

konimex commented Feb 17, 2020

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

@konimex konimex changed the title Building Rust in Clang 9.0 Building Rust in Clang 9.0 errors, complaining -stdlib=c++11 isn't allowed Feb 17, 2020
@konimex konimex changed the title Building Rust in Clang 9.0 errors, complaining -stdlib=c++11 isn't allowed Building Rust in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' Feb 17, 2020
@konimex konimex changed the title Building Rust in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' Building rustc in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' Feb 17, 2020
@jonas-schievink jonas-schievink added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Feb 17, 2020
@konimex
Copy link
Author

konimex commented Feb 17, 2020

I think I may have found the culprit.

if target_env == "musl" {

I'm not well-versed in building rustc (I particularly don't know why rust can build its own LLVM instance, but I assume this is to accommodate systems where LLVM doesn't even exist?), but isn't the choice between $CC and $CXX is pretty much irrelevant per libc?

And by the way, using gcc as $CC, while it does accept the command, it warns (instead of erroring out like clang-9) because -stdlib=c++11 isn't supported in the C compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants