Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 628888 - dev-lang/rust-1.19.0 fails to build when CFLAGS contains any flag not supported by C++ compiler
Summary: dev-lang/rust-1.19.0 fails to build when CFLAGS contains any flag not support...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Gentoo Rust Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-25 08:23 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2024-02-14 10:26 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
rust-1.19.0:20170825-080215.log (rust-1.19.0:20170825-080215.log,16.42 KB, text/plain)
2017-08-25 08:24 UTC, Arfrever Frehtes Taifersar Arahesis
Details
rust-1.19.0-CXXFLAGS.patch (rust-1.19.0-CXXFLAGS.patch,1.99 KB, patch)
2017-08-25 08:28 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2017-08-25 08:23:01 UTC
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)
Comment 1 Arfrever Frehtes Taifersar Arahesis 2017-08-25 08:24:54 UTC
Created attachment 490514 [details]
rust-1.19.0:20170825-080215.log
Comment 2 Arfrever Frehtes Taifersar Arahesis 2017-08-25 08:28:23 UTC
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()).
Comment 3 Dirkjan Ochtman (RETIRED) gentoo-dev 2018-06-06 09:17:22 UTC
Would you mind submitting this patch upstream first?
Comment 4 Georgy Yakovlev archtester gentoo-dev 2020-07-12 20:05:56 UTC
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.