[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Driver / ld-path.c
bloba982ea3739a180d89bc582677ab69c12ac33c03b
1 /// This tests uses the PATH environment variable.
2 // UNSUPPORTED: system-windows
4 // RUN: cd %S
6 /// If --ld-path= specifies a word (without /), -B and COMPILER_PATH are
7 /// consulted to locate the linker.
8 // RUN: %clang %s -### -B %S/Inputs/basic_freebsd_tree/usr/bin --ld-path=ld.bfd \
9 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
10 // RUN: FileCheck %s --check-prefix=BFD
11 // RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
12 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
13 // RUN: FileCheck %s --check-prefix=BFD
14 /// Then PATH is consulted.
15 // RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
16 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
17 // RUN: FileCheck %s --check-prefix=BFD
19 // BFD: Inputs/basic_freebsd_tree/usr/bin/ld.bfd"
21 // RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.gold \
22 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
23 // RUN: FileCheck %s --check-prefix=GOLD
25 // GOLD: Inputs/basic_freebsd_tree/usr/bin/ld.gold"
27 // RUN: env COMPILER_PATH= PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=not_exist \
28 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
29 // RUN: FileCheck %s --check-prefix=NOT_EXIST
31 // NOT_EXIST: error: invalid linker name in argument '--ld-path=not_exist'
33 // RUN: %clang %s -### --ld-path= \
34 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
35 // RUN: FileCheck %s --check-prefix=EMPTY
37 // EMPTY: error: invalid linker name in argument '--ld-path='
39 /// If --ld-path= contains a slash, PATH is not consulted.
40 // RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=./ld.bfd \
41 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
42 // RUN: FileCheck %s --check-prefix=NO_BFD
44 // NO_BFD: error: invalid linker name in argument '--ld-path=./ld.bfd'
46 /// --ld-path can specify an absolute path.
47 // RUN: %clang %s -### --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
48 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
49 // RUN: FileCheck %s --check-prefix=BFD
51 // RUN: %clang %s -### --ld-path=Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
52 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
53 // RUN: FileCheck %s --check-prefix=BFD
55 /// --ld-path= and -fuse-ld= can be used together. --ld-path= takes precedence.
56 /// -fuse-ld= can be used to specify the linker flavor.
57 // RUN: %clang %s -### -Werror --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd -fuse-ld=gold \
58 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
59 // RUN: FileCheck %s --check-prefix=BFD --implicit-check-not=error:
61 /// --ld-path= respects -working-directory.
62 // RUN: %clang %s -### --ld-path=usr/bin/ld.bfd -working-directory=%S/Inputs/basic_freebsd_tree \
63 // RUN: --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
64 // RUN: FileCheck %s --check-prefix=USR_BIN_BFD
66 // USR_BIN_BFD: "usr/bin/ld.bfd"