@@ -100,6 +100,64 @@ function(get_object_files_for_test result skipped_entrypoints_list)
100100
101101endfunction (get_object_files_for_test)
102102
103+ function (_get_common_test_compile_options output_var c_test flags )
104+ _get_compile_options_from_flags(compile_flags ${flags} )
105+
106+ set (compile_options
107+ ${LIBC_COMPILE_OPTIONS_DEFAULT}
108+ ${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
109+ ${compile_flags} )
110+
111+ if (LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
112+ list (APPEND compile_options "-fpie" )
113+
114+ if (LLVM_LIBC_FULL_BUILD)
115+ list (APPEND compile_options "-DLIBC_FULL_BUILD" )
116+ # Only add -ffreestanding flag in full build mode.
117+ list (APPEND compile_options "-ffreestanding" )
118+ list (APPEND compile_options "-fno-exceptions" )
119+ list (APPEND compile_options "-fno-unwind-tables" )
120+ list (APPEND compile_options "-fno-asynchronous-unwind-tables" )
121+ if (NOT c_test)
122+ list (APPEND compile_options "-fno-rtti" )
123+ endif ()
124+ endif ()
125+
126+ if (LIBC_COMPILER_HAS_FIXED_POINT)
127+ list (APPEND compile_options "-ffixed-point" )
128+ endif ()
129+
130+ # list(APPEND compile_options "-Wall")
131+ # list(APPEND compile_options "-Wextra")
132+ # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
133+ if (NOT LIBC_WNO_ERROR)
134+ # list(APPEND compile_options "-Werror")
135+ endif ()
136+ # list(APPEND compile_options "-Wconversion")
137+ # list(APPEND compile_options "-Wno-sign-conversion")
138+ # list(APPEND compile_options "-Wimplicit-fallthrough")
139+ # list(APPEND compile_options "-Wwrite-strings")
140+ # list(APPEND compile_options "-Wextra-semi")
141+ # Silence this warning because _Complex is a part of C99.
142+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
143+ if (NOT c_test)
144+ list (APPEND compile_options "-fext-numeric-literals" )
145+ endif ()
146+ else ()
147+ list (APPEND compile_options "-Wno-c99-extensions" )
148+ list (APPEND compile_options "-Wno-gnu-imaginary-constant" )
149+ endif ()
150+ list (APPEND compile_options "-Wno-pedantic" )
151+ # if(NOT CMAKE_COMPILER_IS_GNUCXX)
152+ # list(APPEND compile_options "-Wnewline-eof")
153+ # list(APPEND compile_options "-Wnonportable-system-include-path")
154+ # list(APPEND compile_options "-Wstrict-prototypes")
155+ # list(APPEND compile_options "-Wthread-safety")
156+ # list(APPEND compile_options "-Wglobal-constructors")
157+ # endif()
158+ endif ()
159+ set (${output_var} ${compile_options} PARENT_SCOPE)
160+ endfunction ()
103161
104162# Rule to add a libc unittest.
105163# Usage
0 commit comments