-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "[libc][cmake] Tidy compiler includes (#66783)" #66822
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit a35a3b7. This broke libc benchmarks.
Breakage example : https://lab.llvm.org/buildbot/#/builders/223/builds/27751 |
@llvm/pr-subscribers-libc ChangesThis reverts commit a35a3b7. This broke libc benchmarks. Full diff: https://github.com/llvm/llvm-project/pull/66822.diff 5 Files Affected:
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 414be906336bf3f..0cec6fc07d982b4 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -7,11 +7,6 @@ endif()
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
NO_POLICY_SCOPE)
-# `llvm-project/llvm/CMakeLists.txt` adds the following directive
-# `include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})`
-# We undo it to be able to precisely control what is getting included.
-set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "")
-
# Default to C++17
set(CMAKE_CXX_STANDARD 17)
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index c10b81f1af8cba3..994437f55d27407 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -151,6 +151,7 @@ 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})
@@ -188,10 +189,13 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${gpu_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(${gpu_target_name} PRIVATE ${include_dirs})
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()
@@ -257,8 +261,7 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(${fq_target_name} PRIVATE ${include_dirs})
add_dependencies(${fq_target_name}
${full_deps_list} ${packaged_gpu_names} ${stub_target_name})
@@ -282,8 +285,7 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${internal_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(${internal_target_name} PRIVATE ${include_dirs})
if(full_deps_list)
add_dependencies(${internal_target_name} ${full_deps_list})
endif()
@@ -367,8 +369,12 @@ function(create_object_library fq_target_name)
${ADD_OBJECT_SRCS}
${ADD_OBJECT_HDRS}
)
- target_include_directories(${fq_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(
+ ${fq_target_name}
+ PRIVATE
+ ${LIBC_SOURCE_DIR}
+ ${LIBC_INCLUDE_DIR}
+ )
target_compile_options(${fq_target_name} PRIVATE ${compile_options})
endif()
@@ -627,6 +633,7 @@ 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)
@@ -663,8 +670,7 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${internal_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(${internal_target_name} PRIVATE ${include_dirs})
add_dependencies(${internal_target_name} ${full_deps_list})
target_link_libraries(${internal_target_name} ${full_deps_list})
@@ -678,8 +684,7 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(${fq_target_name} PRIVATE ${include_dirs})
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 3d02a37e96db51f..e1286b4ab963189 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -148,8 +148,12 @@ function(create_libc_unittest fq_target_name)
${LIBC_UNITTEST_SRCS}
${LIBC_UNITTEST_HDRS}
)
- target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(
+ ${fq_build_target_name}
+ PRIVATE
+ ${LIBC_SOURCE_DIR}
+ ${LIBC_INCLUDE_DIR}
+ )
target_compile_options(
${fq_build_target_name}
PRIVATE -fpie ${LIBC_COMPILE_OPTIONS_DEFAULT}
@@ -382,8 +386,12 @@ function(add_libc_fuzzer target_name)
${LIBC_FUZZER_SRCS}
${LIBC_FUZZER_HDRS}
)
- target_include_directories(${fq_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(
+ ${fq_target_name}
+ PRIVATE
+ ${LIBC_SOURCE_DIR}
+ ${LIBC_INCLUDE_DIR}
+ )
target_link_libraries(${fq_target_name} PRIVATE
${link_object_files}
@@ -508,8 +516,12 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(
+ ${fq_build_target_name}
+ PRIVATE
+ ${LIBC_SOURCE_DIR}
+ ${LIBC_INCLUDE_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.
@@ -671,8 +683,12 @@ 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} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
- target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR})
+ target_include_directories(
+ ${fq_build_target_name}
+ PRIVATE
+ ${LIBC_SOURCE_DIR}
+ ${LIBC_INCLUDE_DIR}
+ )
target_compile_options(${fq_build_target_name}
PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} ${HERMETIC_TEST_COMPILE_OPTIONS})
diff --git a/libc/utils/HdrGen/CMakeLists.txt b/libc/utils/HdrGen/CMakeLists.txt
index 0ec1cba542d400d..0b1612e8a886ae6 100644
--- a/libc/utils/HdrGen/CMakeLists.txt
+++ b/libc/utils/HdrGen/CMakeLists.txt
@@ -14,7 +14,7 @@ add_tablegen(libc-hdrgen LIBC
PublicAPICommand.h
)
-target_include_directories(libc-hdrgen PRIVATE ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})
+target_include_directories(libc-hdrgen PRIVATE ${LIBC_SOURCE_DIR})
target_link_libraries(libc-hdrgen PRIVATE LibcTableGenUtil)
add_subdirectory(PrototypeTestGen)
diff --git a/libc/utils/LibcTableGenUtil/CMakeLists.txt b/libc/utils/LibcTableGenUtil/CMakeLists.txt
index dca6a7bb8306557..222f177ee2f7706 100644
--- a/libc/utils/LibcTableGenUtil/CMakeLists.txt
+++ b/libc/utils/LibcTableGenUtil/CMakeLists.txt
@@ -6,4 +6,3 @@ add_llvm_library(
LINK_COMPONENTS Support TableGen
)
target_include_directories(LibcTableGenUtil PUBLIC ${LIBC_SOURCE_DIR})
-target_include_directories(LibcTableGenUtil PRIVATE ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})
|
This was referenced Sep 20, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reverts commit a35a3b7. This broke libc benchmarks.