[libc-commits] [libc] 5e3ec41 - [libc] Only add -ffreestanding flag in full build mode.

Tue Ly via libc-commits libc-commits at lists.llvm.org
Thu Aug 24 07:17:03 PDT 2023


Author: Tue Ly
Date: 2023-08-24T10:15:42-04:00
New Revision: 5e3ec418ff3b2d15911f743a6ed99dc126d0d8f4

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

LOG: [libc] Only add -ffreestanding flag in full build mode.

Only add -ffreestanding flag in full build mode.

Reviewed By: sivachandra

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

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCObjectRules.cmake
    libc/cmake/modules/LLVMLibCTestRules.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 1742bd92f3fcd7..1a3ee519b96b83 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -21,7 +21,12 @@ function(_get_common_compile_options output_var flags)
   set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN})
   if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
     list(APPEND compile_options "-fpie")
-    list(APPEND compile_options "-ffreestanding")
+
+    if(LLVM_LIBC_FULL_BUILD)
+      # Only add -ffreestanding flag in full build mode.
+      list(APPEND compile_options "-ffreestanding")
+    endif()
+
     list(APPEND compile_options "-fno-builtin")
     list(APPEND compile_options "-fno-exceptions")
     list(APPEND compile_options "-fno-lax-vector-conversions")

diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index ee1ac7ff819e15..4d17dcaf06fe9c 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -156,8 +156,14 @@ function(create_libc_unittest fq_target_name)
   )
   target_compile_options(
     ${fq_build_target_name}
-    PRIVATE -fpie -ffreestanding ${LIBC_COMPILE_OPTIONS_DEFAULT}
+    PRIVATE -fpie ${LIBC_COMPILE_OPTIONS_DEFAULT}
   )
+  if(LLVM_LIBC_FULL_BUILD)
+    target_compile_options(
+      ${fq_build_target_name}
+      PRIVATE -ffreestanding
+    )
+  endif()
   if(LIBC_UNITTEST_COMPILE_OPTIONS)
     target_compile_options(
       ${fq_build_target_name}


        


More information about the libc-commits mailing list