This is an archive of the discontinued LLVM Phabricator instance.

[RFC] [MinGW] Implicitly add .exe suffix if not provided
ClosedPublic

Authored by mstorsjo on Dec 12 2019, 1:23 AM.

Details

Summary

GCC implicitly adds an .exe suffix if it is given an output file name, but the file name doesn't contain a suffix, and there are certain users of GCC that rely on this behaviour (and run into issues when trying to use Clang instead of GCC). And MSVC's cl.exe also does the same (but not link.exe).

However, GCC only does this when actually running on windows, not when operating as a cross compiler.

This was reported to me at https://github.com/mstorsjo/llvm-mingw/issues/60.

As GCC doesn't have this behaviour when cross compiling, we definitely shouldn't introduce the behaviour in such cases (as it would break at least as many cases as this fixes).

Is it worth adding such inconsistent behaviour (with two separate tests, one for running on windows and one elsewhere)?

Diff Detail

Event Timeline

mstorsjo created this revision.Dec 12 2019, 1:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2019, 1:23 AM
rnk added inline comments.Dec 12 2019, 10:37 AM
clang/lib/Driver/ToolChains/MinGW.cpp
164

Can you add what you wrote in the commit message as a comment here to explain the divergence in behavior based on the compiler's host OS? I can imagine that a future maintainer will try to make the code behave the same way regardless of host.

165

I think this can be spelled llvm::sys::path::has_extension.

mstorsjo updated this revision to Diff 233863.Dec 13 2019, 1:21 PM
mstorsjo marked 2 inline comments as done.

Added a code comment, using llvm::path::has_extension, added testcases.

rnk accepted this revision.Dec 16 2019, 2:29 PM

lgtm, thanks!

This revision is now accepted and ready to land.Dec 16 2019, 2:29 PM
This revision was automatically updated to reflect the committed changes.