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.

This commit is contained in:
Graydon Hoare 2011-09-21 11:24:59 -07:00
parent f19ab1ff3c
commit 13215809a8
3 changed files with 56 additions and 6 deletions

View File

@ -11,7 +11,8 @@ ifneq ($(MAKE_RESTARTS),)
CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
endif 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 ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))

51
configure vendored
View File

@ -127,8 +127,8 @@ need_cmd sed
msg "inspecting environment" msg "inspecting environment"
CFG_OSTYPE=$(uname -s) CFG_OSTYPE=$(uname -s)
CFG_CPUTYPE=$(uname -m) CFG_CPUTYPE=$(uname -m)
if [ $CFG_OSTYPE = Darwin -a $CFG_CPUTYPE = i386 ] if [ $CFG_OSTYPE = Darwin -a $CFG_CPUTYPE = i386 ]
then then
# Darwin's `uname -s` lies and always returns i386. We have to use sysctl # Darwin's `uname -s` lies and always returns i386. We have to use sysctl
@ -139,6 +139,54 @@ then
fi fi
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_SELF=$(echo $0 | tr '\\' '/')
CFG_SRC_DIR=${CFG_SELF%${CFG_SELF##*/}} CFG_SRC_DIR=${CFG_SELF%${CFG_SELF##*/}}
CFG_BUILD_DIR=$(echo $PWD | tr '\\' '/') CFG_BUILD_DIR=$(echo $PWD | tr '\\' '/')
@ -180,6 +228,7 @@ putvar CFG_SRC_DIR
putvar CFG_BUILD_DIR putvar CFG_BUILD_DIR
putvar CFG_OSTYPE putvar CFG_OSTYPE
putvar CFG_CPUTYPE putvar CFG_CPUTYPE
putvar CFG_HOST_TRIPLE
putvar CFG_CONFIGURE_ARGS putvar CFG_CONFIGURE_ARGS
step_msg "looking for build programs" step_msg "looking for build programs"

View File

@ -7,7 +7,7 @@ CFG_GCCISH_LINK_FLAGS :=
# embedded into the executable, so use a no-op command. # embedded into the executable, so use a no-op command.
CFG_DSYMUTIL := true CFG_DSYMUTIL := true
ifeq ($(CFG_OSTYPE), FreeBSD) ifeq ($(findstring freebsd,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so CFG_LIB_NAME=lib$(1).so
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -lpthread -lrt CFG_GCCISH_LINK_FLAGS += -shared -fPIC -lpthread -lrt
@ -20,7 +20,7 @@ ifeq ($(CFG_OSTYPE), FreeBSD)
CFG_DEF_SUFFIX := .bsd.def CFG_DEF_SUFFIX := .bsd.def
endif endif
ifeq ($(CFG_OSTYPE), Linux) ifneq ($(findstring linux,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so CFG_LIB_NAME=lib$(1).so
CFG_GCCISH_CFLAGS += -fPIC -march=i686 CFG_GCCISH_CFLAGS += -fPIC -march=i686
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt CFG_GCCISH_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
@ -46,7 +46,7 @@ ifeq ($(CFG_OSTYPE), Linux)
endif endif
endif endif
ifeq ($(CFG_OSTYPE), Darwin) ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).dylib CFG_LIB_NAME=lib$(1).dylib
CFG_UNIXY := 1 CFG_UNIXY := 1
CFG_LDENV := DYLD_LIBRARY_PATH CFG_LDENV := DYLD_LIBRARY_PATH
@ -69,7 +69,7 @@ ifeq ($(CFG_OSTYPE), Darwin)
CFG_DEF_SUFFIX := .darwin.def CFG_DEF_SUFFIX := .darwin.def
endif endif
ifneq ($(findstring MINGW,$(CFG_OSTYPE)),) ifneq ($(findstring mingw,$(CFG_OSTYPE)),)
CFG_WINDOWSY := 1 CFG_WINDOWSY := 1
endif endif