Skip to content

Commit f1eddf5

Browse files
committed
[Driver] Mark OpenBSD-specific -nopie as TargetSpecific after #72578
so that we get an `error: unsupported option '-nopie' for target ...` instead of a warning.
1 parent 96906a9 commit f1eddf5

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5169,7 +5169,7 @@ def nodriverkitlib : Flag<["-"], "nodriverkitlib">;
51695169
def nofixprebinding : Flag<["-"], "nofixprebinding">;
51705170
def nolibc : Flag<["-"], "nolibc">;
51715171
def nomultidefs : Flag<["-"], "nomultidefs">;
5172-
def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>;
5172+
def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>, Flags<[TargetSpecific]>; // OpenBSD
51735173
def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>;
51745174
def noprebind : Flag<["-"], "noprebind">;
51755175
def noprofilelib : Flag<["-"], "noprofilelib">;

clang/test/Driver/linux-ld.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
// CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
210210
// CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
211211
//
212-
// RUN: not %clang -static-pie -nopie -### %s -no-pie 2>&1 \
212+
// RUN: not %clang -static-pie -### %s -no-pie 2>&1 \
213213
// RUN: --target=x86_64-unknown-linux -rtlib=platform \
214214
// RUN: --gcc-toolchain="" \
215215
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
@@ -1861,3 +1861,7 @@
18611861
// CHECK-OE-AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
18621862
// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0{{/|\\\\}}crtend.o"
18631863
// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../lib64{{/|\\\\}}crtn.o"
1864+
1865+
/// -nopie is OpenBSD-specific.
1866+
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu %s -nopie 2>&1 | FileCheck %s --check-prefix=CHECK-NOPIE
1867+
// CHECK-NOPIE: error: unsupported option '-nopie' for target 'x86_64-unknown-linux-gnu'

clang/test/Driver/solaris-ld.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@
132132
// RUN: --gcc-toolchain="" \
133133
// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
134134
// RUN: | FileCheck --check-prefix=CHECK-PIE-GLD %s
135-
// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie -fuse-ld= \
135+
// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld= \
136136
// RUN: --gcc-toolchain="" \
137137
// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
138138
// RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
139-
// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie -fuse-ld=gld \
139+
// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld=gld \
140140
// RUN: --gcc-toolchain="" \
141141
// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
142142
// RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
@@ -191,7 +191,7 @@
191191
// RUN: --gcc-toolchain="" \
192192
// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
193193
// RUN: | FileCheck --check-prefix=CHECK-CRTS %s
194-
// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie \
194+
// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie \
195195
// RUN: --gcc-toolchain="" \
196196
// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
197197
// RUN: | FileCheck --check-prefix=CHECK-NOCRTS %s

0 commit comments

Comments
 (0)