This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Remove cmake glob for source files
AbandonedPublic

Authored by smeenai on Mar 24 2017, 7:29 PM.

Details

Summary

Globbing for source files is problematic because if a source file is
added or removed, the configuration won't be run again, and so the build
won't pick up on the added or removed file until the next configuration.
cmake's help explicitly recommends against the use of file(GLOB) to
collect a list of source files for the same reason. Switch to an
explicit list of files.

The glob for headers is left intact, partly because there are a ton of
them (courtesy of using GLOB_RECURSE), and partly because it shouldn't
affect building, since the header dependency tracking is handled
separately by cmake.

Event Timeline

smeenai created this revision.Mar 24 2017, 7:29 PM
EricWF edited edge metadata.Mar 27 2017, 6:45 PM

Thanks for fixing this. Sucks that we have to manually enumerate source files but this is the correct solution according to CMake.

Would it be easy to still use glob to verify that none of the source files have accidentally been forgotten?

lib/CMakeLists.txt
321–323

These globs should be fixed as well.

beanz edited edge metadata.Mar 28 2017, 11:06 AM

LLVM has a CMake module "LLVMProcessSources.cmake" which verifies that all source files are referenced in the CMakeLists file. Since it is part of the LLVM distributed modules, you can re-use it in libcxx.

smeenai planned changes to this revision.Mar 28 2017, 2:34 PM

I like the idea of verifying that all source files have been included. Will amend this accordingly. Thanks for the cmake pointer @beanz!

lib/CMakeLists.txt
321–323

Right, I missed this one.

smeenai updated this revision to Diff 115259.Sep 14 2017, 12:24 PM

Address comments

This depends on D37859 for the SOURCE_DIR parameter to llvm_check_source_file_list.

@rjmccall, this adds a libc++ build dependency on LLVM's cmake modules. There were some issues when @zturner had added a similar dependency for his work on lit. To confirm, Apple still cares about the use case of building libc++ without having any LLVM cmake modules available (either from source or from an LLVM installation), right?

I'll let Duncan answer that question.

beanz added a comment.Oct 5 2017, 9:20 AM

Building libcxx without LLVM's CMake modules is very important, not just to Apple. This is how several open source distributions work, and it would be a huge disservice to break this. Same is true for compiler-rt, libcxxabi, libunwind, etc.

Historically we've been drawing the line that building and running tests for runtime projects can require LLVM, but building the runtime libraries themselves must work without LLVM. I believe that is still the correct line to draw.

dexonsmith resigned from this revision.Oct 19 2020, 2:57 PM
dexonsmith added a reviewer: ldionne.

@rjmccall, this adds a libc++ build dependency on LLVM's cmake modules. There were some issues when @zturner had added a similar dependency for his work on lit. To confirm, Apple still cares about the use case of building libc++ without having any LLVM cmake modules available (either from source or from an LLVM installation), right?

We resolved our need for building libcxx without llvm during the monorepo transition (2019).

This patch isn't necessary anymore, as we don't use globing anymore. Let's abandon it to clean up the review queue.

This patch isn't necessary anymore, as we don't use globing anymore. Let's abandon it to clean up the review queue.

Actually, I misspoke. We still use it, but only in a few places. If you still feel that we should fix this, please rebase onto master and I will review. Otherwise, let's close this review.

smeenai abandoned this revision.Oct 28 2020, 1:11 PM