Skip to content

Commit 065da35

Browse files
committed
clang driver throws error for -mabi=elfv2 or elfv2
After clang release/16.x there is a regression that -mabi=elfv1 or -mabi=elfv2 are being unused and throws warning. But clang-trunk throws error for -mabi=elfv2 or elfv1. Intent of this patch to accept elfv1 or elfv2 for -mabi. Reviewed By : nemanjai Differential Revision: https://reviews.llvm.org/D156351
1 parent 87d0aed commit 065da35

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,12 @@ void Clang::AddPPCTargetArgs(const ArgList &Args,
20682068
} else if (V == "vec-extabi") {
20692069
VecExtabi = true;
20702070
A->claim();
2071+
} else if (V == "elfv1") {
2072+
ABIName = "elfv1";
2073+
A->claim();
2074+
} else if (V == "elfv2") {
2075+
ABIName = "elfv2";
2076+
A->claim();
20712077
} else if (V != "altivec")
20722078
// The ppc64 linux abis are all "altivec" abis by default. Accept and ignore
20732079
// the option if given as we don't have backend support for any targets

clang/test/Driver/ppc-abi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
1616
// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
1717
// RUN: -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
18+
// RUN: %clang --target=ppc64 -mabi=elfv1 %s -### -o %t.o 2>&1 \
19+
// RUN: | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv1 %s
20+
// RUN: %clang --target=ppc64 -mabi=elfv2 %s -### -o %t.o 2>&1 \
21+
// RUN: | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv2 %s
1822

1923
// RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
2024
// RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
@@ -31,6 +35,8 @@
3135
// CHECK-ELFv2-BE: "-target-abi" "elfv2"
3236
// CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"
3337
// CHECK-ELFv2-BE-PIE: "-target-abi" "elfv2"
38+
// CHECK-UNKNOWN-ELFv1: "-target-abi" "elfv1"
39+
// CHECK-UNKNOWN-ELFv2: "-target-abi" "elfv2"
3440

3541
// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
3642
// RUN: | FileCheck -check-prefix=CHECK-ELFv1-PIC %s

0 commit comments

Comments
 (0)