This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang
ClosedPublic

Authored by beanz on Oct 2 2015, 4:37 PM.

Details

Summary

Many small improvements to LLVM_BUILD_EXTERNAL_COMPILER_RT.

  • Works correctly with Ninja by working around CMake Bug 14771 (https://cmake.org/Bug/view.php?id=14771)
  • Has install-compiler-rt target, and installs as part of the default install target
  • Sets the install paths properly so that it matches the non-standalone build
  • Only generate the test targets if(LLVM_INCLUDE_TESTS)

Diff Detail

Repository
rL LLVM

Event Timeline

beanz updated this revision to Diff 36409.Oct 2 2015, 4:37 PM
beanz retitled this revision from to [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang.
beanz updated this object.
beanz added reviewers: samsonov, Bigcheese.
samsonov added inline comments.Oct 5 2015, 10:24 AM
runtime/CMakeLists.txt
33 ↗(On Diff #36409)

Should this also be named cmake_3_4_USES_TERMINAL_OPTIONS?

40 ↗(On Diff #36409)

This one is later re-defined from ExternalProject_Get_Property. Does it provide the same value there?

42 ↗(On Diff #36409)

Where do you use this target?

47 ↗(On Diff #36409)

Why do you need these deps?

71 ↗(On Diff #36409)

Why did you remove -DCOMPILER_RT_ENABLE_WERROR=ON? I think it's fine to keep it enabled, as it's ok to ensure that ToT Clang builds ToT compiler-rt with no warnings.

beanz added a comment.Oct 5 2015, 10:47 AM

I will send updated patches shortly.

Comments inline below.

runtime/CMakeLists.txt
33 ↗(On Diff #36409)

This was used in an earlier iteration to pass USES_TERMINAL into a call to ExternalProject_Add_Step I will remove it.

40 ↗(On Diff #36409)

Yep, it can be removed.

42 ↗(On Diff #36409)

That is a convenience target for clearing out the compiler-rt directory. It isn't strictly needed, but I have found it (and the bootstrap-clear) to be useful.

Particularly as I've been changing which files are generated by the compiler-rt build and where they end up it is nice to be able to nuke the build directory.

47 ↗(On Diff #36409)

Specifying those deps makes it so that if llvm-config or clang change compiler-rt gets cleaned out and rebuilt.

71 ↗(On Diff #36409)

I'm trying to set the minimal set of options required to make compiler-rt build. Any additional options can be passed in via CLANG_COMPILER_RT_CMAKE_ARGS.

I think that if we expect COMPILER_RT_ENABLE_WERROR to be the way everyone is building, we should make that the default in compiler-rt, not pass it in here.

beanz updated this revision to Diff 36532.Oct 5 2015, 11:06 AM
  • Cleanup based on feedback from samsonov

I'm a CMake ignoramus but functionally if I'm building a Clang cross-compiler, I'd want a cross-built compiler-rt but not run its tests even if LLVM_INCLUDE_TESTS is on. Does that make sense? If so, does this change make that work properly?
Thanks...

beanz added a comment.Oct 5 2015, 11:29 AM

probinson,

Not by itself, but this could be used as a step in that direction. The CLANG_COMPILER_RT_CMAKE_ARGS variable can be used to configure how compiler-rt is built with a great deal of flexibility, but the goal of this patch is to try and closely match how compiler-rt builds in-tree today.

-Chris

samsonov added inline comments.Oct 7 2015, 5:40 PM
runtime/CMakeLists.txt
41 ↗(On Diff #36532)

So, that's the target that you can invoke manually to clean compiler-rt build?

46 ↗(On Diff #36532)

Hm? But "compiler-rt" target also depends on clang and llvm-config.

69 ↗(On Diff #36532)

I thought we only refer to COMPILER_RT_INSTALL_PATH in compiler-rt's CMake. Do we actually need CMAKE_INSTALL_PREFIX there as well?

70 ↗(On Diff #36532)

Disagree - we can't set COMPILER_RT_ENABLE_WERROR in compiler-rt's CMake, because standalone compiler-rt can be built with any compiler in the world, which we don't control. OTOH, if we *know* we're building it with trunk Clang, having it -Werror-clean is smth. we can enforce. It's also consistent with what autoconf did previously.

78 ↗(On Diff #36532)

This is also convenience target, right?

beanz added inline comments.Oct 8 2015, 10:47 AM
runtime/CMakeLists.txt
41 ↗(On Diff #36532)

Yes.

46 ↗(On Diff #36532)

It should. We need it to rebuild whenever clang and llvm-config change.

Although it just occurred to me that I also need to make sure that the clearing happens before compiler-rt gets built, so there will need to be a dependency on that too... I'll figure that out.

69 ↗(On Diff #36532)

I don't think we're actually using it in compiler-rt today, but I think that passing it through is a good idea so that if in the future compiler-rt ever uses CMAKE_INSTALL_PREFIX it will be properly populated.

70 ↗(On Diff #36532)

At the very least if we do that it should be tied to LLVM_ENABLE_WERROR, not just defaulted to On. None of our projects default WERROR to On anywhere. While I agree building with Werror is desirable, we shouldn't be defaulting it on, and we certainly shouldn't be doing it in a way that makes it so the user has to edit the build files in order to turn it off.

78 ↗(On Diff #36532)

Yes.

beanz updated this revision to Diff 36897.Oct 8 2015, 2:58 PM

Updates to fix dependency mapping.

Compiler-rt will be cleaned and rebuilt if clang changes and reconfigured if llvm-config or clang changes.

samsonov accepted this revision.Oct 9 2015, 9:26 PM
samsonov edited edge metadata.

Looks pretty good. I'm still not convinced with your -Werror arguments, and will be unavailable during the next week, so feel free to land it, provided we'll return to the discussion later :)

Thank you!

runtime/CMakeLists.txt
62 ↗(On Diff #36897)

Why should it be tied to LLVM_ENABLE_WERROR? LLVM_ENABLE_WERROR only makes sense if host compiler is known to be "good" and we want it to build LLVM w/o errors. Here, the compiler is *always* good. As for the user, we don't give her the option to define the compiler that would build compiler-rt: it is set to be just-built Clang. I can imagine the test case which verifies that just-built Clang compiles given source file w/o warnings. We can as well keep a large subproject just-built-Clang clean.

This revision is now accepted and ready to land.Oct 9 2015, 9:26 PM
This revision was automatically updated to reflect the committed changes.