aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2020-01-31 15:57:18 -0800
committerPetr Hosek <phosek@google.com>2020-01-31 15:57:18 -0800
commitc96eeebca8b074d2f5cdbd8de3dc42a31b3ea8d7 (patch)
tree6427a18d30abdef1de96e0c98673848210b7cde9
parentb33e5f3c3e850fafcfa94a59da9cdee8eb5f855e (diff)
downloadllvm-c96eeebca8b074d2f5cdbd8de3dc42a31b3ea8d7.zip
llvm-c96eeebca8b074d2f5cdbd8de3dc42a31b3ea8d7.tar.gz
llvm-c96eeebca8b074d2f5cdbd8de3dc42a31b3ea8d7.tar.bz2
[CMake] compiler-rt: Add COMPILER_RT_BUILTINS_ENABLE_PIC
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. Patch By: JamesNagurne Differential Revision: https://reviews.llvm.org/D72950
-rw-r--r--compiler-rt/lib/builtins/CMakeLists.txt14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index feacd21..125a3a1 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -26,6 +26,16 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
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 @@ else ()
# 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)