pingcap / tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
https://docs.pingcap.com/tidb/stable/tiflash-overview
Apache License 2.0
946 stars 409 forks source link

TiFlash cannot build when CXX compiler is specified via -DCMAKE_CXX_COMPILER #5847

Open breezewish opened 2 years ago

breezewish commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

A clean Ubuntu 20.04 (which does not have build-essential installed) + llvm 14.

cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-14
ninja tiflash

2. What did you expect to see? (Required)

TiFlash is build successfully.

3. What did you see instead (Required)

error: failed to run custom build command for `snappy-sys v0.1.0 (https://github.com/busyjay/rust-snappy.git?branch=static-link#8c12738b)`

Caused by:
  process didn't exit successfully: `/home/ubuntu/tiflash/contrib/tiflash-proxy/target/release/build/snappy-sys-4bb1c1b3c53e7d57/build-script-build` (exit status: 101)
  --- stdout
  running: "cmake" "/home/ubuntu/.cargo/git/checkouts/rust-snappy-0ed33e4b7b96fc57/8c12738/snappy-sys/snappy" "-DCMAKE_INSTALL_PREFIX=/home/ubuntu/tiflash/contrib/tiflash-proxy/target/x86_64-unknown-linux-gnu/release/build/snappy-sys-3c3ee3f3563c6036/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" "-DCMAKE_CXX_COMPILER=c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- The CXX compiler identification is unknown
  -- Configuring incomplete, errors occurred!
  See also "/home/ubuntu/tiflash/contrib/tiflash-proxy/target/x86_64-unknown-linux-gnu/release/build/snappy-sys-3c3ee3f3563c6036/out/build/CMakeFiles/CMakeOutput.log".
  See also "/home/ubuntu/tiflash/contrib/tiflash-proxy/target/x86_64-unknown-linux-gnu/release/build/snappy-sys-3c3ee3f3563c6036/out/build/CMakeFiles/CMakeError.log".

  --- stderr
  CMake Error at CMakeLists.txt:2 (project):
    The CMAKE_CXX_COMPILER:

      c++

    is not a full path and was not found in the PATH.

    Tell CMake where to find the compiler by setting either the environment
    variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
    to the compiler, or to the compiler name if it is in the PATH.

  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
make[1]: *** [Makefile:178: build] Error 101
make[1]: Leaving directory '/home/ubuntu/tiflash/contrib/tiflash-proxy'
make: *** [Makefile:194: release] Error 2
ninja: build stopped: subcommand failed

4. What is your TiFlash version? (Required)

master

breezewish commented 2 years ago

After some investigation, I discovered that in my case the actual problem is libc++ not installed with my Clang-14. Maybe we should reject the case where libc++ is not found when LLVM is used.