profile
viewpoint

Ask questionsBuilding LLVM with Clang fails

In config.toml, under [target.x86_64-unknown-linux-gnu], one can set cc and cxx to configure the C/C++ compiler used for building LLVM.

When using clang/clang++, regardless of whether use-libcxx is set under [llvm], the LLVM_LIBSTDCXX_MIN compile test fails due to a #include error.

The error happens because passing --target=x86_64-unknown-linux-gnu to clang/clang++ changes the default header search paths. See https://github.com/rust-lang/rust/issues/63417#issuecomment-520510331

My system uses LLVM 8.0.0 Release. (clang version 8.0.0 (tags/RELEASE_800/final) | Target: x86_64-solus-linux)

Original Issue Text:

I am currently trying to build rust on a Solus 4 machine.

The error happens in stage 0 when building LLVM, where it complains about an incompatible version of libstdc++, even if use-libcxx = true is set under [llvm].

Dependencies (g++ clang++ python make cmake curl git):

g++ (Solus) 8.3.1 20190320
clang version 8.0.0 (tags/RELEASE_800/final)
Python 2.7.16
GNU Make 4.2.1
cmake version 3.15.1
curl 7.65.3 (x86_64-solus-linux-gnu) libcurl/7.65.3 OpenSSL/1.0.2r zlib/1.2.11 libssh2/1.7.0_DEV nghttp2/1.36.0
git version 2.22.0

x.py build --stage 0 output:

Updating only changed submodules
Submodules updated in 0.02 seconds
    Finished dev [unoptimized] target(s) in 0.09s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.11s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 test artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.08s
Copying stage0 test from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.10s
Copying stage0 rustc 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" "/home/luna/shared/projects/rust/src/llvm-project/llvm" "-DLLVM_ENABLE_ASSERTIONS=ON" "-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=" "-DLLVM_INCLUDE_EXAMPLES=OFF" "-DLLVM_INCLUDE_TESTS=OFF" "-DLLVM_INCLUDE_DOCS=OFF" "-DLLVM_INCLUDE_BENCHMARKS=OFF" "-DLLVM_ENABLE_ZLIB=OFF" "-DWITH_POLLY=OFF" "-DLLVM_ENABLE_TERMINFO=OFF" "-DLLVM_ENABLE_LIBEDIT=OFF" "-DLLVM_ENABLE_Z3_SOLVER=OFF" "-DLLVM_PARALLEL_COMPILE_JOBS=4" "-DLLVM_TARGET_ARCH=x86_64" "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu" "-DLLVM_OCAML_INSTALL_PATH=usr/lib/ocaml" "-DLLVM_LINK_LLVM_DYLIB=ON" "-DLLVM_ENABLE_LIBXML2=OFF" "-DLLVM_VERSION_SUFFIX=-rust-1.38.0-dev-f2b0c6766" "-DPYTHON_EXECUTABLE=/usr/bin/python2.7" "-DCMAKE_INSTALL_MESSAGE=LAZY" "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" "-DCMAKE_C_FLAGS=-ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-gnu" "-DCMAKE_CXX_FLAGS=-ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-gnu" "-DCMAKE_INSTALL_PREFIX=/home/luna/shared/projects/rust/build/x86_64-unknown-linux-gnu/llvm" "-DCMAKE_BUILD_TYPE=Release"
-- Could NOT find Z3: Found unsuitable version "0.0.0", but required is at least "4.7.1" (found Z3_LIBRARIES-NOTFOUND)
CMake Error at cmake/modules/CheckCompilerVersion.cmake:83 (message):
  libstdc++ version must be at least 4.8.
Call Stack (most recent call first):
  cmake/config-ix.cmake:13 (include)
  CMakeLists.txt:618 (include)


-- Configuring incomplete, errors occurred!
See also "/home/luna/shared/projects/rust/build/x86_64-unknown-linux-gnu/llvm/build/CMakeFiles/CMakeOutput.log".
See also "/home/luna/shared/projects/rust/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', /home/luna/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.38/src/lib.rs:813:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
	finished in 0.027
failed to run: /home/luna/shared/projects/rust/build/bootstrap/debug/bootstrap build --stage 0
Build completed unsuccessfully in 0:00:01

config.toml and build/x86_64-unknown-linux-gnu/llvm/build/CMakeFiles/CMakeOutput.log: https://gist.github.com/LunarLambda/9b6674731bb1d8f123bca143d546d94e

I would like to avoid having to setup an Ubuntu/Debian system or having to compile GCC 4.8 manually just to build Rust. Any help is appreciated

rust-lang/rust

Answer questions LunarLambda

Aw shucks, I think I missed that package. Though, the value of use-libcxx didn't seem to matter, as it was setting cc/cxx to clang/clang++ on the first build (prior to setting use-libcxx) that caused the issue. So, I'm guessing Clang looks for the libc++ headers regardless if it's actually linking to it or not? Which would seem odd to me, but that might be the case. I'll give it another go tomorrow, maybe this was all a big goof on my part, in which case I'm very sorry for the confusion caused.

Also yes, as I said above I did a clean checkout earlier and compiled strictly with gcc/g++/libstdc++ and it worked fine. It's likely I fudged up with the missing header package, will try tomorrow.

My only defense is that the error message was wildly misleading in what the actual issue was. I had seen the include error but given I had a working set of headers that Clang was happy to use in test programs I wrote I marked it off as CMake being weird, not making the connection that the test failed because it didn't compile.

On Mon, Aug 12, 2019, 00:40 Mateusz Mikuła notifications@github.com wrote:

The error was:

fatal error: 'iosfwd' file not found #include <iosfwd> ^~~~~~~~

Just making sure, does it work when use-libcxx = true is commented out or set to false? To use libc++ on Solus you need llvm-devel package among the others.

Clang has few tricks to detect system libstdc++ and that should work just fine but CMake sometimes get confused when compilation options are changed and mixes old config with the new one.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-lang/rust/issues/63417?email_source=notifications&email_token=AJI55IUFMYVD2RX3ZL3V7I3QECIPPA5CNFSM4IKV745KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BKJTQ#issuecomment-520266958, or mute the thread https://github.com/notifications/unsubscribe-auth/AJI55IVLI6PTVQ3LAF52MJTQECIPPANCNFSM4IKV745A .

useful!

Related questions

Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 2
using 'cargo install xsv' on windows 10 triggers rustc internal error hot 1
chain() make collect very slow hot 1
if/while Some(n) = &mut foo sugar will leak a temporary mutable borrow to current scope in particular situation hot 1
build an empty project failed (undefined reference to `__onexitbegin') hot 1
Invalid collision with TryFrom implementation? hot 1
Crater runs for Rust 1.38.0 hot 1
Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 1
under latest MinGW, cannot link with C code using stdout hot 1
Archive all nightlies hot 1
Internal compiler error: can't buffer lints after HIR lowering hot 1
E0373 help suggests `move async` but the correct syntax is `async move` hot 1
Tracking issue for `Option::contains` and `Result::contains` hot 1
async fn + rustfmt don't "just work" inside of RLS hot 1
Include images in rustdoc output hot 1
Github User Rank List