This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt cmake] Support overriding llvm-config query results
ClosedPublic

Authored by mgorny on Aug 29 2016, 2:44 PM.

Details

Summary

Support overriding LLVM_* variables obtained from llvm-config when doing stand-alone builds. The override of LLVM_MAIN_SRC_DIR is necessary to provide LLVM sources when the initial directory used to build LLVM does
no longer exist when compiler-rt is built stand-alone. This is especially the case when building the projects separately in temporary directories with unpredictable names.

The code is based on existing CMakeLists.txt from clang. Alike clang, it extends the override to all queried variables.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny updated this revision to Diff 69616.Aug 29 2016, 2:44 PM
mgorny retitled this revision from to [compiler-rt cmake] Support overriding llvm-config query results.
mgorny updated this object.
mgorny added reviewers: samsonov, Hahnfeld.
mgorny added a subscriber: cfe-commits.

SGTM, I don't see any drawback

cmake/Modules/CompilerRTUtils.cmake
200 ↗(On Diff #69616)

Is BINARY_DIR reserved in CMake? Otherwise I would prefer to name this consistently...

mgorny added inline comments.Sep 12 2016, 7:33 AM
cmake/Modules/CompilerRTUtils.cmake
200 ↗(On Diff #69616)

I don't think it is. I used that name for consistency with llvm-config options (naming --obj-root BINARY_DIR actually confused me a lot at a first glance), and for consistency with the code used in clang (which names variables exactly like this).

Not saying I like changing names like this but I think if any change is due, we should do it everywhere consistently.

beanz accepted this revision.Sep 12 2016, 12:01 PM
beanz edited edge metadata.

One comment below, otherwise LGTM.

cmake/Modules/CompilerRTUtils.cmake
200 ↗(On Diff #69616)

If you want to be consistent with the options (which makes sense), you should name it OBJ_ROOT, and also rename TOOLS_BINARY_DIR to BINDIR, LIBRARY_DIR to LIBDIR, and MAIN_SRC_DIR to SRC_ROOT. Being partially consistent doesn't make sense.

This revision is now accepted and ready to land.Sep 12 2016, 12:01 PM
mgorny updated this revision to Diff 71040.Sep 12 2016, 12:20 PM
mgorny edited edge metadata.
mgorny marked 3 inline comments as done.Sep 12 2016, 12:20 PM

And done.

And done.

I think @beanz meant to actually do the renames for consistency... Sorry for the confusion!

And done.

I think @beanz meant to actually do the renames for consistency... Sorry for the confusion!

I know but I feel like it's a topic for a separate patch, so I just went back for the current names.

I'm not home right now but furthermore, I suspect that those variables might be actually cross-used between LLVM and compiler-rt, and so we'd have to change them consistently everywhere.

You cannot rename the variables that start with LLVM_*, but the variables without the leading LLVM can be renamed to whatever makes sense, or left as-is. I'm fine with either way.

The variables starting with LLVM_* are effectively public interface to the build system, and renaming them would be very difficult.

This revision was automatically updated to reflect the committed changes.

Thanks again. I've left them as-is and committed.