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

James Nagurne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 12:47:38 PST 2020


JamesNagurne created this revision.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, dberris.
Herald added projects: Sanitizers, LLVM.

  The configuration for -fPIC in the builtins library when built standalone
  is unconditional, stating that the flags would "normally be added... by
  the llvm cmake step"
  
  This is untrue, as the llvm cmake step checks LLVM_ENABLE_PIC, which allows
  a client to turn off -fPIC.
  
  I've added an option when compiler-rt builtins are configured standalone, such
  as when built as part of the LLVM runtimes system, to guard the application of
  -fPIC for users that want it.


Repository:
  rG LLVM Github Monorepo

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
@@ -24,6 +24,10 @@
     include(UseLibtool)
   endif()
   include(AddCompilerRT)
+
+  option(COMPILER_RT_BUILTINS_ENABLE_PIC
+    "Turns on or off -fPIC for the builtin library source"
+    ON)
 endif()
 
 include(builtin-config-ix)
@@ -576,7 +580,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.238862.patch
Type: text/x-patch
Size: 1020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200117/d072a512/attachment.bin>


More information about the llvm-commits mailing list