OSDN Git Service

[Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path
authorFangrui Song <maskray@google.com>
Mon, 20 Jul 2020 16:34:39 +0000 (09:34 -0700)
committerFangrui Song <i@maskray.me>
Mon, 20 Jul 2020 16:34:39 +0000 (09:34 -0700)
commit1bc5c84710a8c73ef21295e63c19d10a8c71f2f5
tree5c475f81cd0d06e1b808040d7dd0dcc1800c416a
parent76887bc4c102a73669a95002d6a06121e7515e68
[Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

Supersedes D80225. Add --ld-path= to avoid strange target specific
prefixes and make -fuse-ld= focus on its intended job: "linker flavor".
(-f* affects generated code or language features. --ld-path does not
affect codegen, so it is not named -f*)

The way --ld-path= works is similar to "Command Search and Execution" in POSIX.1-2017 2.9.1 Simple Commands.

If --ld-path= specifies

* an absolute path, the value specifies the linker.
* a relative path without a path component separator (/), the value is searched using the -B, COMPILER_PATH, then PATH.
* a relative path with a path component separator, the linker is found relative to the current working directory.

-fuse-ld= and --ld-path= can be composed, e.g. `-fuse-ld=lld --ld-path=/usr/bin/ld.lld`

The driver can base its linker option decision on the flavor -fuse-ld=, but it should not do fragile
flavor checking with --ld-path=.

Reviewed By: whitequark, keith

Differential Revision: https://reviews.llvm.org/D83015
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/Inputs/basic_freebsd64_tree/usr/bin/ld.bfd [new file with mode: 0755]
clang/test/Driver/fuse-ld.c
clang/test/Driver/ld-path.c [new file with mode: 0644]
clang/test/Misc/warning-flags.c