If --gcc-toolchain is specified, we should detect GCC installation there, and suppress other directories for detection.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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.
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.