This is an archive of the discontinued LLVM Phabricator instance.

[CMake][DFSan] Don't use cat as it's not available on Windows
AcceptedPublic

Authored by phosek on Jan 27 2020, 7:27 PM.

Details

Reviewers
beanz
smeenai
Summary

We shouldn't be using cat in the build since this command isn't
available on Windows (unless installed as part of gnuwin32). Rather,
we use a pure CMake approach.

Diff Detail

Event Timeline

phosek created this revision.Jan 27 2020, 7:27 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 27 2020, 7:27 PM
Herald added subscribers: llvm-commits, Restricted Project, mgorny. · View Herald Transcript
smeenai accepted this revision.Jan 27 2020, 7:34 PM

At some point it would be nice to deduplicate these sorts of utility scripts across all LLVM projects, now that we're on the monorepo.

This revision is now accepted and ready to land.Jan 27 2020, 7:34 PM

lit has a builtin cat command, is there some way to use it here instead of re-implementing the functionality?

lit has a builtin cat command, is there some way to use it here instead of re-implementing the functionality?

I don't think that LLVM build should depend on lit. Ideally, this would be a CMake command, which is currently not the case, but I found a way to emulate it using a combination of file(READ ...), file(APPEND ...) and configure_file(...): https://stackoverflow.com/a/15283110. @smeenai would you prefer that solution?

http://llvm.org/docs/GettingStarted.html#software currently says exactly the opposite of what this patch is doing: cat is required to build LLVM, python is optional. Is that out of date?

http://llvm.org/docs/GettingStarted.html#software currently says exactly the opposite of what this patch is doing: cat is required to build LLVM, python is optional. Is that out of date?

Does that apply to runtimes as well? The way I ran into this was building a complete Clang toolchain on Windows (just build, not running tests) without having GnuWin32 installed, and this was the only issue. Looking around the tree, I noticed that libc++ already uses this approach https://github.com/llvm/llvm-project/blob/master/libcxx/include/CMakeLists.txt#L186 hence following the same pattern here, but I'm happy to use a different approach if that's preferred.

Does that apply to runtimes as well?

I really don't know the answer here; I've never tried to build LLVM without python. I'm willing to believe the documentation is just wrong.

phosek updated this revision to Diff 241836.Jan 31 2020, 3:52 PM
phosek edited the summary of this revision. (Show Details)

I've tried the pure CMake approach and seems to be working well so I'm inclined to land this version unless there're any objections.

If the input files change, is this gonna automatically trigger a CMake reconfigure? (If not, you'd potentially end up with stale output.)

An alternative that doesn't depend on Python would be to use cat on Unix and type on Windows, though you should confirm that PowerShell is happy with type as well (I know it'll work with cmd).