Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nice helper loose type and print type lld cmake flags #1492

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ endif()
export(TARGETS LLDEnzyme-${LLVM_VERSION_MAJOR}
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")

if (${LLVM_VERSION_MAJOR} GREATER 10)
export(TARGETS LLDEnzymeFlags
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")
endif()
export(TARGETS LLDEnzymeLooseTypeFlags
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")
export(TARGETS LLDEnzymePrintTypeFlags
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")

export(PACKAGE Enzyme)

Expand Down
11 changes: 6 additions & 5 deletions enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ set_target_properties(LLDEnzyme-${LLVM_VERSION_MAJOR} PROPERTIES
LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()


if (${LLVM_VERSION_MAJOR} GREATER 10)
add_library(LLDEnzymeFlags INTERFACE)
target_compile_options(LLDEnzymeFlags INTERFACE -flto)
target_link_options(LLDEnzymeFlags INTERFACE "SHELL: -fuse-ld=lld")
Expand All @@ -172,12 +170,17 @@ if (${LLVM_VERSION_MAJOR} GREATER 14)
target_link_options(LLDEnzymeFlags INTERFACE "SHELL: -Wl,--load-pass-plugin=$<TARGET_FILE:LLDEnzyme-${LLVM_VERSION_MAJOR}>")
endif()

add_library(LLDEnzymeLooseTypeFlags INTERFACE)
target_link_options(LLDEnzymeLooseTypeFlags INTERFACE "SHELL: -Wl,-mllvm -Wl,-enzyme-loose-types=1")

add_library(LLDEnzymePrintTypeFlags INTERFACE)
target_link_options(LLDEnzymePrintTypeFlags INTERFACE "SHELL: -Wl,-mllvm -Wl,-enzyme-print-type=1")

# this custom target exists to prevent CMake from incorrectly assuming that
# targets that link depend on LLDEnzyme-XX can be built at the same time or
# before LLDEnzyme-XX has finished.
add_custom_target(LLDEnzymeDummy "" DEPENDS LLDEnzyme-${LLVM_VERSION_MAJOR})
add_dependencies(LLDEnzymeFlags LLDEnzymeDummy)
endif()

add_library(ClangEnzymeFlags INTERFACE)
target_compile_options(ClangEnzymeFlags INTERFACE "-fplugin=$<TARGET_FILE:ClangEnzyme-${LLVM_VERSION_MAJOR}>")
Expand All @@ -188,9 +191,7 @@ target_compile_options(ClangEnzymeFlags INTERFACE "-fplugin=$<TARGET_FILE:ClangE
add_custom_target(ClangEnzymeDummy "" DEPENDS ClangEnzyme-${LLVM_VERSION_MAJOR})
add_dependencies(ClangEnzymeFlags ClangEnzymeDummy)

if (${LLVM_VERSION_MAJOR} GREATER 10)
install(TARGETS LLDEnzymeFlags EXPORT EnzymeTargets)
endif()
install(TARGETS ClangEnzymeFlags EXPORT EnzymeTargets)

install(TARGETS LLVMEnzyme-${LLVM_VERSION_MAJOR}
Expand Down
10 changes: 8 additions & 2 deletions enzyme/cmake/EnzymeConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ set(Enzyme_CLANG_EXE "@CONF_CLANG_EXE@")
set(Enzyme_TABLEGEN_EXE "@Enzyme_CONFIG_TABLEGEN_EXE@")

# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET ClangEnzymeFlags AND NOT TARGET LLDEnzymeFlags AND NOT TARGET LLVMEnzyme-${Enzyme_LLVM_VERSION_MAJOR} AND NOT TARGET ClangEnzyme-${Enzyme_LLVM_VERSION_MAJOR} AND NOT TARGET LLDEnzyme-${Enzyme_LLVM_VERSION_MAJOR} AND NOT Enzyme_BINARY_DIR)
if(NOT TARGET ClangEnzymeFlags AND NOT TARGET LLDEnzymeFlags
AND NOT TARGET LLDEnzymeLooseTypeFlags
AND NOT TARGET LLDEnzymePrintTypeFlags
AND NOT TARGET LLVMEnzyme-${Enzyme_LLVM_VERSION_MAJOR} AND NOT TARGET ClangEnzyme-${Enzyme_LLVM_VERSION_MAJOR} AND NOT TARGET LLDEnzyme-${Enzyme_LLVM_VERSION_MAJOR} AND NOT Enzyme_BINARY_DIR)
include("${Enzyme_CMAKE_DIR}/EnzymeTargets.cmake")
# These are IMPORTED targets created by EnzymeTargets.cmake
set(Enzyme_LIBRARIES ClangEnzymeFlags LLDEnzymeFlags LLVMEnzyme-${Enzyme_LLVM_VERSION_MAJOR} ClangEnzyme-${Enzyme_LLVM_VERSION_MAJOR} LLDEnzyme-${LLD_LLVM_VERSION_MAJOR})
set(Enzyme_LIBRARIES ClangEnzymeFlags LLDEnzymeFlags
LLDEnzymeLooseTypeFlags
LLDEnzymePrintTypeFlags
LLVMEnzyme-${Enzyme_LLVM_VERSION_MAJOR} ClangEnzyme-${Enzyme_LLVM_VERSION_MAJOR} LLDEnzyme-${LLD_LLVM_VERSION_MAJOR})
endif()
8 changes: 3 additions & 5 deletions enzyme/test/test_find_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ message("imported targets ${importTargetsAfter}")
add_executable(enzyme_test_1 main.c)
target_link_libraries(enzyme_test_1 PUBLIC ClangEnzymeFlags)

if (${Enzyme_LLVM_VERSION_MAJOR} GREATER 10)
add_executable(enzyme_test_2 main.c)
target_compile_definitions(enzyme_test_2 PUBLIC -DNOVERSION)
target_link_libraries(enzyme_test_2 PUBLIC LLDEnzymeFlags)
endif()
add_executable(enzyme_test_2 main.c)
target_compile_definitions(enzyme_test_2 PUBLIC -DNOVERSION)
target_link_libraries(enzyme_test_2 PUBLIC LLDEnzymeFlags)
Loading