This is an archive of the discontinued LLVM Phabricator instance.

Make Gentoo GNU GCC Config override whitespace tolerant
ClosedPublic

Authored by erichkeane on Apr 12 2017, 4:14 PM.

Details

Summary

The config-*triple* file handling isn't tolerant of leading/trailing whitespace, making it not terribly obvious when a single extraneous tab/space/etc will cause the override to be ignored. This patch simply trims the lines to ensure that it is tolerant of whitespace.

Diff Detail

Event Timeline

erichkeane created this revision.Apr 12 2017, 4:14 PM
erichkeane added a subscriber: bkramer.
craig.topper added inline comments.Apr 12 2017, 4:24 PM
lib/Driver/ToolChains/Gnu.cpp
2176

Can we just do

Line = Line.trim()

so we won't have an extra StringRef and no one can misuse the untrimmed on in the future.

erichkeane updated this revision to Diff 95054.Apr 12 2017, 4:27 PM

Oops, yeah, good suggestion.

mgorny accepted this revision.Apr 14 2017, 7:22 AM

Is there any specific reason you need this? Since the file is autogenerated, I don't think it matters very much to allow extra whiespace. But then, I do not think it hurts, so feel free to do it. The code LGTM; note that I haven't tested it, however.

This revision is now accepted and ready to land.Apr 14 2017, 7:22 AM

Is there any specific reason you need this? Since the file is autogenerated, I don't think it matters very much to allow extra whiespace. But then, I do not think it hurts, so feel free to do it. The code LGTM; note that I haven't tested it, however.

In my case, a misbehaving copy of SVN caused the test for this to have a '\r\n' line ending on Windows. I fixed my SVN, but also realized that tolerance for whitespace might be valuable, particularly since a human might decide to change this without the gcc-config tool and neglect a trailing space. It scared me that this was a condition where it would APPEAR to work well (ie, configure it to the 'latest', but not realize it is being ignored), then be surprised later.

Well, I've just checked gcc-config sources and it seems that it sources the file through bash, and gets the resulting ${CURRENT}. While I don't think we ought to do complete bash support here, I guess allowing the same degree of whitespace bash does makes sense.

erichkeane closed this revision.Apr 14 2017, 2:29 PM

Forgot the "DifferentialRevision" in the commit message, but added it as related here.