[PATCH] D97902: [Driver] Clarify --gcc-toolchain
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 4 09:59:35 PST 2021
MaskRay updated this revision to Diff 328220.
MaskRay marked 2 inline comments as done.
MaskRay added a comment.
comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97902/new/
https://reviews.llvm.org/D97902
Files:
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/test/Driver/gcc-toolchain.cpp
Index: clang/test/Driver/gcc-toolchain.cpp
===================================================================
--- clang/test/Driver/gcc-toolchain.cpp
+++ clang/test/Driver/gcc-toolchain.cpp
@@ -29,3 +29,23 @@
// CHECK: "{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5{{/|\\\\}}crtbegin.o"
// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+//
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: --target=x86_64-linux-gnu -stdlib=libstdc++ \
+// RUN: --gcc-toolchain=%S/Inputs/ubuntu_13.04_multiarch_tree/usr \
+// RUN: --sysroot= | FileCheck %s --check-prefix=UBUNTU13
+
+/// If both --prefix and --gcc-toolchain are specified, the GCC installation with a larger version wins.
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
+// RUN: --prefix=%S/Inputs/ubuntu_13.04_multiarch_tree/usr \
+// RUN: --gcc-toolchain=%S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: --sysroot= | FileCheck %s --check-prefix=UBUNTU13
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
+// RUN: --prefix=%S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: --gcc-toolchain=%S/Inputs/ubuntu_13.04_multiarch_tree/usr \
+// RUN: --sysroot= | FileCheck %s --check-prefix=UBUNTU13
+
+// UBUNTU13: {{.*}}/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -599,8 +599,16 @@
def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
Flags<[NoXarchOption, CoreOption]>;
def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, Group<gfortran_Group>;
-def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<dir>">,
- HelpText<"Add <dir> to search path for binaries and object files used implicitly">;
+def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<prefix>">,
+ HelpText<"Search $prefix/$triple-$file and $prefix$file for executables, libraries, includes, and data files used by the compiler. "
+ "If $prefix is a directory, the directory is used to search for GCC installation on targets which commonly use GCC. "
+ "The directory usually contains 'include' and 'lib'. "
+ "If $prefix is not a directory, the GCC installation detection is skipped but $prefix can still be used to "
+ "find executables, typically for -nostdinc -nostdlib compiles">;
+def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
+ HelpText<"Search for GCC installation in the specified directory, similar to -B<dir>. "
+ "The directory usually contains 'lib' and 'include'."
+ "If specified, sysroot is not skipped for GCC detection">;
def CC : Flag<["-"], "CC">, Flags<[CC1Option]>, Group<Preprocessor_Group>,
HelpText<"Include comments from within macros in preprocessed output">,
MarshallingInfoFlag<PreprocessorOutputOpts<"ShowMacroComments">>;
@@ -3666,8 +3674,6 @@
MarshallingInfoFlag<FrontendOpts<"PrintSupportedCPUs">>;
def mcpu_EQ_QUESTION : Flag<["-"], "mcpu=?">, Alias<print_supported_cpus>;
def mtune_EQ_QUESTION : Flag<["-"], "mtune=?">, Alias<print_supported_cpus>;
-def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
- HelpText<"Use the gcc toolchain at the given directory">;
def time : Flag<["-"], "time">,
HelpText<"Time individual commands">;
def traditional_cpp : Flag<["-", "--"], "traditional-cpp">, Flags<[CC1Option]>,
Index: clang/docs/ClangCommandLineReference.rst
===================================================================
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -18,9 +18,9 @@
.. program:: clang
-.. option:: -B<dir>, --prefix <arg>, --prefix=<arg>
+.. option:: -B<prefix>, --prefix <arg>, --prefix=<arg>
-Add <dir> to search path for binaries and object files used implicitly
+Search $prefix/$triple-$file and $prefix$file for executables, libraries, includes, and data files used by the compiler. If $prefix is a directory, the directory is used to search for GCC installation on targets which commonly use GCC. The directory usually contains 'include' and 'lib'. If $prefix is not a directory, the GCC installation detection is skipped but $prefix can still be used to find executables, typically for -nostdinc -nostdlib compiles
.. option:: -F<arg>
@@ -256,7 +256,7 @@
.. option:: --gcc-toolchain=<arg>, -gcc-toolchain <arg>
-Use the gcc toolchain at the given directory
+Search for GCC installation in the specified directory, similar to -B<dir>. The directory usually contains 'lib' and 'include'.If specified, sysroot is not skipped for GCC detection
.. option:: -gcodeview
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97902.328220.patch
Type: text/x-patch
Size: 4982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210304/fb4d7ac0/attachment.bin>
More information about the cfe-commits
mailing list