Skip to content

Commit ae682b4

Browse files
authored
Merge pull request #3183 from gottesmm/migrate_llvm_tools_binary_dir_to_use_llvmconfig.cmake
Migrate llvm tools binary dir to use llvmconfig.cmake
2 parents a7ab3d5 + be112f1 commit ae682b4

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,11 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
113113

114114
precondition_translate_flag(${product}_PATH_TO_LLVM_SOURCE PATH_TO_LLVM_SOURCE)
115115
precondition_translate_flag(${product}_PATH_TO_LLVM_BUILD PATH_TO_LLVM_BUILD)
116+
set(PATH_TO_LLVM_TOOLS_BINARY_DIR "${PATH_TO_LLVM_BUILD}/bin")
116117

117-
if(${is_cross_compiling})
118-
# Can't run llvm-config from the cross-compiled LLVM.
119-
set(LLVM_TOOLS_BINARY_DIR "" CACHE PATH "Path to llvm/bin")
120-
else()
121-
# Rely on llvm-config.
122-
_swift_llvm_config_info(
123-
ENABLE_ASSERTIONS llvm_config_enable_assertions
124-
TOOLS_BINARY_DIR llvm_config_tools_binary_dir
125-
LIBRARY_DIR llvm_config_library_dir
126-
INCLUDE_DIR llvm_config_include_dir
127-
OBJ_ROOT_DIR llvm_config_obj_root
128-
SOURCE_DIR llvm_config_src_dir
129-
)
130-
131-
set(LLVM_TOOLS_BINARY_DIR "${llvm_config_tools_binary_dir}" CACHE PATH "Path to llvm/bin")
132-
133-
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
134-
set(${product}_NATIVE_CLANG_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
118+
if(NOT ${is_cross_compiling})
119+
set(${product}_NATIVE_LLVM_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
120+
set(${product}_NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
135121
endif()
136122

137123
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" "${${product}_NATIVE_LLVM_TOOLS_PATH}"
@@ -155,17 +141,14 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
155141
message(FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}")
156142
endif()
157143

158-
# Save and restore variables that LLVM configuration overrides.
159-
set(LLVM_TOOLS_BINARY_DIR_saved "${LLVM_TOOLS_BINARY_DIR}")
160-
161144
# If we already have a cached value for LLVM_ENABLE_ASSERTIONS, save the value.
162145
if (DEFINED LLVM_ENABLE_ASSERTIONS)
163146
set(LLVM_ENABLE_ASSERTIONS_saved "${LLVM_ENABLE_ASSERTIONS}")
164147
endif()
148+
165149
# Then we import LLVMCONFIG_FILE. This is going to override whatever cached
166150
# value we have for LLVM_ENABLE_ASSERTIONS.
167151
include(${LLVMCONFIG_FILE})
168-
set(LLVM_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR_saved}")
169152

170153
# If we did not have a cached value for LLVM_ENABLE_ASSERTIONS, set
171154
# LLVM_ENABLE_ASSERTIONS_saved to be the ENABLE_ASSERTIONS value from LLVM so
@@ -184,6 +167,7 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
184167
CACHE BOOL "Enable assertions")
185168
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
186169

170+
precondition(LLVM_TOOLS_BINARY_DIR)
187171
precondition_translate_flag(LLVM_BUILD_LIBRARY_DIR LLVM_LIBRARY_DIR)
188172
precondition_translate_flag(LLVM_BUILD_MAIN_INCLUDE_DIR LLVM_MAIN_INCLUDE_DIR)
189173
precondition_translate_flag(LLVM_BUILD_BINARY_DIR LLVM_BINARY_DIR)

utils/build-script-impl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,11 +1832,6 @@ for host in "${ALL_HOSTS[@]}"; do
18321832
native_llvm_tools_path="$(build_directory "${LOCAL_HOST}" llvm)/bin"
18331833
native_clang_tools_path="$(build_directory "${LOCAL_HOST}" llvm)/bin"
18341834
native_swift_tools_path="$(build_directory "${LOCAL_HOST}" swift)/bin"
1835-
1836-
cmake_options=(
1837-
"${cmake_options[@]}"
1838-
-DLLVM_TOOLS_BINARY_DIR:PATH=$(build_directory ${host} llvm)/bin
1839-
)
18401835
else
18411836
build_perf_testsuite_this_time=$(true_false "$(not ${SKIP_BUILD_BENCHMARKS})")
18421837
build_tests_this_time=${SOURCE_TREE_INCLUDES_TESTS}

0 commit comments

Comments
 (0)