This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Add function for building native tool
ClosedPublic

Authored by smeenai on Mar 29 2019, 7:13 PM.

Details

Summary

Instead of duplicating functionality for building native versions of
tblgen and llvm-config, add a function to set up a native tool build.
This will also be used for llvm-nm in a follow-up.

This should be NFC for tblgen, besides the slightly different COMMENT
for the custom command (it'll display the tablegen target name instead
of always saying TableGen). For the native llvm-config, it's a behavior
change in that we'll use llvm_ExternalProject_BuildCmd instead of
constructing the build command manually, always build in Release, and
reference the correct binary path for multi-config generators. I believe
all of these changes to be bug fixes.

Event Timeline

smeenai created this revision.Mar 29 2019, 7:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2019, 7:13 PM
smeenai marked 2 inline comments as done.Mar 29 2019, 7:17 PM
smeenai added inline comments.
llvm/cmake/modules/TableGen.cmake
138

I have no idea why we make the native tblgen depend on the target's tblgen, but I didn't want to change that in this diff. I might try getting rid of it in a follow-up and seeing what happens.

148

With the new centralized function, we could consider adding this chaining in there (which would probably require moving the add_custom_target call into the function as well). However, I'm not sure how to do this chaining in a generic way without introducing unnecessary dependencies; for example, it would be really unfortunate if llvm-tblgen ended up depending on llvm-opt. USES_TERMINAL is the perfect solution to this problem in Ninja, but I don't know of any way to prevent targets from building in parallel on another generator without introducing an artificial dependency.

smeenai updated this revision to Diff 192956.Mar 29 2019, 7:30 PM
smeenai edited the summary of this revision. (Show Details)

Standardize COMMENT

phosek added inline comments.Mar 29 2019, 8:04 PM
llvm/cmake/modules/CrossCompile.cmake
73

Since both of these are required, wouldn't it be better to pass them as function arguments (i.e. function(build_native_tool target output_path_var))?

smeenai marked an inline comment as done.Apr 1 2019, 11:07 AM
smeenai added inline comments.
llvm/cmake/modules/CrossCompile.cmake
73

Yeah, that's fair. I like the keyword form cos it's clearer at call sites, but not having a way to enforce required arguments (besides just manually verifying them) is annoying. Plus DEPENDS might go away in a follow-up, at which point it would be only function arguments.

smeenai updated this revision to Diff 193138.Apr 1 2019, 11:27 AM

Address review comments

compnerd accepted this revision.Apr 2 2019, 8:37 AM

Took a couple of reads to make sure that nothing was really being changed, but seems so. LGTM.

This revision is now accepted and ready to land.Apr 2 2019, 8:37 AM
This revision was automatically updated to reflect the committed changes.