[all-commits] [llvm/llvm-project] 4c2da8: [Driver] Suppress GCC detection under -B

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Mar 19 15:42:39 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4c2da8641087f7b734337a6e6306329cd2535d60
      https://github.com/llvm/llvm-project/commit/4c2da8641087f7b734337a6e6306329cd2535d60
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-03-19 (Fri, 19 Mar 2021)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Driver/ToolChains/Gnu.cpp
    M clang/test/Driver/android-ndk-standalone.cpp
    M clang/test/Driver/android-standalone.cpp
    M clang/test/Driver/gcc-toolchain.cpp
    M clang/test/Driver/print-multi-directory.c

  Log Message:
  -----------
  [Driver] Suppress GCC detection under -B

In GCC, if `-B $prefix` is specified, `$prefix` is used to find executable files and startup files.
`$prefix/include` is added as an include search directory.

Clang overloads -B with GCC installation detection semantics which make the
behavior less predictable (due to the "largest GCC version wins" rule) and
interact poorly with --gcc-toolchain (--gcc-toolchain can be overridden by -B).

* `clang++ foo.cpp` detects GCC installation under `/usr`.
* `clang++ --gcc-toolchain=Inputs foo.cpp` detects GCC installation under `Inputs`.
* `clang++ -BA --gcc-toolchain=B foo.cpp` detects GCC installation under A and B and the larger version wins. With this patch, only B is used for detection.
* `clang++ -BA foo.cpp` detects GCC installation under `A` and `/usr`, and the larger GCC version wins. With this patch `A` is not used for detection.

This patch changes -B to drop the GCC detection semantics.  Its executable
searching semantics are preserved.  --gcc-toolchain is the recommended option to
specify the GCC installation detection directory.

(
Note: Clang detects GCC installation in various target dependent directories.
`$sysroot/usr` (sysroot defaults to "") is a common directory used by most targets.
Such a directory is expected to contain something like `lib{,32,64}/gcc{,-cross}/$triple`.
Clang will then construct library/include paths from the directory.
)

Differential Revision: https://reviews.llvm.org/D97993




More information about the All-commits mailing list