https://github.com/luporl updated 
https://github.com/llvm/llvm-project/pull/160581

>From a7d1e33ceb9dbc5495374da79a91142b1b1bbd8d Mon Sep 17 00:00:00 2001
From: Leandro Lupori <[email protected]>
Date: Wed, 24 Sep 2025 18:23:25 +0000
Subject: [PATCH 1/3] Build and ship OpenMP with LLVM releases

Fixes #135021

Suggested-by: Kawashima Takahiro <[email protected]>
---
 clang/cmake/caches/Release.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index 25f7970119d07..6ddcb7b645c41 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -36,13 +36,15 @@ if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
   list(APPEND DEFAULT_PROJECTS "bolt")
 endif()
 
+set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
+
 # Don't build flang on Darwin due to:
 # https://github.com/llvm/llvm-project/issues/160546
 if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
   list(APPEND DEFAULT_PROJECTS "flang")
+  list(APPEND DEFAULT_RUNTIMES "openmp;flang-rt")
 endif()
 
-set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
 if (NOT WIN32)
   list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind")
 endif()

>From d69d2572a176660947439f0f6b1976deb183274a Mon Sep 17 00:00:00 2001
From: Leandro Lupori <[email protected]>
Date: Thu, 2 Oct 2025 19:57:29 +0000
Subject: [PATCH 2/3] Use LLVM_ENABLE_LIBCXX=ON to build the runtimes too

- also add a missing dependency in libompd
---
 clang/cmake/caches/Release.cmake  |  1 +
 openmp/libompd/src/CMakeLists.txt | 13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index 6ddcb7b645c41..cb18bd17e6814 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -146,6 +146,7 @@ endif()
 if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
   set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
   set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
+  set_instrument_and_final_stage_var(RUNTIMES_CMAKE_ARGS 
"-DLLVM_ENABLE_LIBCXX=ON" STRING)
   set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
   if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
     set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
diff --git a/openmp/libompd/src/CMakeLists.txt 
b/openmp/libompd/src/CMakeLists.txt
index ba228d5181048..410f486220e84 100644
--- a/openmp/libompd/src/CMakeLists.txt
+++ b/openmp/libompd/src/CMakeLists.txt
@@ -11,16 +11,21 @@
 project (libompd)
 cmake_minimum_required(VERSION 3.20.0)
 
+set(LIBOMPD_LD_STD_FLAGS FALSE CACHE BOOL
+  "Use -stdlibc++ instead of -libc++ library for C++ ")
+
+set(LIBCXX_DEP)
+if("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT ${LIBOMPD_LD_STD_FLAGS})
+  set(LIBCXX_DEP cxx)
+endif()
+
 add_library (ompd SHARED TargetValue.cpp omp-debug.cpp omp-state.cpp 
omp-icv.cpp)
 
 # libompd must not link against libomp, there is no code dependency.
-add_dependencies(ompd omp) # ensure generated import library is created first
+add_dependencies(ompd omp ${LIBCXX_DEP}) # ensure generated import library is 
created first
 
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 
-set(LIBOMPD_LD_STD_FLAGS FALSE CACHE BOOL
-  "Use -stdlibc++ instead of -libc++ library for C++ ")
-
 if(${LIBOMPD_LD_STD_FLAGS})
 #  Find and replace/add libstdc++ to compile flags     
    STRING( FIND "${CMAKE_CXX_FLAGS}" "-stdlib=libc++" OUT )

>From 5133cb8fb7f333ce2b1b2871d684daf7547b0d85 Mon Sep 17 00:00:00 2001
From: Leandro Lupori <[email protected]>
Date: Thu, 27 Nov 2025 13:51:46 +0000
Subject: [PATCH 3/3] Don't set LLVM_ENABLE_LIBCXX for runtimes

Because it is now disabled by default for projects.

Also, revert libc++ dependency fix for libompd. Since it's not
needed anymore, it's better to submit it in another PR.
---
 clang/cmake/caches/Release.cmake  |  6 ++----
 openmp/libompd/src/CMakeLists.txt | 13 ++++---------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index cb18bd17e6814..efe20a201dbc9 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -36,13 +36,12 @@ if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
   list(APPEND DEFAULT_PROJECTS "bolt")
 endif()
 
-set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
-
+set (DEFAULT_RUNTIMES "compiler-rt;libcxx;openmp")
 # Don't build flang on Darwin due to:
 # https://github.com/llvm/llvm-project/issues/160546
 if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
   list(APPEND DEFAULT_PROJECTS "flang")
-  list(APPEND DEFAULT_RUNTIMES "openmp;flang-rt")
+  list(APPEND DEFAULT_RUNTIMES "flang-rt")
 endif()
 
 if (NOT WIN32)
@@ -146,7 +145,6 @@ endif()
 if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
   set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
   set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
-  set_instrument_and_final_stage_var(RUNTIMES_CMAKE_ARGS 
"-DLLVM_ENABLE_LIBCXX=ON" STRING)
   set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
   if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
     set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
diff --git a/openmp/libompd/src/CMakeLists.txt 
b/openmp/libompd/src/CMakeLists.txt
index 410f486220e84..ba228d5181048 100644
--- a/openmp/libompd/src/CMakeLists.txt
+++ b/openmp/libompd/src/CMakeLists.txt
@@ -11,21 +11,16 @@
 project (libompd)
 cmake_minimum_required(VERSION 3.20.0)
 
-set(LIBOMPD_LD_STD_FLAGS FALSE CACHE BOOL
-  "Use -stdlibc++ instead of -libc++ library for C++ ")
-
-set(LIBCXX_DEP)
-if("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT ${LIBOMPD_LD_STD_FLAGS})
-  set(LIBCXX_DEP cxx)
-endif()
-
 add_library (ompd SHARED TargetValue.cpp omp-debug.cpp omp-state.cpp 
omp-icv.cpp)
 
 # libompd must not link against libomp, there is no code dependency.
-add_dependencies(ompd omp ${LIBCXX_DEP}) # ensure generated import library is 
created first
+add_dependencies(ompd omp) # ensure generated import library is created first
 
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 
+set(LIBOMPD_LD_STD_FLAGS FALSE CACHE BOOL
+  "Use -stdlibc++ instead of -libc++ library for C++ ")
+
 if(${LIBOMPD_LD_STD_FLAGS})
 #  Find and replace/add libstdc++ to compile flags     
    STRING( FIND "${CMAKE_CXX_FLAGS}" "-stdlib=libc++" OUT )

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to