dev-lang/rust-1.19.0 fails to build when CFLAGS contains any flag not supported by C++ compiler. This happens because some bootstrapping code passes CFLAGS instead of CXXFLAGS to build system of bundled LLVM. Example values: CFLAGS="-march=native -O2 -pipe -Wpointer-sign" CXXFLAGS="-march=native -O2 -pipe" -Wpointer-sign is supported by GCC in C mode, but in C++ mode it triggers the following warning: cc1plus: warning: command line option ‘-Wpointer-sign’ is valid for C/ObjC but not for C++ This warning is interpreted by build system as failure of detection of some feature. Output shows that incorrect value of -DCMAKE_CXX_FLAGS= is passed to cmake: Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu) Building LLVM for x86_64-unknown-linux-gnu running: "cmake" "/var/tmp/portage/dev-lang/rust-1.19.0/work/rustc-1.19.0-src/src/llvm" "-DLLVM_ENABLE_ASSERTIONS=OFF" "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX;Hexagon" "-DLLVM_INCLUDE_EXAMPLES=OFF" "-DLLVM_INCLUDE_TESTS=OFF" "-DLLVM_INCLUDE_DOCS=OFF" "-DLLVM_ENABLE_ZLIB=OFF" "-DWITH_POLLY=OFF" "-DLLVM_ENABLE_TERMINFO=OFF" "-DLLVM_ENABLE_LIBEDIT=OFF" "-DLLVM_PARALLEL_COMPILE_JOBS=2" "-DLLVM_TARGET_ARCH=x86_64" "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu" "-DCMAKE_C_COMPILER=cc" "-DCMAKE_CXX_COMPILER=c++" "-DCMAKE_C_FLAGS=-ffunction-sections -fdata-sections -fPIC -march=native -pipe -Wpointer-sign -m64" "-DCMAKE_CXX_FLAGS=-ffunction-sections -fdata-sections -fPIC -march=native -pipe -Wpointer-sign -m64" "-DCMAKE_INSTALL_PREFIX=/var/tmp/portage/dev-lang/rust-1.19.0/work/rustc-1.19.0-src/build/x86_64-unknown-linux-gnu/llvm" "-DCMAKE_BUILD_TYPE=Release" -- The C compiler identification is GNU 6.4.0 -- The CXX compiler identification is GNU 6.4.0 -- The ASM compiler identification is GNU ... -- Performing Test CXX_SUPPORTS_CXX11 -- Performing Test CXX_SUPPORTS_CXX11 - Failed CMake Error at cmake/modules/HandleLLVMOptions.cmake:480 (message): LLVM requires C++11 support but the '-std=c++11' flag isn't supported. Call Stack (most recent call first): CMakeLists.txt:597 (include) -- Configuring incomplete, errors occurred! See also "/var/tmp/portage/dev-lang/rust-1.19.0/work/rustc-1.19.0-src/build/x86_64-unknown-linux-gnu/llvm/build/CMakeFiles/CMakeOutput.log". See also "/var/tmp/portage/dev-lang/rust-1.19.0/work/rustc-1.19.0-src/build/x86_64-unknown-linux-gnu/llvm/build/CMakeFiles/CMakeError.log". thread 'main' panicked at ' command did not execute successfully, got: exit code: 1 build script failed, must exit now', src/vendor/cmake/src/lib.rs:631 note: Run with `RUST_BACKTRACE=1` for a backtrace. finished in 35.622 failed to run: /var/tmp/portage/dev-lang/rust-1.19.0/work/rustc-1.19.0-src/build/bootstrap/debug/bootstrap build Build completed unsuccessfully in 0:06:06 * ERROR: dev-lang/rust-1.19.0::gentoo failed (compile phase): * (no error message)
Created attachment 490514 [details] rust-1.19.0:20170825-080215.log
Created attachment 490516 [details, diff] rust-1.19.0-CXXFLAGS.patch This patch creates cxxflags() function, which was copied from cflags() function and adjusted to use CXXFLAGS (available as self.cxx[target].args()) instead of CFLAGS (available as self.cc[target].0.args()).
Would you mind submitting this patch upstream first?
I think it should have been fixed for a while. src/boostrap/native.rs got an extra *CFLAG handlers, but we don't use them as environment flags seem to be working fine. config.toml may be used to pass EXTRA flags to bundled llvm. > [llvm] > #cflags = "-fextra-flag" > #cxxflags = "-fextra-flag" > #ldflags = "-Wl,extra-flag" but env flags should be respected as well. But I'll try adding something non-standard env flags and check again.