This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [test] [profile] Add an .exe suffix to some temp executables
ClosedPublic

Authored by mstorsjo on Apr 12 2023, 1:39 PM.

Details

Summary

Mingw toolchains implicitly add an .exe suffix if the output linked
file doesn't have a suffix. In many cases the extra suffix doesn't
cause any issues, but in some tests, this discrepancy between expected
output file name and actual output file does cause issues.

In one test, a later rm command fails to remove the executable since it
doesn't have the expected name. (Alternatively the rm command could use
a wildcard.)

In another test, the executables that are run with a ./ prefix doesn't
manage to resolve the executable when it has an extra implicit .exe
suffix.

Diff Detail

Event Timeline

mstorsjo created this revision.Apr 12 2023, 1:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 1:39 PM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
mstorsjo requested review of this revision.Apr 12 2023, 1:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 1:39 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
alvinhochun added inline comments.Apr 19 2023, 6:07 AM
compiler-rt/test/profile/instrprof-basic.c
45

Do you know is there any reason why this test case needs to remove the exe but the previous test cases don't? Can we instead just remove this rm command?

mstorsjo added inline comments.Apr 19 2023, 9:00 AM
compiler-rt/test/profile/instrprof-basic.c
45

In this test, the profile data files are written in the same directory as the executable, and llvm-profdata reads all files the directory. If the executable is left there, it fails to read that file.

vitalybuka added inline comments.Apr 19 2023, 10:58 AM
compiler-rt/test/profile/instrprof-basic.c
45

can you keep everything as is and just do

rm -f %t.dir4/merge4*
compiler-rt/test/profile/instrprof-tmpdir.c
7

why do you need exe here?
isn't windows will implicitly add .exe when you run ./binary ?

mstorsjo added inline comments.Apr 19 2023, 11:34 AM
compiler-rt/test/profile/instrprof-basic.c
45

Yeah, that should work too

compiler-rt/test/profile/instrprof-tmpdir.c
7

Yes, e.g. cmd.exe does that, but here, we have Python executing the commands.

In most cases, the executable has got some suffix (e.g. %t expanding to something with .tmp as suffix); in those cases there’s no extra suffix added - but for a plain name like binary here, we’ve got this mismatch.

mstorsjo added inline comments.Apr 19 2023, 11:44 AM
compiler-rt/test/profile/instrprof-tmpdir.c
7

Actually, the difference is even more subtle… In most tests, we execute e.g. %t/binary, but here we try to execute ./binary. The Python executor seems to handle adding an implicit extra .exe if needed for finding the executable with an absolute path from %t, but not with ./.

mstorsjo added inline comments.Apr 19 2023, 11:49 AM
compiler-rt/test/profile/instrprof-tmpdir.c
7

So I guess writing %run %t/binary here would work too (it doesn’t seem to remove anything of what this test tries to test); would you prefer that? That would be more alike most often tests.

vitalybuka added inline comments.Apr 19 2023, 12:17 PM
compiler-rt/test/profile/instrprof-tmpdir.c
7

Yes, I would prefer to avoid .exe on platforms where it's not needed.
Same applies to merge4

mstorsjo updated this revision to Diff 515045.Apr 19 2023, 12:38 PM

Updated to not add .exe suffixes explicitly, but work around the ambiguity differently.

vitalybuka accepted this revision.Apr 19 2023, 2:18 PM
This revision is now accepted and ready to land.Apr 19 2023, 2:18 PM
This revision was landed with ongoing or failed builds.Apr 19 2023, 2:35 PM
This revision was automatically updated to reflect the committed changes.