This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection
ClosedPublic

Authored by MaskRay on Mar 3 2021, 3:59 PM.

Details

Summary

If --gcc-toolchain is specified, we should detect GCC installation there, and suppress other directories for detection.

Diff Detail

Event Timeline

MaskRay requested review of this revision.Mar 3 2021, 3:59 PM
MaskRay created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2021, 3:59 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks @MaskRay for this clean up. I can't speak for all of Gentoo but please give me a couple of days to at least test this on Chrome OS.

Thanks. This looks just looks me untested and likely uneeded logic.

My notes about --gcc-toolchain= and --prefix (-B)

https://lore.kernel.org/linux-kbuild/20210303230708.l6pbk5o5nc2qa5of@google.com/

In the presence of --gcc-toolchain= (even if it equals $prefix/usr), the magic detection should be avoided.

mgorny accepted this revision.Mar 4 2021, 12:47 AM

Well, I think this was mostly 'just in case' condition, so I guess it's fine. Let's just wait for @manojgupta to give it some more testing.

This revision is now accepted and ready to land.Mar 4 2021, 12:47 AM

Well, I think this was mostly 'just in case' condition, so I guess it's fine. Let's just wait for @manojgupta to give it some more testing.

Thanks. I sent D97902 to improve the documentation. Dropping the special case makes it more consistent: if --gcc-toolchain is not empty, suppress sysroot GCC detection

With the special rule, it is: if --gcc-toolchain is $sysroot/usr, suppress sysroot GCC detection as well.

Clang -B and --gcc-toolchain have some weird behaviors. Hope you can share your opinions on https://lists.llvm.org/pipermail/cfe-dev/2021-March/067827.html

In Chrome OS, we currently both "-B" and "--prefix". "-B" points to binutils bin directory and the "--prefix" has the binutils directory + target suffix. Should we drop "-B" and still get the same behavior?

Sample invocation: '/usr/bin/clang++' '--sysroot=/usr/x86_64-cros-linux-gnu '-fcrash-diagnostics-dir=/tmp/clang_crash_diagnostics' '-fcommon' '-fstack-protector-strong' '-fPIE' '-pie' '-D_FORTIFY_SOURCE=2' '-fno-omit-frame-pointer' '--prefix=../../../../../../usr/libexec/gcc/x86_64-cros-linux-gnu/x86_64-cros-linux-gnu-' 'foo.o' '-o' 'main' '-B../../../../../../usr/libexec/gcc/x86_64-cros-linux-gnu' '-target' 'x86_64-cros-linux-gnu'

I am not yet able to test this change in Chrome OS thoroughly yet because of some CQ issues. But manually checking the command lines for a few common cases does not show any difference so far.

With the special rule, it is: if --gcc-toolchain is $sysroot/usr, suppress sysroot GCC detection as well.

Clang -B and --gcc-toolchain have some weird behaviors. Hope you can share your opinions on https://lists.llvm.org/pipermail/cfe-dev/2021-March/067827.html

Sure, I have replied on the thread with chrome os usage explanation. I also noticed that we also use "--gcc-toolchain" as well so the whole lot.

manojgupta accepted this revision.Mar 11 2021, 10:05 AM

@MaskRay I have verified that Chrome OS builds are not affected by this change.

@MaskRay I have verified that Chrome OS builds are not affected by this change.

Thank you for testing!

MaskRay edited the summary of this revision. (Show Details)Mar 11 2021, 10:10 AM