This is an archive of the discontinued LLVM Phabricator instance.

[Driver] allow target override containing . in executable name
ClosedPublic

Authored by dankm on Oct 5 2022, 10:04 AM.

Details

Summary

The gcc compatible driver has support for overriding the default
target based on the driver's executable name, for instance
x86_64-pc-linux-gnu-clang will set the default target to
x86_64-pc-linux-gnu.

Previously, this failed when the target contained a minor version, for
example x86_64-pc-freebsd13.1, so instead of finding the file's
stem, use the whole file name, but strip off any '.exe' from the tail.

Diff Detail

Event Timeline

dankm created this revision.Oct 5 2022, 10:04 AM

I'd like comments on this approach to handle target names with a . in them. My assumption is that the way it was done (by finding the filename stem) was to strip any ".exe" string on Windows, but there may be other reasons.

dankm published this revision for review.Oct 5 2022, 10:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 10:19 AM
dankm added a reviewer: dim.Oct 5 2022, 4:31 PM
dankm retitled this revision from RFC: [Driver] select alternative target containing . in executable name to [Driver] select alternative target containing . in executable name.Oct 21 2022, 12:19 PM
MaskRay added a comment.EditedOct 21 2022, 2:11 PM

The gcc compatible driver has support for selecting an alternative target based on the driver's executable name, for instance x86_64-unknown-linux-gnu-clang will set the target to linux on x86_64.

I think the somewhat canonical term is target override (not selecting an alternative target). This changes makes sense and I think it deserves a test in Driver/target-override.c (REQUIRE: shell is important for ln -s %clang ... to work).

Previously, this failed when the target contains a minor version, for example x86_64-unknown-freebsd13.1, so instead of finding the file's stem, use the whole file name, but strip off any '.exe' from the tail.

Mentioning the literal executable name helps readers understand the nature of the change. This change makes x86_64-pc-freebsd13.1-clang to be recognized as having a default target triple of x86_64-pc-freebsd13.1.

dankm added a comment.Oct 26 2022, 1:34 PM

Thanks for the feedback. I've added a testcase for this, I'll push that change and update the summary.

Thanks for the feedback. I've added a testcase for this, I'll push that change and update the summary.

Did you upload a new patch to the differential? I cannot see it.

dankm updated this revision to Diff 470918.Oct 26 2022, 1:40 PM

Added a simple testcase, and updated commit message.

dankm added a comment.Oct 26 2022, 1:40 PM

Thanks for the feedback. I've added a testcase for this, I'll push that change and update the summary.

Did you upload a new patch to the differential? I cannot see it.

I hadn't. I posted that comment and then pushed a new patch.

dankm retitled this revision from [Driver] select alternative target containing . in executable name to [Driver] allow target override containing . in executable name.Oct 26 2022, 1:42 PM
dankm edited the summary of this revision. (Show Details)
MaskRay accepted this revision.Oct 26 2022, 1:46 PM

Thanks!

This revision is now accepted and ready to land.Oct 26 2022, 1:46 PM
dankm added a comment.Oct 26 2022, 2:03 PM

Thanks! Since I don't have privileges to push, can you do that on my behalf?

This revision was automatically updated to reflect the committed changes.