[libc-commits] [PATCH] D158652: [libc] Only add -ffreestanding flag in full build mode.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 23 13:07:59 PDT 2023


lntue updated this revision to Diff 552861.
lntue added a comment.

Only add -ffreestanding to unit tests in full build mode.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158652/new/

https://reviews.llvm.org/D158652

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


Index: libc/cmake/modules/LLVMLibCTestRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCTestRules.cmake
+++ libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -154,10 +154,17 @@
       ${LIBC_SOURCE_DIR}
       ${LIBC_INCLUDE_DIR}
   )
-  target_compile_options(
-    ${fq_build_target_name}
-    PRIVATE -fpie -ffreestanding ${LIBC_COMPILE_OPTIONS_DEFAULT}
-  )
+  if(LLVM_LIBC_FULL_BUILD)
+    target_compile_options(
+      ${fq_build_target_name}
+      PRIVATE -fpie -ffreestanding ${LIBC_COMPILE_OPTIONS_DEFAULT}
+    )
+  else()
+    target_compile_options(
+      ${fq_build_target_name}
+      PRIVATE -fpie ${LIBC_COMPILE_OPTIONS_DEFAULT}
+    )
+  endif()
   if(LIBC_UNITTEST_COMPILE_OPTIONS)
     target_compile_options(
       ${fq_build_target_name}
Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -21,7 +21,12 @@
   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")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158652.552861.patch
Type: text/x-patch
Size: 1576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230823/b82b3368/attachment-0001.bin>


More information about the libc-commits mailing list