xref: /llvm-project/clang/test/Driver/function-sections.c (revision b6cc5ddc94780074e2a027e5c217a254a1b61b05)
1 // Test handling of -f(no-)function-sections and -f(no-)data-sections
2 //
3 // CHECK-FS: -ffunction-sections
4 // CHECK-NOFS-NOT: -ffunction-sections
5 // CHECK-DS: -fdata-sections
6 // CHECK-NODS-NOT: -fdata-sections
7 // CHECK-US-NOT: -fno-unique-section-names
8 // CHECK-NOUS: -fno-unique-section-names
9 // CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
10 // CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
11 // CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
12 // CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
13 // CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
14 // CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
15 
16 // RUN: %clang -### %s -fsyntax-only 2>&1       \
17 // RUN:     --target=i386-unknown-linux \
18 // RUN:   | FileCheck --check-prefix=CHECK-NOFS --check-prefix=CHECK-NODS %s
19 
20 // RUN: %clang -### %s -fsyntax-only 2>&1       \
21 // RUN:     --target=i386-unknown-linux \
22 // RUN:     -ffunction-sections \
23 // RUN:   | FileCheck --check-prefix=CHECK-FS %s
24 
25 // RUN: %clang -### %s -fsyntax-only 2>&1       \
26 // RUN:     --target=i386-unknown-linux \
27 // RUN:     -fno-function-sections \
28 // RUN:   | FileCheck --check-prefix=CHECK-NOFS %s
29 
30 // RUN: %clang -### %s -fsyntax-only 2>&1       \
31 // RUN:     --target=i386-unknown-linux \
32 // RUN:     -ffunction-sections -fno-function-sections \
33 // RUN:   | FileCheck --check-prefix=CHECK-NOFS %s
34 
35 // RUN: %clang -### %s -fsyntax-only 2>&1       \
36 // RUN:     --target=i386-unknown-linux \
37 // RUN:     -fno-function-sections -ffunction-sections \
38 // RUN:   | FileCheck --check-prefix=CHECK-FS %s
39 
40 // RUN: %clang -### %s -fsyntax-only 2>&1       \
41 // RUN:     --target=i386-unknown-linux \
42 // RUN:     -ffunction-sections -fno-function-sections -ffunction-sections \
43 // RUN:   | FileCheck --check-prefix=CHECK-FS %s
44 
45 
46 // RUN: %clang -### %s -fsyntax-only 2>&1       \
47 // RUN:     --target=i386-unknown-linux \
48 // RUN:     -fdata-sections \
49 // RUN:   | FileCheck --check-prefix=CHECK-DS %s
50 
51 // RUN: %clang -### %s -fsyntax-only 2>&1       \
52 // RUN:     --target=i386-unknown-linux \
53 // RUN:     -fno-data-sections \
54 // RUN:   | FileCheck --check-prefix=CHECK-NODS %s
55 
56 // RUN: %clang -### %s -fsyntax-only 2>&1       \
57 // RUN:     --target=i386-unknown-linux \
58 // RUN:     -fdata-sections -fno-data-sections \
59 // RUN:   | FileCheck --check-prefix=CHECK-NODS %s
60 
61 // RUN: %clang -### %s -fsyntax-only 2>&1       \
62 // RUN:     --target=i386-unknown-linux \
63 // RUN:     -fno-data-sections -fdata-sections \
64 // RUN:   | FileCheck --check-prefix=CHECK-DS %s
65 
66 // RUN: %clang -### %s -fsyntax-only 2>&1       \
67 // RUN:     --target=i386-unknown-linux \
68 // RUN:     -fdata-sections -fno-data-sections -fdata-sections \
69 // RUN:   | FileCheck --check-prefix=CHECK-DS %s
70 
71 
72 // RUN: %clang -### %s -fsyntax-only 2>&1        \
73 // RUN:     --target=i386-unknown-linux \
74 // RUN:     -funique-section-names \
75 // RUN:   | FileCheck --check-prefix=CHECK-US %s
76 
77 // RUN: %clang -### %s -fsyntax-only 2>&1        \
78 // RUN:     --target=i386-unknown-linux \
79 // RUN:     -fno-unique-section-names \
80 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
81 
82 
83 // RUN: %clang -### %s -flto 2>&1                \
84 // RUN:     --target=x86_64-unknown-linux \
85 // RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-DEFAULT %s
86 
87 // RUN: %clang -### %s -flto 2>&1                \
88 // RUN:     --target=x86_64-unknown-linux \
89 // RUN:     -ffunction-sections -fdata-sections \
90 // RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-SECTIONS %s
91 
92 // RUN: %clang -### %s -flto 2>&1                \
93 // RUN:     --target=x86_64-unknown-linux \
94 // RUN:     -fno-function-sections -fno-data-sections \
95 // RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-NO-SECTIONS %s
96