[PATCH] D136664: [CMake] Support building crt with the bootstrapping build

2023-08-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek abandoned this revision.
phosek added a comment.
Herald added a subscriber: ekilmer.

Superseded by D153989 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136664/new/

https://reviews.llvm.org/D136664

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136664: [CMake] Support building crt with the bootstrapping build

2022-11-04 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

In D136664#3884796 , @phosek wrote:

> In D136664#3882989 , @smeenai wrote:
>
>> I might be missing it, but I don't see `crt` depending on `builtins` (or 
>> vice versa). If there is actually no dep, could we build them together in a 
>> single configure, instead of needing to add another one for crt? If there is 
>> a dep and I missed it, then this LGTM.
>
> There is no dependency because `crt` and `builtins` aren't dependent on each 
> other. We could build them in a single configure, but we would another top 
> level `CMakeLists.txt`. Do you have any suggestions for where that should 
> live?

Sorry, this fell off my radar. This is fine as-is; avoiding the extra configure 
could potentially be nice for build times, but we can address that later if 
it's actually an issue. I don't have a great idea for the placement of the 
combined builtins+crt CMakeLists.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136664/new/

https://reviews.llvm.org/D136664

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136664: [CMake] Support building crt with the bootstrapping build

2022-10-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D136664#3882989 , @smeenai wrote:

> I might be missing it, but I don't see `crt` depending on `builtins` (or vice 
> versa). If there is actually no dep, could we build them together in a single 
> configure, instead of needing to add another one for crt? If there is a dep 
> and I missed it, then this LGTM.

There is no dependency because `crt` and `builtins` aren't dependent on each 
other. We could build them in a single configure, but we would another top 
level `CMakeLists.txt`. Do you have any suggestions for where that should live?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136664/new/

https://reviews.llvm.org/D136664

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136664: [CMake] Support building crt with the bootstrapping build

2022-10-25 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I might be missing it, but I don't see `crt` depending on `builtins` (or vice 
versa). If there is actually no dep, could we build them together in a single 
configure, instead of needing to add another one for crt? If there is a dep and 
I missed it, then this LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136664/new/

https://reviews.llvm.org/D136664

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136664: [CMake] Support building crt with the bootstrapping build

2022-10-24 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: smeenai, beanz.
Herald added a subscriber: abrachet.
Herald added a project: All.
phosek requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

On platforms like Linux, we need to build crt prior building the rest of
compiler-rt. This change introduces support for building crt with the
bootstrapping build akin to builtins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136664

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -120,6 +120,62 @@
${EXTRA_ARGS})
 endfunction()
 
+function(crt_default_target compiler_rt_path)
+  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
+
+  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
+  # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
+  if (LLVM_TARGET_TRIPLE MATCHES "aix")
+set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
+  endif()
+
+  llvm_ExternalProject_Add(crt
+   ${compiler_rt_path}/lib/crt
+   DEPENDS ${ARG_DEPENDS}
+   CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
+  -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
+  -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
+  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
+  -DCMAKE_C_COMPILER_WORKS=ON
+  ${COMMON_CMAKE_ARGS}
+  ${CRT_CMAKE_ARGS}
+   PASSTHROUGH_PREFIXES COMPILER_RT
+   USE_TOOLCHAIN
+   TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
+   ${EXTRA_ARGS})
+endfunction()
+
+function(crt_register_target compiler_rt_path target)
+  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
+
+  check_apple_target(${target} crt)
+
+  get_cmake_property(variableNames VARIABLES)
+  foreach(variableName ${variableNames})
+string(FIND "${variableName}" "CRT_${target}" out)
+if("${out}" EQUAL 0)
+  string(REPLACE "CRT_${target}_" "" new_name ${variableName})
+  string(REPLACE ";" "|" new_value "${${variableName}}")
+  list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
+endif()
+  endforeach()
+
+  llvm_ExternalProject_Add(crt-${target}
+   ${compiler_rt_path}/lib/crt
+   DEPENDS ${ARG_DEPENDS}
+   CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
+  -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
+  -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
+  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
+  -DCMAKE_C_COMPILER_WORKS=ON
+  -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
+  ${COMMON_CMAKE_ARGS}
+  ${${target}_extra_args}
+   USE_TOOLCHAIN
+   TARGET_TRIPLE ${target}
+   ${EXTRA_ARGS})
+endfunction()
+
 # If compiler-rt is present we need to build the builtin libraries first. This
 # is required because the other runtimes need the builtin libraries present
 # before the just-built compiler can pass the configuration tests.
@@ -148,12 +204,42 @@
   add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
 endforeach()
   endif()
-  set(deps builtins)
+  list(APPEND deps 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.
   if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
 add_dependencies(clang-bootstrap-deps builtins)
   endif()
+
+  if(NOT LLVM_CRT_TARGETS)
+crt_default_target(${compiler_rt_path}
+  DEPENDS clang-resource-headers)
+  else()
+if("default" IN_LIST LLVM_CRT_TARGETS)
+  crt_default_target(${compiler_rt_path}
+DEPENDS clang-resource-headers)
+  list(REMOVE_ITEM LLVM_CRT_TARGETS "default")
+else()
+  add_custom_target(crt)
+  add_custom_target(install-crt)
+  add_custom_target(install-crt-stripped)
+endif()
+
+foreach(target ${LLVM_CRT_TARGETS})
+  crt_register_target(${compiler_rt_path} ${target}
+DEPENDS clang-resource-headers)
+
+  add_dependencies(crt crt-${target})
+  add_dependencies(install-crt install-crt-${target})
+  ad