This is an archive of the discontinued LLVM Phabricator instance.

[test-suite] Added llvm_target_prefix() command to set unique target prefix.
ClosedPublic

Authored by tra on Apr 22 2016, 11:30 AM.

Details

Summary

Instead of relying on magic to generate unique names, allow user to specify unique prefix for target names.
llvm_target_prefix() sets the prefix for targets created with llvm_singlesource()/llvm_multisource().

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 54681.Apr 22 2016, 11:30 AM
tra retitled this revision from to [test-suite] Make unique name generation more robust..
tra updated this object.
tra added reviewers: MatzeB, jmolloy.
tra added a subscriber: llvm-commits.
MatzeB edited edge metadata.Apr 22 2016, 11:50 AM

While the patch looks good to me, what about the alternative approach of just error out on a name clash? AFAIK the only clash we have is between SingleSource/Benchmarks/Shootout and SingleSource/Benchmarks/Shootout-C++ and I'd rather go for a low-tech solution like allowing to specify a prefix in the shootout CMakeFiles and throw an error on non-unique targets instead of going through all the trouble to automatically create unique names.

tra added a comment.Apr 22 2016, 1:16 PM

How about adding llvm_test_name_prefix() which would add given prefix to all targets generated within scope?
Default will remain empty, but for testsuites that have name clashes it would provide an easy way to make their names unique.
Or we can even require having prefix set before we call llvm_multisource(). With that in place we can remove unique name magic and error out on name clashes.

In D19423#409448, @tra wrote:

How about adding llvm_test_name_prefix() which would add given prefix to all targets generated within scope?
Default will remain empty, but for testsuites that have name clashes it would provide an easy way to make their names unique.
Or we can even require having prefix set before we call llvm_multisource(). With that in place we can remove unique name magic and error out on name clashes.

Yep that's what I had in mind. Though I think using a variable like TARGET_PREFIX instead of a function would be more in-line with the current way the singlesource()/multisource() are configured.

tra updated this revision to Diff 54716.Apr 22 2016, 1:57 PM
tra retitled this revision from [test-suite] Make unique name generation more robust. to [test-suite] Added llvm_target_prefix() command to set unique target prefix..
tra updated this object.
tra edited edge metadata.
MatzeB added inline comments.Apr 22 2016, 3:21 PM
cmake/modules/SingleMultiSource.cmake
17–24 ↗(On Diff #54716)

Is there a benefit in having a function here instead of just letting users set TARGET_PREFIX immediately?

26–47 ↗(On Diff #54716)

I just tried it and cmake errors out by itself if you create two (logical) targets with the same name if you set:
cmake_policy(SET CMP0002 NEW)

tra added a comment.Apr 22 2016, 3:40 PM
cmake/modules/SingleMultiSource.cmake
17–24 ↗(On Diff #54716)

None, other than separating end-user from the details of implementation.
Similarly to llvm_test_run()/llvm_test_verify() it does *something* (that user does not need to be aware of) to make llvm_multisource() do the right thing.

26–47 ↗(On Diff #54716)

It does error out, but having explicit "please set prefix" message may make experience of adding new tests somewhat less painful.

This revision was automatically updated to reflect the committed changes.