THU-DSP-LAB / llvm-project

LLVM OpenCL C compiler suite for ventus GPGPU
http://llvm.org
Other
35 stars 15 forks source link

[Build error] using llvm-18 toolchain build compiler get lld error #149

Open zhoujingya opened 1 month ago

zhoujingya commented 1 month ago

How to reproduce

First, download llvm-18(maybe higher version too), then use clang-18/clang++-18 as c/cxx compiler

# Build llvm
build_llvm() {
  if [ ! -d "${VENTUS_BUILD_DIR}" ]; then
    mkdir ${VENTUS_BUILD_DIR}
  fi
  cd ${VENTUS_BUILD_DIR}
  cmake -G Ninja -B ${VENTUS_BUILD_DIR} ${DIR}/llvm \
    -DLLVM_CCACHE_BUILD=ON \
    -DCMAKE_C_COMPILER=clang \        <-----------
    -DCMAKE_CXX_COMPILER=clang++ \ <-----------
    -DCMAKE_LINKER=mold \
    -DLLVM_OPTIMIZED_TABLEGEN=ON \
    -DLLVM_PARALLEL_LINK_JOBS=12 \
    -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
    -DLLVM_ENABLE_PROJECTS="clang;lld;libclc" \
    -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86;RISCV" \
    -DLLVM_TARGET_ARCH=riscv32 \
    -DBUILD_SHARED_LIBS=ON \
    -DLLVM_BUILD_LLVM_DYLIB=ON \
    -DCMAKE_INSTALL_PREFIX=${VENTUS_INSTALL_PREFIX}
  ninja
  ninja install
}

Bug info

: && /usr/lib/llvm-18/bin/clang++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics    -Wl,--version-script,"/home/triton/work/llvm-project/build/tools/lto/LTO.exports" -shared -Wl,-soname,libLTO.so.16git -o lib/libLTO.so.16git tools/lto/CMakeFiles/LTO.dir/LTODisassembler.cpp.o tools/lto/CMakeFiles/LTO.dir/lto.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMAMDGPUAsmParser.so.16git  lib/libLLVMX86AsmParser.so.16git  lib/libLLVMRISCVAsmParser.so.16git  lib/libLLVMAMDGPUCodeGen.so.16git  lib/libLLVMX86CodeGen.so.16git  lib/libLLVMRISCVCodeGen.so.16git  lib/libLLVMX86Desc.so.16git  lib/libLLVMAMDGPUDisassembler.so.16git  lib/libLLVMX86Disassembler.so.16git  lib/libLLVMRISCVDisassembler.so.16git  lib/libLLVMX86Info.so.16git  lib/libLLVMLTO.so.16git  lib/libLLVMMCDisassembler.so.16git  lib/libLLVMAMDGPUDesc.so.16git  lib/libLLVMAMDGPUInfo.so.16git  lib/libLLVMRISCVDesc.so.16git  lib/libLLVMRISCVInfo.so.16git  lib/libLLVMCodeGen.so.16git  lib/libLLVMTarget.so.16git  lib/libLLVMMC.so.16git  lib/libLLVMBitReader.so.16git  lib/libLLVMCore.so.16git  lib/libLLVMSupport.so.16git  -Wl,-rpath-link,/home/triton/work/llvm-project/build/lib && :
ld.lld: error: version script assignment of 'LLVM_16' to symbol 'LLVMCreateDisasm' failed: symbol not defined
ld.lld: error: version script assignment of 'LLVM_16' to symbol 'LLVMCreateDisasmCPU' failed: symbol not defined
ld.lld: error: version script assignment of 'LLVM_16' to symbol 'LLVMDisasmDispose' failed: symbol not defined
ld.lld: error: version script assignment of 'LLVM_16' to symbol 'LLVMDisasmInstruction' failed: symbol not defined
ld.lld: error: version script assignment of 'LLVM_16' to symbol 'LLVMSetDisasmOptions' failed: symbol not defined
ld.lld: error: version script assignment of 'LLVM_16' to symbol 'LLVMCreateDisasmCPUFeatures' failed: symbol not defined
zhoujingya commented 1 month ago

https://reviews.llvm.org/D135402, I think this patch is a better way