blob: 5b69dba36df7d627c7538ee01332981a69440988 [file] [log] [blame]
Chandler Carruth5e219cf2012-04-08 16:40:35 +00001// Test the driver's control over the PIC behavior. These consist of tests of
2// the relocation model flags and the pic level flags passed to CC1.
3//
4// CHECK-NO-PIC: "-mrelocation-model" "static"
5// CHECK-NO-PIC-NOT: "-pic-level"
6// CHECK-NO-PIC-NOT: "-pie-level"
7//
8// CHECK-DYNAMIC-NO-PIC1: "-mrelocation-model" "dynamic-no-pic"
9// CHECK-DYNAMIC-NO-PIC1: "-pic-level" "1"
10//
11// CHECK-DYNAMIC-NO-PIC2: "-mrelocation-model" "dynamic-no-pic"
12// CHECK-DYNAMIC-NO-PIC2: "-pic-level" "2"
13//
14// CHECK-PIC1-NOT: "-mrelocation-model"
15// CHECK-PIC1: "-pic-level" "1"
16//
17// CHECK-PIC2-NOT: "-mrelocation-model"
18// CHECK-PIC2: "-pic-level" "2"
19//
20// CHECK-PIE1-NOT: "-mrelocation-model"
21// CHECK-PIE1: "-pie-level" "1"
22//
23// CHECK-PIE2-NOT: "-mrelocation-model"
24// CHECK-PIE2: "-pie-level" "2"
25//
Roman Divacky8c6a0572012-09-07 13:52:05 +000026// CHECK-PIE3: "{{.*}}ld{{(.exe)?}}"
Roman Divackyf6513812012-09-07 13:36:21 +000027// CHECK-PIE3: "-pie"
28// CHECK-PIE3: "Scrt1.o" "crti.o" "crtbeginS.o"
29// CHECK-PIE3: "crtendS.o" "crtn.o"
30//
Chandler Carruth5e219cf2012-04-08 16:40:35 +000031// RUN: %clang -c %s -target i386-unknown-unknown -### 2>&1 \
32// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
33// RUN: %clang -c %s -target i386-unknown-unknown -fpic -### 2>&1 \
34// RUN: | FileCheck %s --check-prefix=CHECK-PIC1
35// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -### 2>&1 \
36// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
37// RUN: %clang -c %s -target i386-unknown-unknown -fpie -### 2>&1 \
38// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
39// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -### 2>&1 \
40// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
41// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-pic -### 2>&1 \
42// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
43// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fno-PIC -### 2>&1 \
44// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
45// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-PIC -### 2>&1 \
46// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
47// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fno-pic -### 2>&1 \
48// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
49// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-pie -### 2>&1 \
50// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
51// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -fno-PIE -### 2>&1 \
52// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
53// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-PIE -### 2>&1 \
54// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
55// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -fno-pie -### 2>&1 \
56// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
57// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-pic -### 2>&1 \
58// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
59// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-pie -### 2>&1 \
60// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
61// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fPIC -### 2>&1 \
62// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
63// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fpic -### 2>&1 \
64// RUN: | FileCheck %s --check-prefix=CHECK-PIC1
65// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fPIE -fpie -### 2>&1 \
66// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
67// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fPIC -fPIE -### 2>&1 \
68// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
69//
70// Defaults change for Darwin.
71// RUN: %clang -c %s -target i386-apple-darwin -### 2>&1 \
72// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
73// RUN: %clang -c %s -target i386-apple-darwin -fno-pic -### 2>&1 \
74// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
75// RUN: %clang -c %s -target i386-apple-darwin -fno-PIC -### 2>&1 \
76// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
77//
Roman Divackyf6513812012-09-07 13:36:21 +000078// Make sure -pie is passed to along to ld and that the right *crt* files
79// are linked in.
80// RUN: %clang %s -target i386-unknown-freebsd -fPIE -pie -### \
81// RUN: --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 \
82// RUN: | FileCheck %s --check-prefix=CHECK-PIE3
83// RUN: %clang %s -target i386-linux-gnu -fPIE -pie -### \
84// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
85// RUN: | FileCheck %s --check-prefix=CHECK-PIE3
86//
Chandler Carruth5e219cf2012-04-08 16:40:35 +000087// Disregard any of the PIC-specific flags if we have a trump-card flag.
88// RUN: %clang -c %s -target i386-unknown-unknown -mkernel -fPIC -### 2>&1 \
89// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
90// RUN: %clang -c %s -target i386-unknown-unknown -static -fPIC -### 2>&1 \
91// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
92// RUN: %clang -c %s -target i386-unknown-unknown -mdynamic-no-pic -fPIC -### 2>&1 \
93// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC1
94// RUN: %clang -c %s -target i386-apple-darwin -mdynamic-no-pic -fPIC -### 2>&1 \
95// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC2
Bob Wilsonf2f3ce52012-09-29 23:52:58 +000096
97// Checks for ARM
Bob Wilson33e39112012-09-30 00:58:28 +000098// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -### 2>&1 \
Bob Wilsonf2f3ce52012-09-29 23:52:58 +000099// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
Bob Wilson33e39112012-09-30 00:58:28 +0000100// RUN: %clang -c %s -target armv7-apple-ios -mkernel -miphoneos-version-min=6.0.0 -### 2>&1 \
Bob Wilsonf2f3ce52012-09-29 23:52:58 +0000101// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
Bob Wilson33e39112012-09-30 00:58:28 +0000102// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=5.0.0 -### 2>&1 \
Bob Wilsonf2f3ce52012-09-29 23:52:58 +0000103// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
Bob Wilson33e39112012-09-30 00:58:28 +0000104// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -static -### 2>&1 \
Bob Wilsonf2f3ce52012-09-29 23:52:58 +0000105// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC