From 621b515ae50a9bbcd29579418ddc559b72034fa9 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Wed, 10 Sep 2014 21:25:37 +0000 Subject: [PATCH] Only override the target architecture on -m32 and friends if it is actually different. Fixes a surprising link error with nodejs on rpi, where armv6-netbsd-eabihf turned into armv5e-netbsd-eabihf, which doesn't lacks the necessary VFP support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217546 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Driver.cpp | 2 +- test/Driver/biarch.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/Driver/biarch.c diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index e2e6abceef..647d2ca2b3 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1947,7 +1947,7 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple, Target.setEnvironment(llvm::Triple::CODE16); } - if (AT != llvm::Triple::UnknownArch) + if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) Target.setArch(AT); } diff --git a/test/Driver/biarch.c b/test/Driver/biarch.c new file mode 100644 index 0000000000..1f0982e3c5 --- /dev/null +++ b/test/Driver/biarch.c @@ -0,0 +1,41 @@ +// RUN: %clang -target i386--netbsd -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t + +// RUN: %clang -target i386--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t + +// RUN: %clang -target x86_64--netbsd -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t + +// RUN: %clang -target x86_64--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t + +// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "armv6--netbsd-eabihf"' %t + +// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t + +// RUN: %clang -target sparcv9--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t + +// RUN: %clang -target sparc64--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "sparc64--netbsd"' %t + +// RUN: %clang -target sparc--netbsd -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t + +// RUN: %clang -target sparc--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t + +// RUN: %clang -target mips64--netbsd -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t + +// RUN: %clang -target mips64--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t + +// RUN: %clang -target mips--netbsd -m32 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t + +// RUN: %clang -target mips--netbsd -m64 %s -### 2> %t +// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t -- 2.40.0