From 8259931fce1bf9a658cb9fc75af081e015527c2e Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 22 Aug 2022 08:47:03 -0700 Subject: [PATCH] xcc-clang: Do not used unavailable options xcc-clang in based on clan-10 and does not support -fno-pic and -fno-pie. clang-10: warning: argument unused during compilation: '-fno-pic' [-Wunused-command-line-argument] [147/148] Linking C executable zephyr/zephyr.elf clang-10: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument] Signed-off-by: Flavio Ceolin --- CMakeLists.txt | 5 +++-- cmake/compiler/arcmwdt/compiler_flags.cmake | 6 ++++++ cmake/compiler/compiler_flags_template.cmake | 3 +++ cmake/compiler/gcc/compiler_flags.cmake | 6 ++++++ cmake/compiler/xcc-clang/compiler_flags.cmake | 3 +++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef654819a23e7b..b9d98bd4f52177 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,13 +353,14 @@ zephyr_compile_options($) zephyr_compile_options($<$:$>) zephyr_compile_options($<$:$>) +# @Intent: Do not make position independent code / executable +zephyr_compile_options($<$:$>) + # Allow the user to inject options when calling cmake, e.g. # 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..' include(cmake/extra_flags.cmake) zephyr_cc_option(-fno-asynchronous-unwind-tables) -zephyr_cc_option(-fno-pie) -zephyr_cc_option(-fno-pic) if(CONFIG_THREAD_LOCAL_STORAGE) # Only support local exec TLS model at this point. diff --git a/cmake/compiler/arcmwdt/compiler_flags.cmake b/cmake/compiler/arcmwdt/compiler_flags.cmake index 341256ec10ee71..8475ad90350c85 100644 --- a/cmake/compiler/arcmwdt/compiler_flags.cmake +++ b/cmake/compiler/arcmwdt/compiler_flags.cmake @@ -175,6 +175,12 @@ set_property(TARGET compiler-cpp PROPERTY required "-Hcplus" "-Hoff=Stackcheck_a # Compiler flag for turning off thread-safe initialization of local statics set_property(TARGET compiler-cpp PROPERTY no_threadsafe_statics "-fno-threadsafe-statics") +#Compiler flags for disabling position independent code / executable +set_compiler_property(PROPERTY no_position_independent + -fno-pic + -fno-pie +) + ################################# # This section covers asm flags # ################################# diff --git a/cmake/compiler/compiler_flags_template.cmake b/cmake/compiler/compiler_flags_template.cmake index 44bca0324d958d..543b9d6b594759 100644 --- a/cmake/compiler/compiler_flags_template.cmake +++ b/cmake/compiler/compiler_flags_template.cmake @@ -109,3 +109,6 @@ set_property(TARGET asm PROPERTY required) # Compiler flag for disabling pointer arithmetic warnings set_compiler_property(PROPERTY warning_no_pointer_arithmetic) + +# Compiler flags for disabling position independent code / executable +set_compiler_property(PROPERTY no_position_independent) diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index ac0724022b8fb6..e8deb69615299b 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -192,3 +192,9 @@ endif() # Compiler flag for disabling pointer arithmetic warnings set_compiler_property(PROPERTY warning_no_pointer_arithmetic "-Wno-pointer-arith") + +#Compiler flags for disabling position independent code / executable +set_compiler_property(PROPERTY no_position_independent + -fno-pic + -fno-pie +) diff --git a/cmake/compiler/xcc-clang/compiler_flags.cmake b/cmake/compiler/xcc-clang/compiler_flags.cmake index 8b0a29a053343c..c988636a17047a 100644 --- a/cmake/compiler/xcc-clang/compiler_flags.cmake +++ b/cmake/compiler/xcc-clang/compiler_flags.cmake @@ -12,3 +12,6 @@ if($ENV{XCC_NO_G_FLAG}) # Clear the related flag(s) here so it won't cause issues. set_compiler_property(PROPERTY debug) endif() + +# Clang version used by Xtensa does not support -fno-pic and -fno-pie +set_compiler_property(PROPERTY no_position_independent "")