[llvm] [LLVM][runtimes] Prepopulate `LLVM_BUILTIN_TARGETS` with runtimes values (PR #95554)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 05:53:38 PDT 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/95554
>From fc84e233589ad868c0e7d1024702678e9b6833ac Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 14 Jun 2024 10:01:31 -0500
Subject: [PATCH] [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.
---
llvm/runtimes/CMakeLists.txt | 64 +++++++++++++++++++++---------------
1 file changed, 38 insertions(+), 26 deletions(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index f2c273b0b9050..7e089da678c14 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -17,13 +17,18 @@ foreach(proj ${LLVM_ENABLE_RUNTIMES})
endforeach()
function(get_compiler_rt_path path)
- foreach(entry ${runtimes})
+ set(all_runtimes ${runtimes})
+ foreach(name ${LLVM_RUNTIME_TARGETS})
+ list(APPEND all_runtimes ${RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES})
+ endforeach()
+ foreach(entry ${all_runtimes})
get_filename_component(projName ${entry} NAME)
if("${projName}" MATCHES "compiler-rt")
set(${path} ${entry} PARENT_SCOPE)
return()
endif()
endforeach()
+ list(REMOVE_DUPLICATES all_runtimes)
endfunction()
include(LLVMExternalProjectUtils)
@@ -138,37 +143,44 @@ endfunction()
# before the just-built compiler can pass the configuration tests.
get_compiler_rt_path(compiler_rt_path)
if(compiler_rt_path)
- if(NOT LLVM_BUILTIN_TARGETS)
+ # If the user did not specify the targets infer them from the runtimes.
+ set(builtin_targets ${LLVM_BUILTIN_TARGETS})
+ if(NOT builtin_targets)
+ if("compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ list(APPEND builtin_targets "default")
+ endif()
+ foreach(name ${LLVM_RUNTIME_TARGETS})
+ if("compiler-rt" IN_LIST RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES)
+ list(APPEND builtin_targets ${name})
+ endif()
+ endforeach()
+ endif()
+ if("default" IN_LIST builtin_targets)
builtin_default_target(${compiler_rt_path}
DEPENDS clang-resource-headers)
+ list(REMOVE_ITEM builtin_targets "default")
else()
- if("default" IN_LIST LLVM_BUILTIN_TARGETS)
- builtin_default_target(${compiler_rt_path}
- DEPENDS clang-resource-headers)
- list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
- else()
- add_custom_target(builtins)
- add_custom_target(install-builtins)
- add_custom_target(install-builtins-stripped)
- set_target_properties(
- builtins install-builtins install-builtins-stripped
- PROPERTIES FOLDER "Compiler-RT"
- )
- endif()
+ add_custom_target(builtins)
+ add_custom_target(install-builtins)
+ add_custom_target(install-builtins-stripped)
+ set_target_properties(
+ builtins install-builtins install-builtins-stripped
+ PROPERTIES FOLDER "Compiler-RT"
+ )
+ endif()
- foreach(target ${LLVM_BUILTIN_TARGETS})
- check_apple_target(${target} builtin)
+ foreach(target ${builtin_targets})
+ check_apple_target(${target} builtin)
- builtin_register_target(${compiler_rt_path} ${target}
- DEPENDS clang-resource-headers
- CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
- EXTRA_ARGS TARGET_TRIPLE ${target})
+ builtin_register_target(${compiler_rt_path} ${target}
+ DEPENDS clang-resource-headers
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
+ EXTRA_ARGS TARGET_TRIPLE ${target})
- add_dependencies(builtins builtins-${target})
- add_dependencies(install-builtins install-builtins-${target})
- add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
- endforeach()
- endif()
+ add_dependencies(builtins builtins-${target})
+ add_dependencies(install-builtins install-builtins-${target})
+ add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
+ endforeach()
set(builtins_dep builtins)
# We don't need to depend on the builtins if we're building instrumented
# because the next stage will use the same compiler used to build this stage.
More information about the llvm-commits
mailing list