Skip to content

Commit aa2fba5

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 d6bbe2e commit aa2fba5

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ 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+
foreach(entry ${all_runtimes})
2125
get_filename_component(projName ${entry} NAME)
2226
if("${projName}" MATCHES "compiler-rt")
2327
set(${path} ${entry} PARENT_SCOPE)
@@ -138,37 +142,43 @@ endfunction()
138142
# before the just-built compiler can pass the configuration tests.
139143
get_compiler_rt_path(compiler_rt_path)
140144
if(compiler_rt_path)
145+
# If the user did not specify the targets infer them from the runtimes.
141146
if(NOT LLVM_BUILTIN_TARGETS)
147+
if("compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
148+
list(APPEND LLVM_BUILTIN_TARGETS "default")
149+
endif()
150+
foreach(name ${LLVM_RUNTIME_TARGETS})
151+
if("compiler-rt" IN_LIST RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES)
152+
list(APPEND LLVM_BUILTIN_TARGETS ${name})
153+
endif()
154+
endforeach()
155+
endif()
156+
if("default" IN_LIST LLVM_BUILTIN_TARGETS)
142157
builtin_default_target(${compiler_rt_path}
143158
DEPENDS clang-resource-headers)
159+
list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
144160
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()
161+
add_custom_target(builtins)
162+
add_custom_target(install-builtins)
163+
add_custom_target(install-builtins-stripped)
164+
set_target_properties(
165+
builtins install-builtins install-builtins-stripped
166+
PROPERTIES FOLDER "Compiler-RT"
167+
)
168+
endif()
158169

159-
foreach(target ${LLVM_BUILTIN_TARGETS})
160-
check_apple_target(${target} builtin)
170+
foreach(target ${LLVM_BUILTIN_TARGETS})
171+
check_apple_target(${target} builtin)
161172

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})
173+
builtin_register_target(${compiler_rt_path} ${target}
174+
DEPENDS clang-resource-headers
175+
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
176+
EXTRA_ARGS TARGET_TRIPLE ${target})
166177

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()
178+
add_dependencies(builtins builtins-${target})
179+
add_dependencies(install-builtins install-builtins-${target})
180+
add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
181+
endforeach()
172182
set(builtins_dep builtins)
173183
# We don't need to depend on the builtins if we're building instrumented
174184
# because the next stage will use the same compiler used to build this stage.

0 commit comments

Comments
 (0)