r196630 - Pass correct flags to assembler and linker for OpenBSD on AMD64, PowerPC
Bill Wendling
isanbard at gmail.com
Sat Dec 7 16:25:22 PST 2013
Aye aye.
-bw
On Dec 6, 2013, at 5:22 PM, Brad Smith <brad at comstyle.com> wrote:
> On 06/12/13 7:57 PM, Joerg Sonnenberger wrote:
>> Author: joerg
>> Date: Fri Dec 6 18:57:46 2013
>> New Revision: 196630
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=196630&view=rev
>> Log:
>> Pass correct flags to assembler and linker for OpenBSD on AMD64, PowerPC
>> and MIPS64. From Brad Smith.
>>
>> Modified:
>> cfe/trunk/lib/Driver/Tools.cpp
>> cfe/trunk/test/Driver/openbsd.c
>
> Please commit this to the 3.4 branch.
>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=196630&r1=196629&r2=196630&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Dec 6 18:57:46 2013
>> @@ -5430,6 +5430,40 @@ void openbsd::Assemble::ConstructJob(Com
>> const char *LinkingOutput) const {
>> ArgStringList CmdArgs;
>>
>> + // When building 32-bit code on OpenBSD/amd64, we have to explicitly
>> + // instruct as in the base system to assemble 32-bit code.
>> + if (getToolChain().getArch() == llvm::Triple::x86)
>> + CmdArgs.push_back("--32");
>> + else if (getToolChain().getArch() == llvm::Triple::ppc) {
>> + CmdArgs.push_back("-mppc");
>> + CmdArgs.push_back("-many");
>> + } else if (getToolChain().getArch() == llvm::Triple::mips64 ||
>> + getToolChain().getArch() == llvm::Triple::mips64el) {
>> + StringRef CPUName;
>> + StringRef ABIName;
>> + getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
>> +
>> + CmdArgs.push_back("-mabi");
>> + CmdArgs.push_back(getGnuCompatibleMipsABIName(ABIName).data());
>> +
>> + if (getToolChain().getArch() == llvm::Triple::mips64)
>> + CmdArgs.push_back("-EB");
>> + else
>> + CmdArgs.push_back("-EL");
>> +
>> + Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
>> + options::OPT_fpic, options::OPT_fno_pic,
>> + options::OPT_fPIE, options::OPT_fno_PIE,
>> + options::OPT_fpie, options::OPT_fno_pie);
>> + if (LastPICArg &&
>> + (LastPICArg->getOption().matches(options::OPT_fPIC) ||
>> + LastPICArg->getOption().matches(options::OPT_fpic) ||
>> + LastPICArg->getOption().matches(options::OPT_fPIE) ||
>> + LastPICArg->getOption().matches(options::OPT_fpie))) {
>> + CmdArgs.push_back("-KPIC");
>> + }
>> + }
>> +
>> Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
>> options::OPT_Xassembler);
>>
>> @@ -5463,6 +5497,11 @@ void openbsd::Link::ConstructJob(Compila
>> // handled somewhere else.
>> Args.ClaimAllArgs(options::OPT_w);
>>
>> + if (getToolChain().getArch() == llvm::Triple::mips64)
>> + CmdArgs.push_back("-EB");
>> + else if (getToolChain().getArch() == llvm::Triple::mips64el)
>> + CmdArgs.push_back("-EL");
>> +
>> if ((!Args.hasArg(options::OPT_nostdlib)) &&
>> (!Args.hasArg(options::OPT_shared))) {
>> CmdArgs.push_back("-e");
>>
>> Modified: cfe/trunk/test/Driver/openbsd.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=196630&r1=196629&r2=196630&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/Driver/openbsd.c (original)
>> +++ cfe/trunk/test/Driver/openbsd.c Fri Dec 6 18:57:46 2013
>> @@ -17,6 +17,10 @@
>> // RUN: | FileCheck --check-prefix=CHECK-LD-T %s
>> // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -Z %s -### 2>&1 \
>> // RUN: | FileCheck --check-prefix=CHECK-LD-Z %s
>> +// RUN: %clang -no-canonical-prefixes -target mips64-unknown-openbsd %s -### 2>&1 \
>> +// RUN: | FileCheck --check-prefix=CHECK-MIPS64-LD %s
>> +// RUN: %clang -no-canonical-prefixes -target mips64el-unknown-openbsd %s -### 2>&1 \
>> +// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
>> // CHECK-LD-R: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
>> // CHECK-LD-R: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-r" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
>> // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
>> @@ -25,3 +29,27 @@
>> // CHECK-LD-T: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-t" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
>> // CHECK-LD-Z: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
>> // CHECK-LD-Z: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-Z" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
>> +// CHECK-MIPS64-LD: clang{{.*}}" "-cc1" "-triple" "mips64-unknown-openbsd"
>> +// CHECK-MIPS64-LD: ld{{.*}}" "-EB" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
>> +// CHECK-MIPS64EL-LD: clang{{.*}}" "-cc1" "-triple" "mips64el-unknown-openbsd"
>> +// CHECK-MIPS64EL-LD: ld{{.*}}" "-EL" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
>> +
>> +// Check passing options to the assembler for various OpenBSD targets
>> +// RUN: %clang -target amd64-pc-openbsd -m32 -### -no-integrated-as -c %s 2>&1 \
>> +// RUN: | FileCheck -check-prefix=CHECK-AMD64-M32 %s
>> +// RUN: %clang -target powerpc-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
>> +// RUN: | FileCheck -check-prefix=CHECK-POWERPC %s
>> +// RUN: %clang -target mips64-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
>> +// RUN: | FileCheck -check-prefix=CHECK-MIPS64 %s
>> +// RUN: %clang -target mips64-unknown-openbsd -fPIC -### -no-integrated-as -c %s 2>&1 \
>> +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-PIC %s
>> +// RUN: %clang -target mips64el-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
>> +// RUN: | FileCheck -check-prefix=CHECK-MIPS64EL %s
>> +// RUN: %clang -target mips64el-unknown-openbsd -fPIC -### -no-integrated-as -c %s 2>&1 \
>> +// RUN: | FileCheck -check-prefix=CHECK-MIPS64EL-PIC %s
>> +// CHECK-AMD64-M32: as{{.*}}" "--32"
>> +// CHECK-POWERPC: as{{.*}}" "-mppc" "-many"
>> +// CHECK-MIPS64: as{{.*}}" "-mabi" "64" "-EB"
>> +// CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
>> +// CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
>> +// CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131207/541e9490/attachment.html>
More information about the cfe-commits
mailing list