llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.48k stars 11.77k forks source link

libclc/amdgcn: `prepare-builtins.cpp.o: undefined reference to symbol '_ZN4llvm2cl6Option11addArgumentEv'` #62018

Closed illwieckz closed 1 year ago

illwieckz commented 1 year ago

I get this while building libclc AMD GCN targets with LLVM 17-git (e58a49300e757ff61142f6abd227bd1437c1cf87), 16.0.1 and 16.0.0 (I haven't tried to build older Git references):

/usr/bin/ld: CMakeFiles/prepare_builtins.dir/utils/prepare-builtins.cpp.o:
  undefined reference to symbol '_ZN4llvm2cl6Option11addArgumentEv'

I completely deleted the build and install directories on each attempt.

nikic commented 1 year ago

Which cmake command are you using?

illwieckz commented 1 year ago

Hi @nikic here is the options I use to build llvm:

        -D'LLVM_BUILD_TOOLS'='ON' \
        -D'LLVM_ENABLE_ASSERTIONS'="${llvm_enable_assertions}" \
        -D'LLVM_ENABLE_PROJECTS'='clang' \
        -D'LLVM_ENABLE_RTTI'='ON' \
        -D'LLVM_BUILD_RUNTIME'='OFF' \
        -D'LLVM_BUILD_RUNTIMES'='OFF' \
        -D'LLVM_BUILD_TESTS'='OFF' \
        -D'LLVM_BUILD_UTILS'='OFF' \
        -D'LLVM_ENABLE_PLUGINS'='OFF' \
        -D'LLVM_INCLUDE_BENCHMARKS'='OFF' \
        -D'LLVM_INCLUDE_DOCS'='OFF' \
        -D'LLVM_INCLUDE_EXAMPLES'='OFF' \
        -D'LLVM_INCLUDE_TESTS'='OFF' \
        -D'LLVM_INCLUDE_UTILS'='OFF' \
        -D'LLVM_SPIRV_INCLUDE_TESTS'='OFF' \
        -D'LLVM_TARGETS_TO_BUILD'="AMDGPU;Native" \
        -D'LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR'="${workspace_dir}/SPIRV-Headers" \
        -D'CLANG_ENABLE_ARCMT'='OFF' \
        -D'CLANG_ENABLE_STATIC_ANALYZER'='OFF' \
        -D'CLANG_TOOL_DICTIONARY_BUILD'='OFF' \
        -D'CLANG_TOOL_HANDLE_CXX_BUILD'='OFF' \
        -D'CLANG_TOOL_HANDLE_LLVM_BUILD'='OFF'

I also set a symlink to SPIRV-LLVM-Translator to llvm-project/llvm/projects/SPIRV-LLVM-Translator before building llvm.

And here are the options I use to build libclc:

        -D'LIBCLC_TARGETS_TO_BUILD'='amdgcn-mesa-mesa3d;r600--;spirv-mesa3d-;spirv64-mesa3d-'

Details can be found there.

illwieckz commented 1 year ago

I forgot to mention this are the defaults I use for all cmake projects in my scripts (they are added to the previously mentioned ones):

        -S'.' \
        -B'build' \
        -G'Ninja' \
        -D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
        -D'CMAKE_BUILD_TYPE'="${cmake_build_type}" \
        -D'BUILD_SHARED_LIBS'='ON' \

This is a Release build.

illwieckz commented 1 year ago

@nikic here is a fix: