[PATCH] D62841: [openmp] Use libffi only when LLVM_ENABLE_FFI is on

Taewook Oh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 22:32:02 PDT 2019


twoh updated this revision to Diff 203078.
twoh added a comment.

@grokos Thanks for the suggestion. What about this?

Off by default
==============

> cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS=openmp 2>&1 | grep LIBFFI

  - Could NOT find LIBOMPTARGET_DEP_LIBFFI (missing: LIBOMPTARGET_DEP_LIBFFI_LIBRARIES LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS)
1. On if LIBOMPTARGET_ENABLE_FFI is set

> cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS=openmp -DLIBOMPTARGET_ENABLE_FFI=ON 2>&1 | grep LIBFFI

  - Found LIBOMPTARGET_DEP_LIBFFI: /usr/lib64/libffi.so
1. On if LLVM_ENABLE_FFI is on

> cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS=openmp -DLLVM_ENABLE_FFI=ON 2>&1 | grep LIBFFI

  - Found LIBOMPTARGET_DEP_LIBFFI: /usr/lib64/libffi.so
1. Option LIBOMPTARGET_ENABLE_FFI has a precedence over the default value

> cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS=openmp -DLLVM_ENABLE_FFI=ON -DLIBOMPTARGET_ENABLE_FFI=OFF 2>&1 | grep LIBFFI

  - Could NOT find LIBOMPTARGET_DEP_LIBFFI (missing: LIBOMPTARGET_DEP_LIBFFI_LIBRARIES LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS)
1. On by default if standalone build

> cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS=openmp -DOPENMP_STANDALONE_BUILD=ON 2>&1 | grep LIBFFI

- Found LIBOMPTARGET_DEP_LIBFFI: /usr/lib64/libffi.so


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62841

Files:
  openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake


Index: openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
===================================================================
--- openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -65,36 +65,46 @@
 
 pkg_check_modules(LIBOMPTARGET_SEARCH_LIBFFI QUIET libffi)
 
-find_path (
-  LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR
-  NAMES
-    ffi.h
-  HINTS
-    ${LIBOMPTARGET_SEARCH_LIBFFI_INCLUDEDIR}
-    ${LIBOMPTARGET_SEARCH_LIBFFI_INCLUDE_DIRS}
-  PATHS
-    /usr/include
-    /usr/local/include
-    /opt/local/include
-    /sw/include
-    ENV CPATH)
+if (OPENMP_STANDALONE_BUILD)
+  set(LIBOMPTARGET_ENABLE_FFI_DEFAULT ON)
+else()
+  set(LIBOMPTARGET_ENABLE_FFI_DEFAULT ${LLVM_ENABLE_FFI})
+endif()
 
-# Don't bother look for the library if the header files were not found.
-if (LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR)
-  find_library (
-      LIBOMPTARGET_DEP_LIBFFI_LIBRARIES
+option(LIBOMPTARGET_ENABLE_FFI "Enable libffi for libomptarget."
+       ${LIBOMPTARGET_ENABLE_FFI_DEFAULT})
+if (LIBOMPTARGET_ENABLE_FFI)
+  find_path (
+    LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR
     NAMES
-      ffi
+      ffi.h
     HINTS
-      ${LIBOMPTARGET_SEARCH_LIBFFI_LIBDIR}
-      ${LIBOMPTARGET_SEARCH_LIBFFI_LIBRARY_DIRS}
+      ${LIBOMPTARGET_SEARCH_LIBFFI_INCLUDEDIR}
+      ${LIBOMPTARGET_SEARCH_LIBFFI_INCLUDE_DIRS}
     PATHS
-      /usr/lib
-      /usr/local/lib
-      /opt/local/lib
-      /sw/lib
-      ENV LIBRARY_PATH
-      ENV LD_LIBRARY_PATH)
+      /usr/include
+      /usr/local/include
+      /opt/local/include
+      /sw/include
+      ENV CPATH)
+  
+  # Don't bother look for the library if the header files were not found.
+  if (LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR)
+    find_library (
+        LIBOMPTARGET_DEP_LIBFFI_LIBRARIES
+      NAMES
+        ffi
+      HINTS
+        ${LIBOMPTARGET_SEARCH_LIBFFI_LIBDIR}
+        ${LIBOMPTARGET_SEARCH_LIBFFI_LIBRARY_DIRS}
+      PATHS
+        /usr/lib
+        /usr/local/lib
+        /opt/local/lib
+        /sw/lib
+        ENV LIBRARY_PATH
+        ENV LD_LIBRARY_PATH)
+  endif()
 endif()
 
 set(LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62841.203078.patch
Type: text/x-patch
Size: 2239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190605/d8d28325/attachment.bin>


More information about the llvm-commits mailing list