semarie / build-rust

Script helper for building rustc and cargo from source on OpenBSD (without rustup)
59 stars 15 forks source link

Build error #3

Closed ltratt closed 7 years ago

ltratt commented 7 years ago

If I do ./build.sh beta I get (eventually) this error:

    Finished release [optimized] target(s) in 17.82 secs
updating "/home/ltratt/tmp/build-rust/build_dir/rustc/build/x86_64-unknown-openbsd/stage0-test/x86_64-unknown-openbsd/release/.libtest.stamp" as "/home/ltratt/tmp/build-rust/build_dir/rustc/build/x86_64-unknown-openbsd/stage0-test/x86_64-unknown-openbsd/release/deps/libtest_shim-07a3fe58b9347a2d.rlib" changed
executing step Step { name: "libtest-link", stage: 0, host: "x86_64-unknown-openbsd", target: "x86_64-unknown-openbsd" }
Copying stage0 test from stage0 (x86_64-unknown-openbsd -> x86_64-unknown-openbsd / x86_64-unknown-openbsd)
executing step Step { name: "libtest", stage: 0, host: "x86_64-unknown-openbsd", target: "x86_64-unknown-openbsd" }
executing step Step { name: "llvm", stage: 0, host: "x86_64-unknown-openbsd", target: "x86_64-unknown-openbsd" }
Building LLVM for x86_64-unknown-openbsd
running: "cmake" "/home/ltratt/tmp/build-rust/build_dir/rustc/rust-src-beta/rust-src/lib/rustlib/src/rust/src/llvm" "-G" "Ninja" "-DLLVM_ENABLE_ASSERTIONS=OFF" "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX" "-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=4" "-DLLVM_TARGET_ARCH=x86_64" "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-openbsd" "-DCMAKE_C_COMPILER=cc" "-DCMAKE_CXX_COMPILER=c++" "-DCMAKE_C_FLAGS=-O0 -ffunction-sections -fdata-sections -O2 -pipe -m64 -fPIC" "-DCMAKE_CXX_FLAGS=-O0 -ffunction-sections -fdata-sections -O2 -pipe -m64 -fPIC" "-DCMAKE_INSTALL_PREFIX=/home/ltratt/tmp/build-rust/build_dir/rustc/build/x86_64-unknown-openbsd/llvm" "-DCMAKE_BUILD_TYPE=Release"
Re-run cmake no build system arguments
-- The C compiler identification is GNU 4.9.4
-- The CXX compiler identification is GNU 4.9.4
-- The ASM compiler identification is GNU
-- Found assembler: /home/ltratt/tmp/build-rust/build_dir/bin/cc
-- Check for working C compiler: /home/ltratt/tmp/build-rust/build_dir/bin/cc
-- Check for working C compiler: /home/ltratt/tmp/build-rust/build_dir/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/ltratt/tmp/build-rust/build_dir/bin/c++
-- Check for working CXX compiler: /home/ltratt/tmp/build-rust/build_dir/bin/c++ -- broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestCXXCompiler.cmake:44 (message):
  The C++ compiler "/home/ltratt/tmp/build-rust/build_dir/bin/c++" is not
  able to compile a simple test program.

  It fails with the following output:

   Change Dir: /home/ltratt/tmp/build-rust/build_dir/rustc/build/x86_64-unknown-openbsd/llvm/build/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/local/bin/ninja" "cmTC_c7188"

  [1/2] Building CXX object CMakeFiles/cmTC_c7188.dir/testCXXCompiler.cxx.o

  [2/2] Linking CXX executable cmTC_c7188

  FAILED: cmTC_c7188

  : && /home/ltratt/tmp/build-rust/build_dir/bin/c++ -O0 -ffunction-sections
  -fdata-sections -O2 -pipe -m64 -fPIC
  CMakeFiles/cmTC_c7188.dir/testCXXCompiler.cxx.o -o cmTC_c7188
  -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib && :

  ld: cannot find -lgcc

  ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:48 (project)

-- Configuring incomplete, errors occurred!
See also "/home/ltratt/tmp/build-rust/build_dir/rustc/build/x86_64-unknown-openbsd/llvm/build/CMakeFiles/CMakeOutput.log".
See also "/home/ltratt/tmp/build-rust/build_dir/rustc/build/x86_64-unknown-openbsd/llvm/build/CMakeFiles/CMakeError.log".
thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', rust-src-beta/rust-src/lib/rustlib/src/rust/src/vendor/cmake/src/lib.rs:521
note: Run with `RUST_BACKTRACE=1` for a backtrace.
        finished in 1.077

I'm not quite sure what the gcc problem is to be honest.

semarie commented 7 years ago

it is a bit odd: cmake was able to get the version of gcc and g++ and there are corrects.

-- The C compiler identification is GNU 4.9.4                                                                                                
-- The CXX compiler identification is GNU 4.9.4                                                                                              

But it is unable to use it to produce binary.

-- Check for working CXX compiler: /home/ltratt/tmp/build-rust/build_dir/bin/c++
-- Check for working CXX compiler: /home/ltratt/tmp/build-rust/build_dir/bin/c++ -- broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestCXXCompiler.cmake:44 (message):
  The C++ compiler "/home/ltratt/tmp/build-rust/build_dir/bin/c++" is not
  able to compile a simple test program.
ltratt commented 7 years ago

The problem seems to be that it's not picking up libgcc. I assume it's supposed to be finding /usr/local/lib/gcc/x86_64-unknown-openbsd6.0/4.9.4/libgcc.a? I have no idea if it's important, but I notice the failing command has -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib -- but not /usr/local/lib/gcc/x86_64-unknown-openbsd6.0/4.9.4/, although I would have guessed it might have picked that up automatically?

semarie commented 7 years ago

eg++ should know itself where is located the libgcc.a for his version.

the -rpath-link shouldn't be related. if you are able to test it, you could add rpath = false in config.toml under the section [rust]. It will remove the use of rpath.

ltratt commented 7 years ago

Setting rpath = false doesn't seem to have fixed things.

I'm wondering if there's some missing package? In terms of gcc packages I have:

$ pkg_info |grep -i gcc
gcc-4.9.4p3         GNU compiler collection: core C compiler
gcc-libs-4.9.4p3    GNU compiler collection: support libs
semarie commented 7 years ago

if you ran ./build.sh init (with SUDO env var setted to doas or sudo), you should have installed all required packages.

ltratt commented 7 years ago

Yep, I'd run SUDO=doas ./build.sh init first :/

ltratt commented 7 years ago

This was magically fixed by upgrading to a newer snapshot. I don't know why, but there's no need to keep this issue open any more.