r192615 - For NetBSD/current on X86 do not use libgcc and default to libc++.
David Blaikie
dblaikie at gmail.com
Mon Oct 14 13:57:46 PDT 2013
On Mon, Oct 14, 2013 at 1:13 PM, Joerg Sonnenberger <joerg at bec.de> wrote:
> Author: joerg
> Date: Mon Oct 14 15:13:05 2013
> New Revision: 192615
>
> URL: http://llvm.org/viewvc/llvm-project?rev=192615&view=rev
> Log:
> For NetBSD/current on X86 do not use libgcc and default to libc++.
> Adjust linkage to make more sense for older releases.
>
> Added:
> cfe/trunk/test/Driver/netbsd.c
> cfe/trunk/test/Driver/netbsd.cpp
>
These tests are failing for me:
Command Output (stderr):
--
llvm/src/tools/clang/test/Driver/netbsd.c:17:12: error: expected string not
found in input
// X86_64: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc"
^
<stdin>:5:72: note: scanning from here
"/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" "-o"
"a.out" "crt0.o" "/usr/lib/crti.o" "crtbegin.o" "/tmp/netbsd-beaf8
f.o" "-lc" "crtend.o" "/usr/lib/crtn.o"
and
Command Output (stderr):
--
llvm/src/tools/clang/test/Driver/netbsd.cpp:17:12: error: expected string
not found in input
// X86_64: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc++"
^
<stdin>:5:72: note: scanning from here
"/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" "-o"
"a.out" "crt0.o" "/usr/lib/crti.o" "crtbegin.o" "/tmp/netbsd-30fe11.o"
"-lc++" "-lm" "-lc" "crtend.o" "/usr/lib/crtn.o"
> Modified:
> cfe/trunk/lib/Driver/ToolChains.cpp
> cfe/trunk/lib/Driver/Tools.cpp
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=192615&r1=192614&r2=192615&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Oct 14 15:13:05 2013
> @@ -1982,6 +1982,12 @@ NetBSD::GetCXXStdlibType(const ArgList &
> << A->getAsString(Args);
> }
>
> + unsigned Major, Minor, Micro;
> + getTriple().getOSVersion(Major, Minor, Micro);
> + if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 23) || Major
> == 0) {
> + if (getArch() == llvm::Triple::x86 || getArch() ==
> llvm::Triple::x86_64)
> + return ToolChain::CST_Libcxx;
> + }
> return ToolChain::CST_Libstdcxx;
> }
>
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=192615&r1=192614&r2=192615&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 14 15:13:05 2013
> @@ -5860,34 +5860,39 @@ void netbsd::Link::ConstructJob(Compilat
>
> AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
>
> + unsigned Major, Minor, Micro;
> + getToolChain().getTriple().getOSVersion(Major, Minor, Micro);
> + bool useLibgcc = true;
> + if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 23) || Major
> == 0) {
> + if (getToolChain().getArch() == llvm::Triple::x86 ||
> + getToolChain().getArch() == llvm::Triple::x86_64)
> + useLibgcc = false;
> + }
> +
> if (!Args.hasArg(options::OPT_nostdlib) &&
> !Args.hasArg(options::OPT_nodefaultlibs)) {
> if (D.CCCIsCXX()) {
> getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
> CmdArgs.push_back("-lm");
> }
> - // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
> - // the default system libraries. Just mimic this for now.
> - if (Args.hasArg(options::OPT_static)) {
> - CmdArgs.push_back("-lgcc_eh");
> - } else {
> - CmdArgs.push_back("--as-needed");
> - CmdArgs.push_back("-lgcc_s");
> - CmdArgs.push_back("--no-as-needed");
> - }
> - CmdArgs.push_back("-lgcc");
> -
> if (Args.hasArg(options::OPT_pthread))
> CmdArgs.push_back("-lpthread");
> CmdArgs.push_back("-lc");
>
> - CmdArgs.push_back("-lgcc");
> - if (Args.hasArg(options::OPT_static)) {
> - CmdArgs.push_back("-lgcc_eh");
> - } else {
> - CmdArgs.push_back("--as-needed");
> - CmdArgs.push_back("-lgcc_s");
> - CmdArgs.push_back("--no-as-needed");
> + if (useLibgcc) {
> + if (Args.hasArg(options::OPT_static)) {
> + // libgcc_eh depends on libc, so resolve as much as possible,
> + // pull in any new requirements from libc and then get the rest
> + // of libgcc.
> + CmdArgs.push_back("-lgcc_eh");
> + CmdArgs.push_back("-lc");
> + CmdArgs.push_back("-lgcc");
> + } else {
> + CmdArgs.push_back("-lgcc");
> + CmdArgs.push_back("--as-needed");
> + CmdArgs.push_back("-lgcc_s");
> + CmdArgs.push_back("--no-as-needed");
> + }
> }
> }
>
>
> Added: cfe/trunk/test/Driver/netbsd.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/netbsd.c?rev=192615&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Driver/netbsd.c (added)
> +++ cfe/trunk/test/Driver/netbsd.c Mon Oct 14 15:13:05 2013
> @@ -0,0 +1,45 @@
> +// RUN: %clang -no-canonical-prefixes -target x86_64--netbsd %s -### 2>&1
> \
> +// RUN: | FileCheck -check-prefix=X86_64 %s
> +// RUN: %clang -no-canonical-prefixes -target x86_64--netbsd7.0.0 %s -###
> 2>&1 \
> +// RUN: | FileCheck -check-prefix=X86_64-7 %s
> +// RUN: %clang -no-canonical-prefixes -target x86_64--netbsd6.0.0 %s -###
> 2>&1 \
> +// RUN: | FileCheck -check-prefix=X86_64-6 %s
> +
> +// RUN: %clang -no-canonical-prefixes -target x86_64--netbsd %s -static
> -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=S-X86_64 %s
> +// RUN: %clang -no-canonical-prefixes -target x86_64--netbsd7.0.0 -static
> %s -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=S-X86_64-7 %s
> +// RUN: %clang -no-canonical-prefixes -target x86_64--netbsd6.0.0 -static
> %s -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=S-X86_64-6 %s
> +
> +// X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
> +// X86_64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker"
> "/libexec/ld.elf_so"
> +// X86_64: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc"
> +// X86_64: "crtend.o" "crtn.o"
> +
> +// X86_64-7: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd7.0.0"
> +// X86_64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker"
> "/libexec/ld.elf_so"
> +// X86_64-7: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc"
> +// X86_64-7: "crtend.o" "crtn.o"
> +
> +// X86_64-6: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd6.0.0"
> +// X86_64-6: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker"
> "/libexec/ld.elf_so"
> +// X86_64-6: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc"
> +// X86_64-6: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
> +// X86_64-6: "crtend.o" "crtn.o"
> +
> +// S-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
> +// S-X86_64: ld{{.*}}" "-Bstatic"
> +// S-X86_64: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc"
> +// S-X86_64: "crtend.o" "crtn.o"
> +
> +// S-X86_64-7: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd7.0.0"
> +// S-X86_64-7: ld{{.*}}" "-Bstatic"
> +// S-X86_64-7: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lc"
> +// S-X86_64-7: "crtend.o" "crtn.o"
> +
> +// S-X86_64-6: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd6.0.0"
> +// S-X86_64-6: ld{{.*}}" "-Bstatic"
> +// S-X86_64-6: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lc"
> +// S-X86_64-6: "-lgcc_eh" "-lc" "-lgcc"
> +// S-X86_64-6: "crtend.o" "crtn.o"
>
> Added: cfe/trunk/test/Driver/netbsd.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/netbsd.cpp?rev=192615&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Driver/netbsd.cpp (added)
> +++ cfe/trunk/test/Driver/netbsd.cpp Mon Oct 14 15:13:05 2013
> @@ -0,0 +1,45 @@
> +// RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd %s -###
> 2>&1 \
> +// RUN: | FileCheck -check-prefix=X86_64 %s
> +// RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd7.0.0 %s
> -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=X86_64-7 %s
> +// RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd6.0.0 %s
> -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=X86_64-6 %s
> +
> +// RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd %s -static
> -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=S-X86_64 %s
> +// RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd7.0.0
> -static %s -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=S-X86_64-7 %s
> +// RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd6.0.0
> -static %s -### 2>&1 \
> +// RUN: | FileCheck -check-prefix=S-X86_64-6 %s
> +
> +// X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
> +// X86_64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker"
> "/libexec/ld.elf_so"
> +// X86_64: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o" "-lc++"
> +// X86_64: "-lm" "-lc" "crtend.o" "crtn.o"
> +
> +// X86_64-7: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd7.0.0"
> +// X86_64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker"
> "/libexec/ld.elf_so"
> +// X86_64-7: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lc++"
> +// X86_64-7: "-lm" "-lc" "crtend.o" "crtn.o"
> +
> +// X86_64-6: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd6.0.0"
> +// X86_64-6: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker"
> "/libexec/ld.elf_so"
> +// X86_64-6: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lstdc++"
> +// X86_64-6: "-lm" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
> +// X86_64-6: "crtend.o" "crtn.o"
> +
> +// S-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
> +// S-X86_64: ld{{.*}}" "-Bstatic"
> +// S-X86_64: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lc++"
> +// S-X86_64: "-lm" "-lc" "crtend.o" "crtn.o"
> +
> +// S-X86_64-7: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd7.0.0"
> +// S-X86_64-7: ld{{.*}}" "-Bstatic"
> +// S-X86_64-7: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lc++"
> +// S-X86_64-7: "-lm" "-lc" "crtend.o" "crtn.o"
> +
> +// S-X86_64-6: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd6.0.0"
> +// S-X86_64-6: ld{{.*}}" "-Bstatic"
> +// S-X86_64-6: "-o" "a.out" "crt0.o" "crti.o" "crtbegin.o" "{{.*}}.o"
> "-lstdc++"
> +// S-X86_64-6: "-lm" "-lc" "-lgcc_eh" "-lc" "-lgcc"
> +// S-X86_64-6: "crtend.o" "crtn.o"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131014/cc45d5d2/attachment.html>
More information about the cfe-commits
mailing list