diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7dd2755350f7a..fae70e61375de 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5169,7 +5169,7 @@ def nodriverkitlib : Flag<["-"], "nodriverkitlib">; def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; def nomultidefs : Flag<["-"], "nomultidefs">; -def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>; +def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>, Flags<[TargetSpecific]>; // OpenBSD def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>; def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c index 7adb078f755dc..15643d6491ae5 100644 --- a/clang/test/Driver/linux-ld.c +++ b/clang/test/Driver/linux-ld.c @@ -209,7 +209,7 @@ // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o" // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group" // -// RUN: not %clang -static-pie -nopie -### %s -no-pie 2>&1 \ +// RUN: not %clang -static-pie -### %s -no-pie 2>&1 \ // RUN: --target=x86_64-unknown-linux -rtlib=platform \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ @@ -1861,3 +1861,7 @@ // CHECK-OE-AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" // CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0{{/|\\\\}}crtend.o" // CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../lib64{{/|\\\\}}crtn.o" + +/// -nopie is OpenBSD-specific. +// RUN: not %clang -### --target=x86_64-unknown-linux-gnu %s -nopie 2>&1 | FileCheck %s --check-prefix=CHECK-NOPIE +// CHECK-NOPIE: error: unsupported option '-nopie' for target 'x86_64-unknown-linux-gnu' diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c index 8f7f168c38721..df4fa7b4c9ebd 100644 --- a/clang/test/Driver/solaris-ld.c +++ b/clang/test/Driver/solaris-ld.c @@ -132,11 +132,11 @@ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PIE-GLD %s -// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie -fuse-ld= \ +// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld= \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s -// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie -fuse-ld=gld \ +// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld=gld \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s @@ -191,7 +191,7 @@ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-CRTS %s -// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie \ +// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOCRTS %s