diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2017-12-30 17:59:26 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2017-12-30 17:59:26 +0000 |
commit | c92ca91472b9158d74c2b8999406fec02f266bce (patch) | |
tree | 9c39a0b624e07a8da5a0629e65ebdfcd314372e0 /clang/test/Driver/config-file2.c | |
parent | 9f0ac82f3b2f24ccab95b0b710a9fa34c53bae3a (diff) | |
download | bcm5719-llvm-c92ca91472b9158d74c2b8999406fec02f266bce.tar.gz bcm5719-llvm-c92ca91472b9158d74c2b8999406fec02f266bce.zip |
Enable configuration files in clang
Clang is inherently a cross compiler and can generate code for any target
enabled during build. It however requires to specify many parameters in the
invocation, which could be hardcoded during configuration process in the
case of single-target compiler. The purpose of configuration files is to
make specifying clang arguments easier.
A configuration file is a collection of driver options, which are inserted
into command line before other options specified in the clang invocation.
It groups related options together and allows specifying them in simpler,
more flexible and less error prone way than just listing the options
somewhere in build scripts. Configuration file may be thought as a "macro"
that names an option set and is expanded when the driver is called.
Use of configuration files is described in `UserManual.rst`.
Differential Revision: https://reviews.llvm.org/D24933
llvm-svn: 321587
Diffstat (limited to 'clang/test/Driver/config-file2.c')
-rw-r--r-- | clang/test/Driver/config-file2.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/test/Driver/config-file2.c b/clang/test/Driver/config-file2.c new file mode 100644 index 00000000000..3a93b55eaca --- /dev/null +++ b/clang/test/Driver/config-file2.c @@ -0,0 +1,51 @@ +// REQUIRES: x86-registered-target + +//--- Invocation `clang --config x86_64-qqq -m32` loads `i386-qqq.cfg` if the latter exists. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -m32 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD +// CHECK-RELOAD: Target: i386-unknown-linux +// CHECK-RELOAD: Configuration file: {{.*}}Inputs{{.}}config{{.}}i386-qqq.cfg + + +//--- Invocation `clang --config x86_64-qqq2 -m32` loads `i386.cfg` if the latter exists in another search directory. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir=%S/Inputs/config2 --config x86_64-qqq2 -m32 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1 +// CHECK-RELOAD1: Target: i386-unknown-linux +// CHECK-RELOAD1: Configuration file: {{.*}}Inputs{{.}}config2{{.}}i386.cfg + + +//--- Invocation `clang --config x86_64-qqq2 -m32` loads `x86_64-qqq2.cfg` if `i386-qqq2.cfg` and `i386.cfg` do not exist. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq2 -m32 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD2 +// note: target is overriden due to -m32 +// CHECK-RELOAD2: Target: i386-unknown-linux +// CHECK-RELOAD2: Configuration file: {{.*}}Inputs{{.}}config{{.}}x86_64-qqq2.cfg + + +//--- Invocation `clang --config i386-qqq3 -m64` loads `x86_64.cfg` if `x86_64-qqq3.cfg` does not exist. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq3 -m64 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD3 +// CHECK-RELOAD3: Target: x86_64-unknown-linux +// CHECK-RELOAD3: Configuration file: {{.*}}Inputs{{.}}config{{.}}x86_64.cfg + + +//--- Invocation `clang --config x86_64-qqq -target i386` loads `i386-qqq.cfg` if the latter exists. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -target i386 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD4 +// CHECK-RELOAD4: Target: i386 +// CHECK-RELOAD4: Configuration file: {{.*}}Inputs{{.}}config{{.}}i386-qqq.cfg + + +//--- Invocation `clang --config x86_64-qqq2 -target i386` loads `x86_64-qqq2.cfg` if `i386-qqq2.cfg` and `i386.cfg` do not exist. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq2 -target i386 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD5 +// note: target is overriden due to -target i386 +// CHECK-RELOAD5: Target: i386 +// CHECK-RELOAD5: Configuration file: {{.*}}Inputs{{.}}config{{.}}x86_64-qqq2.cfg + + +//--- Invocation `clang --config x86_64-qqq -target i386 -m64` loads `x86_64-qqq.cfg`. +// +// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -target i386 -m64 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD6 +// CHECK-RELOAD6: Target: x86_64 +// CHECK-RELOAD6: Configuration file: {{.*}}Inputs{{.}}config{{.}}x86_64-qqq.cfg |