diff options
author | Guillaume Chatelet <gchatelet@google.com> | 2023-09-19 23:08:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 23:08:29 +0200 |
commit | a35a3b75b219247eb9ff6784d1a0fe562f72d415 (patch) | |
tree | affd89ab7c3160dfe48dab031b4c665942f11b6a /libc/cmake/modules | |
parent | be8c2df2b15b17ef7a409a95333f09b016fc4a7e (diff) | |
download | llvm-a35a3b75b219247eb9ff6784d1a0fe562f72d415.zip llvm-a35a3b75b219247eb9ff6784d1a0fe562f72d415.tar.gz llvm-a35a3b75b219247eb9ff6784d1a0fe562f72d415.tar.bz2 |
[libc][cmake] Tidy compiler includes (#66783)
We want to activate `llvm-header-guard` (#66477) but the current CMake
configuration includes paths that should be `isystem`. This PR restricts
the number of `-I` passed to the clang command line and correctly marks
the llvm libc include path as `isystem`.
Diffstat (limited to 'libc/cmake/modules')
-rw-r--r-- | libc/cmake/modules/LLVMLibCObjectRules.cmake | 31 | ||||
-rw-r--r-- | libc/cmake/modules/LLVMLibCTestRules.cmake | 32 |
2 files changed, 21 insertions, 42 deletions
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake index 994437f..c10b81f 100644 --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -151,7 +151,6 @@ function(_build_gpu_objects fq_target_name internal_target_name) ${ARGN} ) - set(include_dirs ${LIBC_SOURCE_DIR} ${LIBC_INCLUDE_DIR}) set(common_compile_options ${ADD_GPU_OBJ_COMPILE_OPTIONS}) if(NOT ADD_GPU_OBJ_CXX_STANDARD) set(ADD_GPU_OBJ_CXX_STANDARD ${CMAKE_CXX_STANDARD}) @@ -189,13 +188,10 @@ function(_build_gpu_objects fq_target_name internal_target_name) ) target_compile_options(${gpu_target_name} PRIVATE ${compile_options}) - target_include_directories(${gpu_target_name} PRIVATE ${include_dirs}) + target_include_directories(${gpu_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${gpu_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_definitions(${gpu_target_name} PRIVATE LIBC_COPT_PUBLIC_PACKAGING) - set_target_properties( - ${gpu_target_name} - PROPERTIES - CXX_STANDARD ${ADD_GPU_OBJ_CXX_STANDARD} - ) + set_target_properties(${gpu_target_name} PROPERTIES CXX_STANDARD ${ADD_GPU_OBJ_CXX_STANDARD}) if(ADD_GPU_OBJ_DEPENDS) add_dependencies(${gpu_target_name} ${ADD_GPU_OBJ_DEPENDS}) endif() @@ -261,7 +257,8 @@ function(_build_gpu_objects fq_target_name internal_target_name) target_compile_options(${fq_target_name} PRIVATE "SHELL:-Xclang -fembed-offload-object=${packaged_gpu_binary}") endforeach() - target_include_directories(${fq_target_name} PRIVATE ${include_dirs}) + target_include_directories(${fq_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR}) add_dependencies(${fq_target_name} ${full_deps_list} ${packaged_gpu_names} ${stub_target_name}) @@ -285,7 +282,8 @@ function(_build_gpu_objects fq_target_name internal_target_name) get_nvptx_compile_options(nvptx_options ${LIBC_GPU_TARGET_ARCHITECTURE}) target_compile_options(${internal_target_name} PRIVATE ${nvptx_options}) endif() - target_include_directories(${internal_target_name} PRIVATE ${include_dirs}) + target_include_directories(${internal_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${internal_target_name} PRIVATE ${LIBC_SOURCE_DIR}) if(full_deps_list) add_dependencies(${internal_target_name} ${full_deps_list}) endif() @@ -369,12 +367,8 @@ function(create_object_library fq_target_name) ${ADD_OBJECT_SRCS} ${ADD_OBJECT_HDRS} ) - target_include_directories( - ${fq_target_name} - PRIVATE - ${LIBC_SOURCE_DIR} - ${LIBC_INCLUDE_DIR} - ) + target_include_directories(${fq_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_options(${fq_target_name} PRIVATE ${compile_options}) endif() @@ -633,7 +627,6 @@ function(create_entrypoint_object fq_target_name) "${ADD_ENTRYPOINT_OBJ_FLAGS}" ${ADD_ENTRYPOINT_OBJ_COMPILE_OPTIONS} ) - set(include_dirs ${LIBC_SOURCE_DIR} ${LIBC_INCLUDE_DIR}) get_fq_deps_list(fq_deps_list ${ADD_ENTRYPOINT_OBJ_DEPENDS}) set(full_deps_list ${fq_deps_list} libc.src.__support.common) @@ -670,7 +663,8 @@ function(create_entrypoint_object fq_target_name) ${ADD_ENTRYPOINT_OBJ_HDRS} ) target_compile_options(${internal_target_name} BEFORE PRIVATE ${common_compile_options}) - target_include_directories(${internal_target_name} PRIVATE ${include_dirs}) + target_include_directories(${internal_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${internal_target_name} PRIVATE ${LIBC_SOURCE_DIR}) add_dependencies(${internal_target_name} ${full_deps_list}) target_link_libraries(${internal_target_name} ${full_deps_list}) @@ -684,7 +678,8 @@ function(create_entrypoint_object fq_target_name) ${ADD_ENTRYPOINT_OBJ_HDRS} ) target_compile_options(${fq_target_name} BEFORE PRIVATE ${common_compile_options} -DLIBC_COPT_PUBLIC_PACKAGING) - target_include_directories(${fq_target_name} PRIVATE ${include_dirs}) + target_include_directories(${fq_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR}) add_dependencies(${fq_target_name} ${full_deps_list}) target_link_libraries(${fq_target_name} ${full_deps_list}) endif() diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index e1286b4..3d02a37 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -148,12 +148,8 @@ function(create_libc_unittest fq_target_name) ${LIBC_UNITTEST_SRCS} ${LIBC_UNITTEST_HDRS} ) - target_include_directories( - ${fq_build_target_name} - PRIVATE - ${LIBC_SOURCE_DIR} - ${LIBC_INCLUDE_DIR} - ) + target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_options( ${fq_build_target_name} PRIVATE -fpie ${LIBC_COMPILE_OPTIONS_DEFAULT} @@ -386,12 +382,8 @@ function(add_libc_fuzzer target_name) ${LIBC_FUZZER_SRCS} ${LIBC_FUZZER_HDRS} ) - target_include_directories( - ${fq_target_name} - PRIVATE - ${LIBC_SOURCE_DIR} - ${LIBC_INCLUDE_DIR} - ) + target_include_directories(${fq_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_link_libraries(${fq_target_name} PRIVATE ${link_object_files} @@ -516,12 +508,8 @@ function(add_integration_test test_name) ) set_target_properties(${fq_build_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - target_include_directories( - ${fq_build_target_name} - PRIVATE - ${LIBC_SOURCE_DIR} - ${LIBC_INCLUDE_DIR} - ) + target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_options(${fq_build_target_name} PRIVATE -fpie -ffreestanding -fno-exceptions -fno-rtti ${INTEGRATION_TEST_COMPILE_OPTIONS}) # The GPU build requires overriding the default CMake triple and architecture. @@ -683,12 +671,8 @@ function(add_libc_hermetic_test test_name) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} #OUTPUT_NAME ${fq_target_name} ) - target_include_directories( - ${fq_build_target_name} - PRIVATE - ${LIBC_SOURCE_DIR} - ${LIBC_INCLUDE_DIR} - ) + target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) + target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_options(${fq_build_target_name} PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} ${HERMETIC_TEST_COMPILE_OPTIONS}) |