[libc-commits] [PATCH] D105643: [libc] Specificying compilation flags for Windows

Caitlyn Cano via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jul 8 10:49:11 PDT 2021


caitlyncano created this revision.
caitlyncano added reviewers: sivachandra, aeubanks, hedingarcia.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added a project: libc-project.
caitlyncano requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105643

Files:
  libc/cmake/modules/LLVMLibCObjectRules.cmake


Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ 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)
+  if(${LIBC_TARGET_OS} STREQUAL "windows") 
+    set(${output_var}${LLVM_CXX_STD_default} /Qfreestanding ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN} PARENT_SCOPE)
+  else()
+   set(${output_var} -fpie ${LLVM_CXX_STD_default} -ffreestanding ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN} PARENT_SCOPE)
+  endif()
 endfunction()
 
 # Rule which is essentially a wrapper over add_library to compile a set of


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105643.357277.patch
Type: text/x-patch
Size: 852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210708/59935b22/attachment.bin>


More information about the libc-commits mailing list