Expand our own config.guess-like logic in configure, rather than only asking LLVM. We have to decide some things before we get an LLVM to ask.
diff --git a/Makefile.in b/Makefile.in
index bdb55e1..e74b4cb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -11,7 +11,8 @@
CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
endif
-CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE))
+CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE))
+CFG_INFO := $(info cfg: llvm host triple $(CFG_LLVM_TRIPLE))
ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
diff --git a/configure b/configure
index 11f0a05..c4516c8 100755
--- a/configure
+++ b/configure
@@ -127,8 +127,8 @@
msg "inspecting environment"
CFG_OSTYPE=$(uname -s)
-
CFG_CPUTYPE=$(uname -m)
+
if [ $CFG_OSTYPE = Darwin -a $CFG_CPUTYPE = i386 ]
then
# Darwin's `uname -s` lies and always returns i386. We have to use sysctl
@@ -139,6 +139,54 @@
fi
fi
+
+# The goal here is to come up with the same triple as LLVM would,
+# at least for the subset of platforms we're willing to target.
+
+case $CFG_OSTYPE in
+
+ Linux)
+ CFG_OSTYPE=unknown-linux-gnu
+ ;;
+
+ FreeBSD)
+ CFG_OSTYPE=unknown-freebsd
+ ;;
+
+ Darwin)
+ CFG_OSTYPE=apple-darwin
+ ;;
+
+ MINGW32*)
+ CFG_OSTYPE=pc-mingw32
+ ;;
+
+ *)
+ err "unknown OS type: $CFG_OSTYPE"
+ ;;
+esac
+
+
+case $CFG_CPUTYPE in
+
+ i386 | i486 | i686 | i786 | x86)
+ CFG_CPUTYPE=i686
+ ;;
+
+ xscale | arm)
+ CFG_CPUTYPE=arm
+ ;;
+
+ x86_64 | x86-64 | x64)
+ CFG_CPUTYPE=x86_64
+ ;;
+
+ *)
+ err "unknown CPU type: $CFG_CPUTYPE"
+esac
+
+CFG_HOST_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}"
+
CFG_SELF=$(echo $0 | tr '\\' '/')
CFG_SRC_DIR=${CFG_SELF%${CFG_SELF##*/}}
CFG_BUILD_DIR=$(echo $PWD | tr '\\' '/')
@@ -180,6 +228,7 @@
putvar CFG_BUILD_DIR
putvar CFG_OSTYPE
putvar CFG_CPUTYPE
+putvar CFG_HOST_TRIPLE
putvar CFG_CONFIGURE_ARGS
step_msg "looking for build programs"
diff --git a/mk/platform.mk b/mk/platform.mk
index 001ba43..c38d081 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -7,7 +7,7 @@
# embedded into the executable, so use a no-op command.
CFG_DSYMUTIL := true
-ifeq ($(CFG_OSTYPE), FreeBSD)
+ifeq ($(findstring freebsd,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -lpthread -lrt
@@ -20,7 +20,7 @@
CFG_DEF_SUFFIX := .bsd.def
endif
-ifeq ($(CFG_OSTYPE), Linux)
+ifneq ($(findstring linux,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so
CFG_GCCISH_CFLAGS += -fPIC -march=i686
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
@@ -46,7 +46,7 @@
endif
endif
-ifeq ($(CFG_OSTYPE), Darwin)
+ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).dylib
CFG_UNIXY := 1
CFG_LDENV := DYLD_LIBRARY_PATH
@@ -69,7 +69,7 @@
CFG_DEF_SUFFIX := .darwin.def
endif
-ifneq ($(findstring MINGW,$(CFG_OSTYPE)),)
+ifneq ($(findstring mingw,$(CFG_OSTYPE)),)
CFG_WINDOWSY := 1
endif