This is an archive of the discontinued LLVM Phabricator instance.

[clang][lld][cmake] Simplify header dirs
ClosedPublic

Authored by Ericson2314 on Jul 26 2022, 12:42 AM.

Details

Summary

We don't need to recompute the list LLVMConfig.cmake provides us.

When LLVM is being built, the list is two elements long: generated headers and headers from source.

When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources.

Diff Detail

Event Timeline

Ericson2314 created this revision.Jul 26 2022, 12:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2022, 12:42 AM
Herald added a subscriber: mgorny. · View Herald Transcript
Ericson2314 requested review of this revision.Jul 26 2022, 12:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2022, 12:42 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
sebastian-ne added inline comments.Jul 26 2022, 3:06 AM
clang/CMakeLists.txt
81

Do we need to add "${LLVM_BINARY_DIR}/include" here as well?

Ericson2314 added inline comments.Jul 26 2022, 7:59 AM
clang/CMakeLists.txt
81

Pretty sure we shouldn't be cause that should be one of the elements of the list when LLVM is also being built in this CMake invocation.

Ericson2314 edited the summary of this revision. (Show Details)Jul 26 2022, 8:00 AM
Ericson2314 added a subscriber: doyougnu.
sebastian-ne accepted this revision.Jul 27 2022, 2:23 AM

Looks good to me, I left three questions inline.

clang/CMakeLists.txt
81

The quotation marks went missing, is this intended? (Same in lld/CMakeLists.txt)

91

The quotation marks went missing, is this intended? (Same in lld/CMakeLists.txt)

133

The quotation marks went missing, is this intended? (Same in lld/CMakeLists.txt)

This revision is now accepted and ready to land.Jul 27 2022, 2:23 AM

@sebastian-ne I didn't quote it because it is a list, but this might be shell script habit sneaking through. I am not sure what is best for CMake.

Checking now, https://stackoverflow.com/questions/35847655/when-should-i-quote-cmake-variables says "If your variable contains a list you normally don't add quotes" but I am not comfortable with "normally don't add"-style reasoning :).

This revision was landed with ongoing or failed builds.Jul 28 2022, 4:36 PM
This revision was automatically updated to reflect the committed changes.

I tested this in my distro build setup, and reread the LLVM source to make sure the list was as I expected.

When LLVM is being built, the list is two elements long: generated headers and headers from source.

All these changes are guarded by if (CLANG_BUILT_STANDALONE), which means LLVM should already be built. What build configuration are you using where you needed this change?

@tstellar There wasn't a configuration necessitating these changes.

The CMake config file currently distinguishes a main include dir and secondary include dir, which feels to me like it is leaking the implementation details of which headers are generated or not. I was hoping by replacing the instances where those are used with the list one, we'd eventually be able to deprecate the two underlying variables and just have the list one left.