|
| 1 | +function(_get_common_test_compile_options output_var c_test flags) |
| 2 | + _get_compile_options_from_flags(compile_flags ${flags}) |
| 3 | + |
| 4 | + set(compile_options |
| 5 | + ${LIBC_COMPILE_OPTIONS_DEFAULT} |
| 6 | + ${LIBC_TEST_COMPILE_OPTIONS_DEFAULT} |
| 7 | + ${compile_flags}) |
| 8 | + |
| 9 | + if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE) |
| 10 | + list(APPEND compile_options "-fpie") |
| 11 | + |
| 12 | + if(LLVM_LIBC_FULL_BUILD) |
| 13 | + list(APPEND compile_options "-DLIBC_FULL_BUILD") |
| 14 | + # Only add -ffreestanding flag in full build mode. |
| 15 | + list(APPEND compile_options "-ffreestanding") |
| 16 | + list(APPEND compile_options "-fno-exceptions") |
| 17 | + list(APPEND compile_options "-fno-unwind-tables") |
| 18 | + list(APPEND compile_options "-fno-asynchronous-unwind-tables") |
| 19 | + if(NOT c_test) |
| 20 | + list(APPEND compile_options "-fno-rtti") |
| 21 | + endif() |
| 22 | + endif() |
| 23 | + |
| 24 | + if(LIBC_COMPILER_HAS_FIXED_POINT) |
| 25 | + list(APPEND compile_options "-ffixed-point") |
| 26 | + endif() |
| 27 | + |
| 28 | + # list(APPEND compile_options "-Wall") |
| 29 | + # list(APPEND compile_options "-Wextra") |
| 30 | + # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror. |
| 31 | + if(NOT LIBC_WNO_ERROR) |
| 32 | + # list(APPEND compile_options "-Werror") |
| 33 | + endif() |
| 34 | + # list(APPEND compile_options "-Wconversion") |
| 35 | + # list(APPEND compile_options "-Wno-sign-conversion") |
| 36 | + # list(APPEND compile_options "-Wimplicit-fallthrough") |
| 37 | + # list(APPEND compile_options "-Wwrite-strings") |
| 38 | + # list(APPEND compile_options "-Wextra-semi") |
| 39 | + # Silence this warning because _Complex is a part of C99. |
| 40 | + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 41 | + if(NOT c_test) |
| 42 | + list(APPEND compile_options "-fext-numeric-literals") |
| 43 | + endif() |
| 44 | + else() |
| 45 | + list(APPEND compile_options "-Wno-c99-extensions") |
| 46 | + list(APPEND compile_options "-Wno-gnu-imaginary-constant") |
| 47 | + endif() |
| 48 | + list(APPEND compile_options "-Wno-pedantic") |
| 49 | + # if(NOT CMAKE_COMPILER_IS_GNUCXX) |
| 50 | + # list(APPEND compile_options "-Wnewline-eof") |
| 51 | + # list(APPEND compile_options "-Wnonportable-system-include-path") |
| 52 | + # list(APPEND compile_options "-Wstrict-prototypes") |
| 53 | + # list(APPEND compile_options "-Wthread-safety") |
| 54 | + # list(APPEND compile_options "-Wglobal-constructors") |
| 55 | + # endif() |
| 56 | + endif() |
| 57 | + set(${output_var} ${compile_options} PARENT_SCOPE) |
| 58 | +endfunction() |
| 59 | + |
| 60 | +function(_get_hermetic_test_compile_options output_var) |
| 61 | + _get_common_test_compile_options(compile_options "" "") |
| 62 | + |
| 63 | + # The GPU build requires overriding the default CMake triple and architecture. |
| 64 | + if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU) |
| 65 | + list(APPEND compile_options |
| 66 | + -Wno-multi-gpu -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto |
| 67 | + -mcode-object-version=${LIBC_GPU_CODE_OBJECT_VERSION}) |
| 68 | + elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX) |
| 69 | + list(APPEND compile_options |
| 70 | + "SHELL:-mllvm -nvptx-emit-init-fini-kernel=false" |
| 71 | + -Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT} |
| 72 | + -nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit) |
| 73 | + endif() |
| 74 | + |
| 75 | + set(${output_var} ${compile_options} PARENT_SCOPE) |
| 76 | +endfunction() |
| 77 | + |
1 | 78 | # This is a helper function and not a build rule. It is to be used by the
|
2 | 79 | # various test rules to generate the full list of object files
|
3 | 80 | # recursively produced by "add_entrypoint_object" and "add_object_library"
|
@@ -100,7 +177,6 @@ function(get_object_files_for_test result skipped_entrypoints_list)
|
100 | 177 |
|
101 | 178 | endfunction(get_object_files_for_test)
|
102 | 179 |
|
103 |
| - |
104 | 180 | # Rule to add a libc unittest.
|
105 | 181 | # Usage
|
106 | 182 | # add_libc_unittest(
|
|
0 commit comments