From c278f4c0a576d499cba9de158f09ddbd60752b39 Mon Sep 17 00:00:00 2001 From: Kishan Parmar Date: Sat, 29 Jul 2023 16:09:54 +0530 Subject: [PATCH] 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 (cherry picked from commit 065da3574b4fe9d4ee6283de2c82b8ce1c08af08) --- clang/lib/Driver/ToolChains/Clang.cpp | 6 ++++++ clang/test/Driver/ppc-abi.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index e3fa315..8bd7d09 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2068,6 +2068,12 @@ void Clang::AddPPCTargetArgs(const ArgList &Args, } else if (V == "vec-extabi") { VecExtabi = true; A->claim(); + } else if (V == "elfv1") { + ABIName = "elfv1"; + A->claim(); + } else if (V == "elfv2") { + ABIName = "elfv2"; + A->claim(); } else if (V != "altivec") // The ppc64 linux abis are all "altivec" abis by default. Accept and ignore // the option if given as we don't have backend support for any targets diff --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c index cc07b08..a433f4c 100644 --- a/clang/test/Driver/ppc-abi.c +++ b/clang/test/Driver/ppc-abi.c @@ -15,6 +15,10 @@ // RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \ // RUN: -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s +// RUN: %clang --target=ppc64 -mabi=elfv1 %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv1 %s +// RUN: %clang --target=ppc64 -mabi=elfv2 %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv2 %s // RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s @@ -31,6 +35,8 @@ // CHECK-ELFv2-BE: "-target-abi" "elfv2" // CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" // CHECK-ELFv2-BE-PIE: "-target-abi" "elfv2" +// CHECK-UNKNOWN-ELFv1: "-target-abi" "elfv1" +// CHECK-UNKNOWN-ELFv2: "-target-abi" "elfv2" // RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ELFv1-PIC %s -- 2.7.4