Skip to content

Commit

Permalink
Expand our own config.guess-like logic in configure, rather than only…
Browse files Browse the repository at this point in the history
… asking LLVM. We have to decide some things before we get an LLVM to ask.
  • Loading branch information
graydon committed Sep 21, 2011
1 parent f19ab1f commit 1321580
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Makefile.in
Expand Up @@ -11,7 +11,8 @@ ifneq ($(MAKE_RESTARTS),)
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))
Expand Down
51 changes: 50 additions & 1 deletion configure
Expand Up @@ -127,8 +127,8 @@ need_cmd sed
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
Expand All @@ -139,6 +139,54 @@ then
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 '\\' '/')
Expand Down Expand Up @@ -180,6 +228,7 @@ putvar CFG_SRC_DIR
putvar CFG_BUILD_DIR
putvar CFG_OSTYPE
putvar CFG_CPUTYPE
putvar CFG_HOST_TRIPLE
putvar CFG_CONFIGURE_ARGS

step_msg "looking for build programs"
Expand Down
8 changes: 4 additions & 4 deletions mk/platform.mk
Expand Up @@ -7,7 +7,7 @@ CFG_GCCISH_LINK_FLAGS :=
# 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
Expand All @@ -20,7 +20,7 @@ ifeq ($(CFG_OSTYPE), FreeBSD)
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
Expand All @@ -46,7 +46,7 @@ ifeq ($(CFG_OSTYPE), Linux)
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
Expand All @@ -69,7 +69,7 @@ ifeq ($(CFG_OSTYPE), Darwin)
CFG_DEF_SUFFIX := .darwin.def
endif

ifneq ($(findstring MINGW,$(CFG_OSTYPE)),)
ifneq ($(findstring mingw,$(CFG_OSTYPE)),)
CFG_WINDOWSY := 1
endif

Expand Down

0 comments on commit 1321580

Please sign in to comment.