[PATCH] D72950: [CMake] compiler-rt: Add COMPILER_RT_BUILTINS_ENABLE_PIC

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 15:58:14 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc96eeebca8b0: [CMake] compiler-rt: Add COMPILER_RT_BUILTINS_ENABLE_PIC (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D72950?vs=240004&id=241837#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72950

Files:
  compiler-rt/lib/builtins/CMakeLists.txt


Index: compiler-rt/lib/builtins/CMakeLists.txt
===================================================================
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -26,6 +26,16 @@
   include(AddCompilerRT)
 endif()
 
+if (COMPILER_RT_STANDALONE_BUILD)
+  # When compiler-rt is being built standalone, possibly as a cross-compilation
+  # target, the target may or may not want position independent code. This
+  # option provides an avenue through which the flag may be controlled when an
+  # LLVM configuration is not being utilized.
+  option(COMPILER_RT_BUILTINS_ENABLE_PIC
+    "Turns on or off -fPIC for the builtin library source"
+    ON)
+endif()
+
 include(builtin-config-ix)
 
 # TODO: Need to add a mechanism for logging errors when builtin source files are
@@ -576,7 +586,9 @@
   # These flags would normally be added to CMAKE_C_FLAGS by the llvm
   # cmake step. Add them manually if this is a standalone build.
   if(COMPILER_RT_STANDALONE_BUILD)
-    append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC BUILTIN_CFLAGS)
+    if(COMPILER_RT_BUILTINS_ENABLE_PIC)
+      append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC BUILTIN_CFLAGS)
+    endif()
     append_list_if(COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin BUILTIN_CFLAGS)
     if(NOT ANDROID)
       append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG -fvisibility=hidden BUILTIN_CFLAGS)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72950.241837.patch
Type: text/x-patch
Size: 1396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200131/d460c79a/attachment.bin>


More information about the llvm-commits mailing list