[libc-commits] [libc] a16071e - [libc] Don't pass -fpie/-ffreestanding on Windows

Caitlyn Cano via libc-commits libc-commits at lists.llvm.org
Tue Jul 13 13:40:10 PDT 2021


Author: Caitlyn Cano
Date: 2021-07-13T20:39:51Z
New Revision: a16071e409a55cfc83e59eb738fd6144207dd5d1

URL: https://github.com/llvm/llvm-project/commit/a16071e409a55cfc83e59eb738fd6144207dd5d1
DIFF: https://github.com/llvm/llvm-project/commit/a16071e409a55cfc83e59eb738fd6144207dd5d1.diff

LOG: [libc] Don't pass -fpie/-ffreestanding on Windows

The current compile options function hardcodes the -fpie and
-ffreestanding flags, which don't exist on Windows. This patch sets the
compilation flags conditionally based on the OS specifics.

Reviewed By: sivachandra, aeubanks

Differential Revision: https://reviews.llvm.org/D105643

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCObjectRules.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 8c4e6bf8cb244..55761ee238fbb 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -1,7 +1,11 @@
 set(OBJECT_LIBRARY_TARGET_TYPE "OBJECT_LIBRARY")
 
 function(_get_common_compile_options output_var)
-  set(${output_var} -fpie ${LLVM_CXX_STD_default} -ffreestanding ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN} PARENT_SCOPE)
+  set(compile_options ${LLVM_CXX_STD_default} ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN})
+  if(NOT ${LIBC_TARGET_OS} STREQUAL "windows")
+    set(compile_options ${compile_options} -fpie -ffreestanding)
+  endif()
+  set(${output_var} ${compile_options} PARENT_SCOPE)
 endfunction()
 
 # Rule which is essentially a wrapper over add_library to compile a set of


        


More information about the libc-commits mailing list