Skip to content

Commit 3223272

Browse files
committed
Fix unused argument diagnostic emission for baremetal targets
1 parent f3be202 commit 3223272

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

clang/lib/Driver/ToolChain.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ static void getAArch64MultilibFlags(const Driver &D,
210210
const llvm::opt::ArgList &Args,
211211
Multilib::flags_list &Result) {
212212
std::vector<StringRef> Features;
213-
tools::aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, false);
213+
tools::aarch64::getAArch64TargetFeatures(D, Triple, Args, Features,
214+
/*ForAS=*/false,
215+
/*ForMultilib=*/true);
214216
const auto UnifiedFeatures = tools::unifyTargetFeatures(Features);
215217
llvm::DenseSet<StringRef> FeatureSet(UnifiedFeatures.begin(),
216218
UnifiedFeatures.end());

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
196196
const llvm::Triple &Triple,
197197
const ArgList &Args,
198198
std::vector<StringRef> &Features,
199-
bool ForAS) {
199+
bool ForAS, bool ForMultilib) {
200200
Arg *A;
201201
bool success = true;
202202
llvm::StringRef WaMArch;
@@ -334,7 +334,9 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
334334

335335
// Generate execute-only output (no data access to code sections).
336336
// This only makes sense for the compiler, not for the assembler.
337-
if (!ForAS) {
337+
// It's not needed for multilib selection and may hide an unused
338+
// argument diagnostic if the code is always run.
339+
if (!ForAS && !ForMultilib) {
338340
if (Arg *A = Args.getLastArg(options::OPT_mexecute_only,
339341
options::OPT_mno_execute_only)) {
340342
if (A->getOption().matches(options::OPT_mexecute_only)) {

clang/lib/Driver/ToolChains/Arch/AArch64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace aarch64 {
2323
void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple,
2424
const llvm::opt::ArgList &Args,
2525
std::vector<llvm::StringRef> &Features,
26-
bool ForAS);
26+
bool ForAS, bool ForMultilib = false);
2727

2828
std::string getAArch64TargetCPU(const llvm::opt::ArgList &Args,
2929
const llvm::Triple &Triple, llvm::opt::Arg *&A);

clang/test/Driver/aarch64-execute-only.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33

44
// RUN: %clang -### --target=aarch64-unknown-linux-gnu -x assembler -mexecute-only %s -c -### 2>&1 \
55
// RUN: | FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM
6+
// RUN: %clang -### --multi-lib-config=%S/Inputs/multilib/empty.yaml --sysroot= \
7+
// RUN: --target=aarch64-none-elf -x assembler -mexecute-only %s -c -### 2>&1 \
8+
// RUN: | FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM
69
// CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: '-mexecute-only'

0 commit comments

Comments
 (0)