@@ -135,21 +135,9 @@ function(_get_common_test_compile_options output_var flags)
135
135
# list(APPEND compile_options "-Wglobal-constructors")
136
136
# endif()
137
137
endif ()
138
- if (LIBC_TARGET_ARCHITECTURE_IS_GPU)
139
- # TODO: Set these flags
140
- # list(APPEND compile_options "-nogpulib")
141
- # list(APPEND compile_options "-fvisibility=hidden")
142
- # list(APPEND compile_options "-fconvergent-functions")
143
-
144
- # # Manually disable all standard include paths and include the resource
145
- # # directory to prevent system headers from being included.
146
- # list(APPEND compile_options "-isystem${COMPILER_RESOURCE_DIR}/include")
147
- # list(APPEND compile_options "-nostdinc")
148
- endif ()
149
138
set (${output_var} ${compile_options} PARENT_SCOPE)
150
139
endfunction ()
151
140
152
-
153
141
# Obtains NVPTX specific arguments for compilation.
154
142
# The PTX feature is primarily based on the CUDA toolchain version. We want to
155
143
# be able to target NVPTX without an existing CUDA installation, so we need to
@@ -202,19 +190,21 @@ function(get_nvptx_compile_options output_var gpu_arch)
202
190
set (${output_var} ${nvptx_options} PARENT_SCOPE)
203
191
endfunction ()
204
192
205
- #TODO: Fold this into a function to get test framework compile options (which
206
- # need to be separate from the main test compile options because otherwise they
207
- # error)
208
- set (LIBC_HERMETIC_TEST_COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_DEFAULT}
209
- -fpie -ffreestanding -fno-exceptions -fno-rtti)
210
- # The GPU build requires overriding the default CMake triple and architecture.
211
- if (LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
212
- list (APPEND LIBC_HERMETIC_TEST_COMPILE_OPTIONS
213
- -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
214
- --target =${LIBC_GPU_TARGET_TRIPLE}
215
- -mcode-object-version =${LIBC_GPU_CODE_OBJECT_VERSION} )
216
- elseif (LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
217
- get_nvptx_compile_options(nvptx_options ${LIBC_GPU_TARGET_ARCHITECTURE} )
218
- list (APPEND LIBC_HERMETIC_TEST_COMPILE_OPTIONS
219
- -nogpulib ${nvptx_options} -fno-use-cxa-atexit --target =${LIBC_GPU_TARGET_TRIPLE} )
220
- endif ()
193
+ function (_get_hermetic_test_compile_options output_var flags )
194
+ _get_compile_options_from_flags(compile_flags ${flags} )
195
+ list (APPEND compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags}
196
+ ${flags} -fpie -ffreestanding -fno-exceptions -fno-rtti)
197
+
198
+ # The GPU build requires overriding the default CMake triple and architecture.
199
+ if (LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
200
+ list (APPEND compile_options
201
+ -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
202
+ --target =${LIBC_GPU_TARGET_TRIPLE}
203
+ -mcode-object-version =${LIBC_GPU_CODE_OBJECT_VERSION} )
204
+ elseif (LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
205
+ get_nvptx_compile_options(nvptx_options ${LIBC_GPU_TARGET_ARCHITECTURE} )
206
+ list (APPEND compile_options
207
+ -nogpulib ${nvptx_options} -fno-use-cxa-atexit --target =${LIBC_GPU_TARGET_TRIPLE} )
208
+ endif ()
209
+ set (${output_var} ${compile_options} PARENT_SCOPE)
210
+ endfunction ()
0 commit comments