This is an archive of the discontinued LLVM Phabricator instance.

[MinGW] Add option for disabling looking for a mingw gcc in PATH
AbandonedPublic

Authored by mstorsjo on Apr 1 2018, 2:39 PM.

Details

Summary

This avoids looking for a mingw gcc to use as sysroot, preferring the clang installation itself over a similar gcc found in the path.

The option name, --ignore-gcc, might not be ideal - any suggestions for a better name?

Currently, I'm injecting a --sysroot parameter via a wrapper script, forcing the clang invocation to use clang_bin/../triple as sysroot, even if there's a similar named cross gcc elsewhere in PATH. With this option, I wouldn't need to use a wrapper script to manually set the sysroot.

Diff Detail

Event Timeline

mstorsjo created this revision.Apr 1 2018, 2:39 PM
mstorsjo added inline comments.Apr 2 2018, 12:13 AM
include/clang/Driver/Options.td
1735

Perhaps --ignore-gcc-toolchain would be better?

rnk accepted this revision.Apr 3 2018, 10:56 AM

Seems reasonable, looks good.

This revision is now accepted and ready to land.Apr 3 2018, 10:56 AM
In D45152#1055871, @rnk wrote:

Seems reasonable, looks good.

Any opinion on the wording of the option name?

rnk added a comment.Apr 3 2018, 1:46 PM
In D45152#1055871, @rnk wrote:

Seems reasonable, looks good.

Any opinion on the wording of the option name?

Maybe what we're trying to do is find the sysroot relative to clang, so an option name phrased along those lines makes more sense? --clang-in-sysroot-bin? --from-sysroot-bin? --assume-sysroot-bin? --in-sysroot-bin?

In D45152#1056134, @rnk wrote:
In D45152#1055871, @rnk wrote:

Seems reasonable, looks good.

Any opinion on the wording of the option name?

Maybe what we're trying to do is find the sysroot relative to clang, so an option name phrased along those lines makes more sense? --clang-in-sysroot-bin? --from-sysroot-bin? --assume-sysroot-bin? --in-sysroot-bin?

That sounds sensible - and positive options is often better than negated/ignore etc. I think I prefer --assume-sysroot-bin out of those.

martell added a comment.EditedApr 4 2018, 3:26 PM

@mstorsjo I would much prefer to detect the clang sysroot first and if that exists just ignore the gcc one.
Most of the time clang and gcc will be in the same bin folder and in the case where the clang sysroot with mingw prefix folders is not found we can just default back to the default gcc behavior.
This should cover the use case for existing gcc users while not blocking us to move forward with clang only toolchains.
If someone really wants to ignore the clang sysroot with mingw folders we could add a flag for that and not the other way around.
What are your thoughts here?

Though I do like the idea of having an --assume-sysroot-bin as an option for all toolchains

@mstorsjo I would much prefer to detect the clang sysroot first and if that exists just ignore the gcc one.
Most of the time clang and gcc will be in the same bin folder and in the case where the clang sysroot with mingw prefix folders is not found we can just default back to the default gcc behavior.
This should cover the use case for existing gcc users while not blocking us to move forward with clang only toolchains.

That's probably an even better idea - I'll give that a try.

If someone really wants to ignore the clang sysroot with mingw folders we could add a flag for that and not the other way around.
What are your thoughts here?

I guess that could be useful in theory, but I'd hold off adding that until there's a concrete need for that case (it sounds quite contrieved to me, and there's always the --sysroot= option).

Though I do like the idea of having an --assume-sysroot-bin as an option for all toolchains

Well ideally all toolchains should use similar logic for finding sysroots, except for cases where they by design are different. I haven't looked for how many other cases of similar logic there is.

mstorsjo abandoned this revision.Apr 18 2018, 11:45 PM

D45504 fixed the same issue in a better way.