Skip to content

Commit

Permalink
CMakeLists: prefer to use llvm_map_components_to_libnames
Browse files Browse the repository at this point in the history
This fixes the build of lgc and lgcdis when LLVM is compiled as a
shared library.

The underlying issue is that the lgc and lgcdis *libraries* are not
linked into the libLLVM-*.so, but the LLVM_LINK_COMPONENTS mechanism
assumes that they are.
  • Loading branch information
nhaehnle committed Jul 11, 2022
1 parent 7f59d3a commit c38b3be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions lgc/tool/lgc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
#######################################################################################################################

### LGC Standalone Compiler ############################################################################################
set(LLVM_LINK_COMPONENTS
add_llvm_tool(lgc
lgc.cpp
)

llvm_map_components_to_libnames(llvm_libs
lgc
Core
AMDGPUAsmParser
Expand All @@ -33,12 +37,7 @@ set(LLVM_LINK_COMPONENTS
AsmParser
Support
)

add_llvm_tool(lgc
lgc.cpp
)

add_dependencies(lgc LLVMlgc)
target_link_libraries(lgc PUBLIC ${llvm_libs})

target_compile_definitions(lgc PRIVATE ${TARGET_ARCHITECTURE_ENDIANESS}ENDIAN_CPU)

Expand Down
13 changes: 6 additions & 7 deletions lgc/tool/lgcdis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
#######################################################################################################################

### LGC disassembler tool ############################################################################################
set(LLVM_LINK_COMPONENTS
lgcdis
AMDGPUDisassembler
Support
)

add_llvm_tool(lgcdis
lgcdis.cpp
)

add_dependencies(lgcdis LLVMlgcdis)
llvm_map_components_to_libnames(llvm_libs
lgcdis
AMDGPUDisassembler
Support
)
target_link_libraries(lgcdis PUBLIC ${llvm_libs})

target_include_directories(lgcdis
PRIVATE
Expand Down

0 comments on commit c38b3be

Please sign in to comment.