[PATCH] D93738: [OpenMP] Not set OPENMP_STANDALONE_BUILD=ON when building OpenMP along with LLVM

Shilei Tian via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 22 17:32:40 PST 2020


tianshilei1992 created this revision.
Herald added subscribers: guansong, yaxunl, mgorny.
tianshilei1992 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, openmp-commits, sstefan1.
Herald added projects: OpenMP, LLVM.

For now, `*_STANDALONE_BUILD` is set to ON even if they're built along
with LLVM because of issues mentioned in the comments. This can cause some issues.
For example, if we build OpenMP along with LLVM, we'd like to copy those OpenMP
headers to `<prefix>/lib/clang/<version>/include` such that `clang` can find
those headers without using `-I <prefix>/include` because those headers will be
copied to `<prefix>/include` if it is built standalone.

In this patch, we fixed the dependence issue in OpenMP such that it can be built
correctly even with `OPENMP_STANDALONE_BUILD=OFF`. The issue is in the call to
`add_lit_testsuite`, where `clang` and `clang-resource-headers` are passed as
`DEPENDS`. Since we're building OpenMP along with LLVM, `clang` is set by CMake
to be the C/C++ compiler, therefore these two dependences are no longer needed,
where caused the dependence issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93738

Files:
  llvm/runtimes/CMakeLists.txt
  openmp/cmake/OpenMPTesting.cmake


Index: openmp/cmake/OpenMPTesting.cmake
===================================================================
--- openmp/cmake/OpenMPTesting.cmake
+++ openmp/cmake/OpenMPTesting.cmake
@@ -185,19 +185,21 @@
       USES_TERMINAL
     )
   else()
+    # Since we're building along with LLVM, clang and clang-resource-headers are
+    # guaranteed so we don't need them in DEPENDS, which can cause issues.
     if (ARG_EXCLUDE_FROM_CHECK_ALL)
       add_lit_testsuite(${target}
         ${comment}
         ${ARG_UNPARSED_ARGUMENTS}
         EXCLUDE_FROM_CHECK_ALL
-        DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS}
+        DEPENDS FileCheck ${ARG_DEPENDS}
         ARGS ${ARG_ARGS}
       )
     else()
       add_lit_testsuite(${target}
         ${comment}
         ${ARG_UNPARSED_ARGUMENTS}
-        DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS}
+        DEPENDS FileCheck ${ARG_DEPENDS}
         ARGS ${ARG_ARGS}
       )
     endif()
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -136,8 +136,11 @@
     # The subdirectories need to treat this as standalone builds. D57992 tried
     # to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if
     # llvm & clang are configured in the same CMake, and setup dependencies
-    # against their targets.
-    set(${canon_name}_STANDALONE_BUILD ON)
+    # against their targets. OpenMP has fixed the issue so we don't set the
+    # variable.
+    if (NOT ${canon_name} STREQUAL "OPENMP")
+      set(${canon_name}_STANDALONE_BUILD ON)
+    endif()
 
     if(LLVM_RUNTIMES_LIBDIR_SUBDIR)
       set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE STRING "" FORCE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93738.313457.patch
Type: text/x-patch
Size: 1804 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201223/be2b8973/attachment.bin>


More information about the llvm-commits mailing list