Skip to content
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 "NFC: Make clang resource headers an interface library (#88317)" #89266

Closed

Conversation

etcwilde
Copy link
Contributor

This reverts commit 8d468c1.

@ayermolo reports seeing the following error when the clang-resource-headers are a library instead of a custom target:

CMake Error at CMakeLists.txt:86 (get_property):
  get_property could not find TARGET clang-resource-headers.  Perhaps it has
  not yet been created.

I don't see this line in the LLVM repository, and I'm not sure how it worked as a custom target since this change doesn't affect whether or not the CMake target is generated, nor does it impact the order that targets are created in.

@llvmbot llvmbot added clang Clang issues not falling into any other category lldb backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Apr 18, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 18, 2024

@llvm/pr-subscribers-lldb

@llvm/pr-subscribers-backend-x86

Author: Evan Wilde (etcwilde)

Changes

This reverts commit 8d468c1.

@ayermolo reports seeing the following error when the clang-resource-headers are a library instead of a custom target:

CMake Error at CMakeLists.txt:86 (get_property):
  get_property could not find TARGET clang-resource-headers.  Perhaps it has
  not yet been created.

I don't see this line in the LLVM repository, and I'm not sure how it worked as a custom target since this change doesn't affect whether or not the CMake target is generated, nor does it impact the order that targets are created in.


Full diff: https://github.com/llvm/llvm-project/pull/89266.diff

2 Files Affected:

  • (modified) clang/lib/Headers/CMakeLists.txt (+2-6)
  • (modified) lldb/cmake/modules/LLDBFramework.cmake (+1-1)
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index e6ae4e19e81db9..97104ccd8db59c 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -437,14 +437,14 @@ foreach( f ${generated_files} )
 endforeach( f )
 
 function(add_header_target target_name file_list)
-  add_library(${target_name} INTERFACE ${file_list})
+  add_custom_target(${target_name} DEPENDS ${file_list})
   set_target_properties(${target_name} PROPERTIES
     FOLDER "Misc"
     RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 endfunction()
 
 # The catch-all clang-resource-headers target
-add_library(clang-resource-headers INTERFACE ${out_files})
+add_custom_target("clang-resource-headers" ALL DEPENDS ${out_files})
 set_target_properties("clang-resource-headers" PROPERTIES
   FOLDER "Misc"
   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
@@ -501,10 +501,6 @@ add_header_target("windows-resource-headers" ${windows_only_files})
 add_header_target("utility-resource-headers" ${utility_files})
 
 get_clang_resource_dir(header_install_dir SUBDIR include)
-target_include_directories(clang-resource-headers INTERFACE
-  $<BUILD_INTERFACE:${output_dir}>
-  $<INSTALL_INTERFACE:${header_install_dir}>)
-set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS clang-resource-headers)
 
 #############################################################
 # Install rules for the catch-all clang-resource-headers target
diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake
index f915839f6b45a5..81fc596ef4244e 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -119,7 +119,7 @@ add_custom_command(TARGET liblldb POST_BUILD
 if(NOT APPLE_EMBEDDED)
   if (TARGET clang-resource-headers)
     add_dependencies(liblldb clang-resource-headers)
-    set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,INTERFACE_INCLUDE_DIRECTORIES>)
+    set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,RUNTIME_OUTPUT_DIRECTORY>)
   else()
     set(clang_resource_headers_dir ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}/include)
     if(NOT EXISTS ${clang_resource_headers_dir})

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 18, 2024

@llvm/pr-subscribers-clang

Author: Evan Wilde (etcwilde)

Changes

This reverts commit 8d468c1.

@ayermolo reports seeing the following error when the clang-resource-headers are a library instead of a custom target:

CMake Error at CMakeLists.txt:86 (get_property):
  get_property could not find TARGET clang-resource-headers.  Perhaps it has
  not yet been created.

I don't see this line in the LLVM repository, and I'm not sure how it worked as a custom target since this change doesn't affect whether or not the CMake target is generated, nor does it impact the order that targets are created in.


Full diff: https://github.com/llvm/llvm-project/pull/89266.diff

2 Files Affected:

  • (modified) clang/lib/Headers/CMakeLists.txt (+2-6)
  • (modified) lldb/cmake/modules/LLDBFramework.cmake (+1-1)
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index e6ae4e19e81db9..97104ccd8db59c 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -437,14 +437,14 @@ foreach( f ${generated_files} )
 endforeach( f )
 
 function(add_header_target target_name file_list)
-  add_library(${target_name} INTERFACE ${file_list})
+  add_custom_target(${target_name} DEPENDS ${file_list})
   set_target_properties(${target_name} PROPERTIES
     FOLDER "Misc"
     RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 endfunction()
 
 # The catch-all clang-resource-headers target
-add_library(clang-resource-headers INTERFACE ${out_files})
+add_custom_target("clang-resource-headers" ALL DEPENDS ${out_files})
 set_target_properties("clang-resource-headers" PROPERTIES
   FOLDER "Misc"
   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
@@ -501,10 +501,6 @@ add_header_target("windows-resource-headers" ${windows_only_files})
 add_header_target("utility-resource-headers" ${utility_files})
 
 get_clang_resource_dir(header_install_dir SUBDIR include)
-target_include_directories(clang-resource-headers INTERFACE
-  $<BUILD_INTERFACE:${output_dir}>
-  $<INSTALL_INTERFACE:${header_install_dir}>)
-set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS clang-resource-headers)
 
 #############################################################
 # Install rules for the catch-all clang-resource-headers target
diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake
index f915839f6b45a5..81fc596ef4244e 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -119,7 +119,7 @@ add_custom_command(TARGET liblldb POST_BUILD
 if(NOT APPLE_EMBEDDED)
   if (TARGET clang-resource-headers)
     add_dependencies(liblldb clang-resource-headers)
-    set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,INTERFACE_INCLUDE_DIRECTORIES>)
+    set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,RUNTIME_OUTPUT_DIRECTORY>)
   else()
     set(clang_resource_headers_dir ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}/include)
     if(NOT EXISTS ${clang_resource_headers_dir})

@etcwilde
Copy link
Contributor Author

@ayermolo, one idea might be to see if clang-resource-headers is in the install distribution list? I'm not seeing a matching get_property in a CMakeLists.txt that matches the above error exactly, so I'm not sure how to reproduce this or how you're picking up the clang-resource-headers target.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving it in case it needs to be merged, but I think that we should try to determine how it is breaking. This change feels like it should be correct and is a pretty good cleanup, so I would prefer that fix forward rather than revert.

@ayermolo
Copy link
Contributor

Thanks.
It's failing internally in our automatic multi stage build. Trying to dig into it as part of my oncall. :)

@ayermolo
Copy link
Contributor

Seems like an issue is our internal CMakeLists that

set (LIBS ${CLANG_EXPORTED_TARGETS} ${LLD_EXPORTED_TARGETS} ${LLVM_AVAILABLE_LIBS})
foreach(LIB ${LIBS})
  get_property(TYPE TARGET ${LIB} PROPERTY TYPE)

@ayermolo
Copy link
Contributor

ayermolo commented Apr 20, 2024

Fixed our internal foobar yesterday. Can close this. Thanks

@etcwilde
Copy link
Contributor Author

Great, glad to hear that you figured out what was happening. I wasn't sure how the target would end up in the clang-export list and not be defined since the bit of code that adds it to the clang-export list isn't conditionalized any differently than the creation of the target itself.

@etcwilde etcwilde closed this Apr 21, 2024
@etcwilde etcwilde deleted the ewilde/revert-clang-header-library branch April 22, 2024 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category lldb
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants