Skip to content

Commit ddd1164

Browse files
move _get_common_test_compile_options too
1 parent 6193104 commit ddd1164

File tree

2 files changed

+58
-59
lines changed

2 files changed

+58
-59
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -213,62 +213,3 @@ function(_get_common_compile_options output_var flags)
213213
endif()
214214
set(${output_var} ${compile_options} PARENT_SCOPE)
215215
endfunction()
216-
217-
function(_get_common_test_compile_options output_var c_test flags)
218-
_get_compile_options_from_flags(compile_flags ${flags})
219-
220-
set(compile_options
221-
${LIBC_COMPILE_OPTIONS_DEFAULT}
222-
${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
223-
${compile_flags})
224-
225-
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
226-
list(APPEND compile_options "-fpie")
227-
228-
if(LLVM_LIBC_FULL_BUILD)
229-
list(APPEND compile_options "-DLIBC_FULL_BUILD")
230-
# Only add -ffreestanding flag in full build mode.
231-
list(APPEND compile_options "-ffreestanding")
232-
list(APPEND compile_options "-fno-exceptions")
233-
list(APPEND compile_options "-fno-unwind-tables")
234-
list(APPEND compile_options "-fno-asynchronous-unwind-tables")
235-
if(NOT c_test)
236-
list(APPEND compile_options "-fno-rtti")
237-
endif()
238-
endif()
239-
240-
if(LIBC_COMPILER_HAS_FIXED_POINT)
241-
list(APPEND compile_options "-ffixed-point")
242-
endif()
243-
244-
# list(APPEND compile_options "-Wall")
245-
# list(APPEND compile_options "-Wextra")
246-
# -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
247-
if(NOT LIBC_WNO_ERROR)
248-
# list(APPEND compile_options "-Werror")
249-
endif()
250-
# list(APPEND compile_options "-Wconversion")
251-
# list(APPEND compile_options "-Wno-sign-conversion")
252-
# list(APPEND compile_options "-Wimplicit-fallthrough")
253-
# list(APPEND compile_options "-Wwrite-strings")
254-
# list(APPEND compile_options "-Wextra-semi")
255-
# Silence this warning because _Complex is a part of C99.
256-
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
257-
if(NOT c_test)
258-
list(APPEND compile_options "-fext-numeric-literals")
259-
endif()
260-
else()
261-
list(APPEND compile_options "-Wno-c99-extensions")
262-
list(APPEND compile_options "-Wno-gnu-imaginary-constant")
263-
endif()
264-
list(APPEND compile_options "-Wno-pedantic")
265-
# if(NOT CMAKE_COMPILER_IS_GNUCXX)
266-
# list(APPEND compile_options "-Wnewline-eof")
267-
# list(APPEND compile_options "-Wnonportable-system-include-path")
268-
# list(APPEND compile_options "-Wstrict-prototypes")
269-
# list(APPEND compile_options "-Wthread-safety")
270-
# list(APPEND compile_options "-Wglobal-constructors")
271-
# endif()
272-
endif()
273-
set(${output_var} ${compile_options} PARENT_SCOPE)
274-
endfunction()

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,64 @@ function(get_object_files_for_test result skipped_entrypoints_list)
100100

101101
endfunction(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

Comments
 (0)