Skip to content

Commit df69ebf

Browse files
committed
[LLVM][runtimes] Prepopulate LLVM_BUILTIN_TARGETS with runtimes values
Summary: We create the builtins separately because these are required to set up before others are built. It's configured with a default value if not specified, but this doesn't respect the runtimes from other targets. This patch changes the behavior to prepopulate the builtins list with all the targets that have `compiler-rt` enabled if not overridden by the user.
1 parent 46307f1 commit df69ebf

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ foreach(proj ${LLVM_ENABLE_RUNTIMES})
1717
endforeach()
1818

1919
function(get_compiler_rt_path path)
20-
foreach(entry ${runtimes})
20+
set(all_runtimes ${runtimes})
21+
foreach(name ${LLVM_RUNTIME_TARGETS})
22+
list(APPEND all_runtimes ${RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES})
23+
endforeach()
24+
list(REMOVE_DUPLICATES all_runtimes)
25+
foreach(entry ${all_runtimes})
2126
get_filename_component(projName ${entry} NAME)
2227
if("${projName}" MATCHES "compiler-rt")
2328
set(${path} ${entry} PARENT_SCOPE)
@@ -138,37 +143,44 @@ endfunction()
138143
# before the just-built compiler can pass the configuration tests.
139144
get_compiler_rt_path(compiler_rt_path)
140145
if(compiler_rt_path)
141-
if(NOT LLVM_BUILTIN_TARGETS)
146+
# If the user did not specify the targets infer them from the runtimes.
147+
set(builtin_targets ${LLVM_BUILTIN_TARGETS})
148+
if(NOT builtin_targets)
149+
if("compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
150+
list(APPEND builtin_targets "default")
151+
endif()
152+
foreach(name ${LLVM_RUNTIME_TARGETS})
153+
if("compiler-rt" IN_LIST RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES)
154+
list(APPEND builtin_targets ${name})
155+
endif()
156+
endforeach()
157+
endif()
158+
if("default" IN_LIST builtin_targets)
142159
builtin_default_target(${compiler_rt_path}
143160
DEPENDS clang-resource-headers)
161+
list(REMOVE_ITEM builtin_targets "default")
144162
else()
145-
if("default" IN_LIST LLVM_BUILTIN_TARGETS)
146-
builtin_default_target(${compiler_rt_path}
147-
DEPENDS clang-resource-headers)
148-
list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
149-
else()
150-
add_custom_target(builtins)
151-
add_custom_target(install-builtins)
152-
add_custom_target(install-builtins-stripped)
153-
set_target_properties(
154-
builtins install-builtins install-builtins-stripped
155-
PROPERTIES FOLDER "Compiler-RT"
156-
)
157-
endif()
163+
add_custom_target(builtins)
164+
add_custom_target(install-builtins)
165+
add_custom_target(install-builtins-stripped)
166+
set_target_properties(
167+
builtins install-builtins install-builtins-stripped
168+
PROPERTIES FOLDER "Compiler-RT"
169+
)
170+
endif()
158171

159-
foreach(target ${LLVM_BUILTIN_TARGETS})
160-
check_apple_target(${target} builtin)
172+
foreach(target ${builtin_targets})
173+
check_apple_target(${target} builtin)
161174

162-
builtin_register_target(${compiler_rt_path} ${target}
163-
DEPENDS clang-resource-headers
164-
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
165-
EXTRA_ARGS TARGET_TRIPLE ${target})
175+
builtin_register_target(${compiler_rt_path} ${target}
176+
DEPENDS clang-resource-headers
177+
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
178+
EXTRA_ARGS TARGET_TRIPLE ${target})
166179

167-
add_dependencies(builtins builtins-${target})
168-
add_dependencies(install-builtins install-builtins-${target})
169-
add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
170-
endforeach()
171-
endif()
180+
add_dependencies(builtins builtins-${target})
181+
add_dependencies(install-builtins install-builtins-${target})
182+
add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
183+
endforeach()
172184
set(builtins_dep builtins)
173185
# We don't need to depend on the builtins if we're building instrumented
174186
# because the next stage will use the same compiler used to build this stage.

0 commit comments

Comments
 (0)