xref: /llvm-project/clang/test/Driver/constructors.c (revision f5991161529511ca6ebc058da2a0507c2fc5283e)
1 // Test whether or not the driver instructs the backend to use .init_array
2 // sections for global constructors.
3 //
4 // CHECK-INIT-ARRAY-NOT: -fno-use-init-array
5 // CHECK-NO-INIT-ARRAY: -fno-use-init-array
6 //
7 // RUN: %clang -### %s -fsyntax-only 2>&1       \
8 // RUN:     --target=i386-unknown-linux \
9 // RUN:     --sysroot=%S/Inputs/resource_dir \
10 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
11 //
12 // RUN: %clang -### %s -fsyntax-only 2>&1       \
13 // RUN:     --target=i386-unknown-linux \
14 // RUN:     --sysroot=%S/Inputs/fake_install_tree \
15 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
16 //
17 // RUN: %clang -### %s -fsyntax-only 2>&1       \
18 // RUN:     -fno-use-init-array \
19 // RUN:     --target=i386-unknown-linux \
20 // RUN:     --sysroot=%S/Inputs/fake_install_tree \
21 // RUN:   | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s
22 //
23 // RUN: %clang -### %s -fsyntax-only 2>&1       \
24 // RUN:     -fno-use-init-array -fuse-init-array \
25 // RUN:     --target=i386-unknown-linux \
26 // RUN:     --sysroot=%S/Inputs/fake_install_tree \
27 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
28 //
29 // RUN: %clang -### %s -fsyntax-only 2>&1       \
30 // RUN:     --target=i386-unknown-linux \
31 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
32 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
33 //
34 // RUN: %clang -### %s -fsyntax-only 2>&1       \
35 // RUN:     -fuse-init-array \
36 // RUN:     --target=i386-unknown-linux \
37 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
38 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
39 //
40 // RUN: %clang -### %s -fsyntax-only 2>&1       \
41 // RUN:     --target=arm-unknown-linux-androideabi \
42 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
43 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
44 //
45 // RUN: %clang -### %s -fsyntax-only 2>&1       \
46 // RUN:     --target=i386-unknown-linux-android \
47 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
48 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
49 //
50 // RUN: %clang -### %s -fsyntax-only 2>&1       \
51 // RUN:     --target=aarch64-none-linux-gnu \
52 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
53 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
54 //
55 // RUN: %clang -### %s -fsyntax-only 2>&1       \
56 // RUN:     --target=aarch64-none-elf \
57 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
58 
59 // RUN: %clang -### %s -fsyntax-only 2>&1       \
60 // RUN:     --target=arm64-none-linux-gnu \
61 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
62 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
63 //
64 // RUN: %clang -### %s -fsyntax-only 2>&1       \
65 // RUN:     --target=arm64-none-none-eabi \
66 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
67 
68 // RUN: %clang -### %s -fsyntax-only 2>&1       \
69 // RUN:     --target=i386-unknown-freebsd \
70 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
71 //
72 // RUN: %clang -### %s -fsyntax-only 2>&1       \
73 // RUN:     --target=i386-unknown-freebsd12 \
74 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
75 //
76 // RUN: %clang -### %s -fsyntax-only 2>&1        \
77 // RUN:     --target=sparc-sun-solaris2.11 \
78 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
79 //
80 // RUN: %clang -### %s -fsyntax-only 2>&1        \
81 // RUN:     --target=i386-pc-solaris2.11 \
82 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
83