[Driver] -p: change from unused warning to error for most targets

AIX and OpenBSD seem to use -p. For most targets (at least FreeBSD and Linux),
-p is legacy (GCC freebsd has a warning). We don't want the uses to grow, so
making -p an alias for -pg is not recommended. I think the uses are small.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D138255
This commit is contained in:
Fangrui Song 2022-12-02 18:57:48 +00:00
parent 0b2473936d
commit 9f07256a51
3 changed files with 16 additions and 0 deletions

View File

@ -184,6 +184,9 @@ code bases.
- To match GCC, ``__ppc64__`` is no longer defined on PowerPC64 targets. Use - To match GCC, ``__ppc64__`` is no longer defined on PowerPC64 targets. Use
``__powerpc64__`` instead. ``__powerpc64__`` instead.
- ``-p`` is rejected for all targets which are not AIX or OpenBSD. ``-p`` led
to an ``-Wunused-command-line-argument`` warning in previous releases.
What's New in Clang |release|? What's New in Clang |release|?
============================== ==============================
Some of the major new features and improvements to Clang are listed Some of the major new features and improvements to Clang are listed

View File

@ -6214,6 +6214,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
<< A->getAsString(Args) << TripleStr; << A->getAsString(Args) << TripleStr;
} }
} }
if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
D.Diag(diag::err_drv_unsupported_opt_for_target)
<< A->getAsString(Args) << TripleStr;
}
}
if (Args.getLastArg(options::OPT_fapple_kext) || if (Args.getLastArg(options::OPT_fapple_kext) ||
(Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType))) (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))

7
clang/test/Driver/p.c Normal file
View File

@ -0,0 +1,7 @@
/// For most targets -p is legacy. We used to report -Wunused-command-line-argument.
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -c -p %s 2>&1 | FileCheck %s --check-prefix=ERR
// RUN: %clang -### --target=x86_64-unknown-openbsd -c -p %s 2>&1 | FileCheck %s --implicit-check-not=error:
// RUN: %clang -### --target=powerpc64-ibm-aix -c -p %s 2>&1 | FileCheck %s --implicit-check-not=error:
// ERR: error: unsupported option '-p' for target {{.*}}