[cfe-commits] r110693 - in /cfe/trunk: lib/Driver/HostInfo.cpp test/Driver/freebsd.c
Daniel Dunbar
daniel at zuster.org
Tue Aug 10 10:39:05 PDT 2010
Author: ddunbar
Date: Tue Aug 10 12:39:05 2010
New Revision: 110693
URL: http://llvm.org/viewvc/llvm-project?rev=110693&view=rev
Log:
Driver/FreeBSD: Infer the right arch name in the presence of -m32,-m64, for the
cases we care about.
- This is eventually going to be unified outside the host specific code.
Modified:
cfe/trunk/lib/Driver/HostInfo.cpp
cfe/trunk/test/Driver/freebsd.c
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=110693&r1=110692&r2=110693&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Aug 10 12:39:05 2010
@@ -345,8 +345,20 @@
assert(!ArchName &&
"Unexpected arch name on platform without driver driver support.");
+ // Automatically handle some instances of -m32/-m64 we know about.
std::string Arch = getArchName();
ArchName = Arch.c_str();
+ if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
+ if (Triple.getArch() == llvm::Triple::x86 ||
+ Triple.getArch() == llvm::Triple::x86_64) {
+ ArchName =
+ (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64";
+ } else if (Triple.getArch() == llvm::Triple::ppc ||
+ Triple.getArch() == llvm::Triple::ppc64) {
+ ArchName =
+ (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64";
+ }
+ }
ToolChain *&TC = ToolChains[ArchName];
if (!TC) {
Modified: cfe/trunk/test/Driver/freebsd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.c?rev=110693&r1=110692&r2=110693&view=diff
==============================================================================
--- cfe/trunk/test/Driver/freebsd.c (original)
+++ cfe/trunk/test/Driver/freebsd.c Tue Aug 10 12:39:05 2010
@@ -1,7 +1,21 @@
-// RUN: %clang -ccc-clang-archs "" -ccc-host-triple powerpc64-pc-freebsd8 %s -### 2> %t.log
-// RUN: cat %t.log
-// RUN: FileCheck -input-file %t.log %s
+// RUN: %clang -ccc-clang-archs "" -ccc-host-triple powerpc64-pc-freebsd8 %s -### 2> %t
+// RUN: FileCheck --check-prefix=CHECK-PPC < %t %s
+//
+// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
+// CHECK-PPC: as{{.*}}" "-o" "{{.*}}.o" "{{.*}}.s
+// CHECK-PPC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
-// CHECK: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
-// CHECK: as{{.*}}" "-o" "{{.*}}.o" "{{.*}}.s
-// CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+
+// Check that -m32 properly adjusts the toolchain flags.
+//
+// RUN: %clang -ccc-host-triple x86_64-pc-freebsd8 -m32 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-LIB32 < %t %s
+//
+// CHECK-LIB32: clang{{.*}}" "-cc1" "-triple" "i386-pc-freebsd8"
+// CHECK-LIB32: as{{.*}}" "--32"
+// CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
+//
+// RUN: %clang -ccc-host-triple x86_64-pc-freebsd8 -m32 -print-search-dirs %s > %t
+// RUN: FileCheck --check-prefix=CHECK-LIB32PATHS < %t %s
+//
+// CHECK-LIB32PATHS: libraries: ={{.*}}:/usr/lib32
More information about the cfe-commits
mailing list