This is an archive of the discontinued LLVM Phabricator instance.

[test-suite] Prevent timeit and fpcmp from being rebuilt every time make is called.
ClosedPublic

Authored by mcrosier on Jan 6 2016, 2:33 PM.

Details

Reviewers
MatzeB
Summary

Internally, our build system has an option to build External tests in parallel by calling make per benchmark. Unfortunately, this causes a race condition because the timeit and fpcmp tools are built every time make is run (e.g., one instance of make tries to execute timeit, while another is rebuilding it).

This patch adds a custom_command level underneath the custom_targets for timeit and fpcmp to prevent the executables from being rebuilt every time make is called.

The custom_target rule will still be run every time, but the binaries will be detected as being up to date and skip rebuilding.

I’m a bit shaky on my CMake but I think this is the proper way to resolve the issue.

Please take a look.

Chad

Diff Detail

Event Timeline

mcrosier updated this revision to Diff 44159.Jan 6 2016, 2:33 PM
mcrosier retitled this revision from to [test-suite] Prevent timeit and fpcmp from being rebuilt every time make is called..
mcrosier updated this object.
mcrosier added a reviewer: MatzeB.
mcrosier set the repository for this revision to rL LLVM.
mcrosier added a subscriber: llvm-commits.
MatzeB accepted this revision.Jan 6 2016, 2:40 PM
MatzeB edited edge metadata.

My cmake-fu isn't that strong either. But using add_custom_command looks like the right thing to do. LGTM.

tools/CMakeLists.txt
1

Is this change necessary or just here by accident?

This revision is now accepted and ready to land.Jan 6 2016, 2:40 PM

I probable lack context but it is not clear to me why we have custom_target to begin with? Why aren't fpcmp and timeit just declared with add_executable for which the dependency would be correctly tracked?

MatzeB added a subscriber: MatzeB.Jan 6 2016, 3:08 PM

Because we need to compile then for the host machine, even if everything else is cross compiled to a different target machine.

I see, wouldn't the proper way would be to cross-compile the way we do for llvm-tblgen?

MatzeB added a comment.Jan 6 2016, 3:30 PM
In D15938#320936, @joker.eph wrote:

I see, wouldn't the proper way would be to cross-compile the way we do for llvm-tblgen?

Yes that might very well be the better solution. http://reviews.llvm.org/D15004 stands at the same conclusion. I just couldn't get it to work in an hour and decided to put something in that works right now. I'd be happy if someone with more cmake experience would help out here.

mcrosier added inline comments.Jan 7 2016, 5:48 AM
tools/CMakeLists.txt
1

As far as I've read while trying to find a way to compile the same source in two ways, this change to the dependency for timeit-target is necessary, because cmake somehow loses the ability to find the source file in the same directory unless specifically shown where it is.

mcrosier closed this revision.Jan 7 2016, 6:00 AM

Committed in r257059.