[llvm-commits] [PATCH] compiler-rt: Sanity check architectures

Patrick Walton pwalton at mozilla.com
Sun May 8 20:35:43 PDT 2011


(rust-dev: This is an LLVM patch you might want to apply if you're 
trying to build with clang on the Mac.)

Hi everyone,

I've got a quick patch to compiler-rt that makes it do a simple sanity 
check on the toolchain before trying to compile for each architecture. 
This makes clang able to be built again on Darwin without having to 
install the iOS SDK.

Thanks!
Patrick

Index: compiler-rt/make/platform/clang_darwin.mk
===================================================================
--- compiler-rt.orig/make/platform/clang_darwin.mk	2011-05-08 
19:44:40.000000000 -0700
+++ compiler-rt/make/platform/clang_darwin.mk	2011-05-08 
20:25:06.000000000 -0700
@@ -6,6 +6,19 @@

  Description := Static runtime libraries for clang/Darwin.

+# A function that ensures we don't try to build for architectures that we
+# don't have working toolchains for.
+CheckArches = \
+  $(shell \
+    result=""; \
+    for arch in $(1); do \
+      gcc -arch $$arch; \
+      if test $$? == 1; then result="$$result$$arch "; fi; \
+    done; \
+    echo $$result)
+
+###
+
  Configs :=
  UniversalArchs :=

@@ -13,23 +26,23 @@
  # still be referenced from Darwin system headers. This symbol is only ever
  # needed on i386.
  Configs += eprintf
-UniversalArchs.eprintf := i386
+UniversalArchs.eprintf := $(call CheckArches,i386)

  # Configuration for targetting 10.4. We need a few functions missing from
  # libgcc_s.10.4.dylib. We only build x86 slices since clang doesn't really
  # support targetting PowerPC.
  Configs += 10.4
-UniversalArchs.10.4 := i386 x86_64
+UniversalArchs.10.4 := $(call CheckArches,i386 x86_64)

  # Configuration for targetting iOS, for some ARMv6 functions, which 
must be
  # in the same linkage unit, and for a couple of other functions that 
didn't
  # make it into libSystem.
  Configs += ios
-UniversalArchs.ios := i386 x86_64 armv6 armv7
+UniversalArchs.ios := $(call CheckArches,i386 x86_64 armv6 armv7)

  # Configuration for use with kernel/kexts.
  Configs += cc_kext
-UniversalArchs.cc_kext := armv6 armv7 i386 x86_64
+UniversalArchs.cc_kext := $(call CheckArches,armv6 armv7 i386 x86_64)

  ###




More information about the llvm-commits mailing list