mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
build: Use clang to compile the runtime if available
This commit is contained in:
parent
7641142ce2
commit
269550f673
8
configure
vendored
8
configure
vendored
@ -194,12 +194,13 @@ putvar CFG_CPUTYPE
|
||||
putvar CFG_CONFIGURE_ARGS
|
||||
|
||||
step_msg "looking for build programs"
|
||||
probe_need CFG_GCC gcc
|
||||
probe_need CFG_GIT git
|
||||
probe_need CFG_PERL perl
|
||||
probe_need CFG_PYTHON python
|
||||
probe_need CFG_CURL curl
|
||||
|
||||
probe CFG_CLANG clang
|
||||
probe CFG_GCC gcc
|
||||
probe CFG_LLVM_CONFIG llvm-config
|
||||
probe CFG_VALGRIND valgrind
|
||||
probe CFG_OCAMLC ocamlc
|
||||
@ -211,6 +212,11 @@ probe CFG_MAKEINFO makeinfo
|
||||
probe CFG_TEXI2PDF texi2pdf
|
||||
probe CFG_TEX tex
|
||||
|
||||
if [ -z "$CFG_CLANG" -a -z "$CFG_GCC" ]
|
||||
then
|
||||
err "either clang or gcc is required"
|
||||
fi
|
||||
|
||||
# Valgrind is only reliable on Linux. On Windows it doesn't work at all, and
|
||||
# on the Mac the dynamic linker causes Valgrind to emit a huge stream of
|
||||
# errors.
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
CFG_GCC_CFLAGS := -fno-strict-aliasing
|
||||
CFG_GCC_LINK_FLAGS :=
|
||||
CFG_GCCISH_CFLAGS := -fno-strict-aliasing
|
||||
CFG_GCCISH_LINK_FLAGS :=
|
||||
|
||||
# On Darwin, we need to run dsymutil so the debugging information ends
|
||||
# up in the right place. On other platforms, it automatically gets
|
||||
@ -9,11 +9,11 @@ CFG_DSYMUTIL := true
|
||||
|
||||
ifeq ($(CFG_OSTYPE), FreeBSD)
|
||||
CFG_LIB_NAME=lib$(1).so
|
||||
CFG_GCC_CFLAGS += -fPIC -march=i686 -I/usr/local/include -O2
|
||||
CFG_GCC_LINK_FLAGS += -shared -fPIC -lpthread -lrt
|
||||
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include -O2
|
||||
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -lpthread -lrt
|
||||
ifeq ($(CFG_CPUTYPE), x86_64)
|
||||
CFG_GCC_CFLAGS += -m32
|
||||
CFG_GCC_LINK_FLAGS += -m32
|
||||
CFG_GCCISH_CFLAGS += -m32
|
||||
CFG_GCCISH_LINK_FLAGS += -m32
|
||||
endif
|
||||
CFG_UNIXY := 1
|
||||
CFG_LDENV := LD_LIBRARY_PATH
|
||||
@ -22,14 +22,14 @@ endif
|
||||
|
||||
ifeq ($(CFG_OSTYPE), Linux)
|
||||
CFG_LIB_NAME=lib$(1).so
|
||||
CFG_GCC_CFLAGS += -fPIC -march=i686 -O2
|
||||
CFG_GCC_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
|
||||
CFG_GCC_DEF_FLAG := -Wl,--export-dynamic,--dynamic-list=
|
||||
CFG_GCC_PRE_LIB_FLAGS := -Wl,-whole-archive
|
||||
CFG_GCC_POST_LIB_FLAGS := -Wl,-no-whole-archive
|
||||
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -O2
|
||||
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
|
||||
CFG_GCCISH_DEF_FLAG := -Wl,--export-dynamic,--dynamic-list=
|
||||
CFG_GCCISH_PRE_LIB_FLAGS := -Wl,-whole-archive
|
||||
CFG_GCCISH_POST_LIB_FLAGS := -Wl,-no-whole-archive
|
||||
ifeq ($(CFG_CPUTYPE), x86_64)
|
||||
CFG_GCC_CFLAGS += -m32
|
||||
CFG_GCC_LINK_FLAGS += -m32
|
||||
CFG_GCCISH_CFLAGS += -m32
|
||||
CFG_GCCISH_LINK_FLAGS += -m32
|
||||
endif
|
||||
CFG_UNIXY := 1
|
||||
CFG_LDENV := LD_LIBRARY_PATH
|
||||
@ -40,8 +40,8 @@ ifeq ($(CFG_OSTYPE), Darwin)
|
||||
CFG_LIB_NAME=lib$(1).dylib
|
||||
CFG_UNIXY := 1
|
||||
CFG_LDENV := DYLD_LIBRARY_PATH
|
||||
CFG_GCC_LINK_FLAGS += -dynamiclib -lpthread
|
||||
CFG_GCC_DEF_FLAG := -Wl,-exported_symbols_list,
|
||||
CFG_GCCISH_LINK_FLAGS += -dynamiclib -lpthread
|
||||
CFG_GCCISH_DEF_FLAG := -Wl,-exported_symbols_list,
|
||||
# Darwin has a very blurry notion of "64 bit", and claims it's running
|
||||
# "on an i386" when the whole userspace is 64-bit and the compiler
|
||||
# emits 64-bit binaries by default. So we just force -m32 here. Smarter
|
||||
@ -49,7 +49,12 @@ ifeq ($(CFG_OSTYPE), Darwin)
|
||||
#
|
||||
# NB: Currently GCC's optimizer breaks rustrt (task-comm-1 hangs) on Darwin.
|
||||
CFG_GCC_CFLAGS += -m32 -O0
|
||||
CFG_GCC_LINK_FLAGS += -m32
|
||||
CFG_CLANG_CFLAGS += -m32 -O2
|
||||
ifeq ($(CFG_CPUTYPE), x86_64)
|
||||
CFG_GCCISH_CFLAGS += -arch i386
|
||||
CFG_GCCISH_LINK_FLAGS += -arch i386
|
||||
endif
|
||||
CFG_GCCISH_LINK_FLAGS += -m32
|
||||
CFG_DSYMUTIL := dsymutil
|
||||
CFG_DEF_SUFFIX := .darwin.def
|
||||
endif
|
||||
@ -85,8 +90,8 @@ ifdef CFG_WINDOWSY
|
||||
ifdef CFG_FLEXLINK
|
||||
CFG_BOOT_NATIVE := 1
|
||||
endif
|
||||
CFG_GCC_CFLAGS += -march=i686 -O2
|
||||
CFG_GCC_LINK_FLAGS += -shared -fPIC
|
||||
CFG_GCCISH_CFLAGS += -march=i686 -O2
|
||||
CFG_GCCISH_LINK_FLAGS += -shared -fPIC
|
||||
CFG_DEF_SUFFIX := .def
|
||||
endif
|
||||
|
||||
@ -112,16 +117,16 @@ ifdef CFG_UNIXY
|
||||
CFG_RUN_TEST=PATH=$(CFG_LDPATH):$(call CFG_TESTLIB,$(1)) $(1)
|
||||
|
||||
CFG_INFO := $(info cfg: mingw-cross)
|
||||
CFG_GCC_CROSS := i586-mingw32msvc-
|
||||
CFG_GCCISH_CROSS := i586-mingw32msvc-
|
||||
CFG_BOOT_FLAGS += -t win32-x86-pe
|
||||
ifdef CFG_VALGRIND
|
||||
CFG_VALGRIND += wine
|
||||
endif
|
||||
CFG_GCC_CFLAGS := -march=i686
|
||||
CFG_GCC_LINK_FLAGS := -shared
|
||||
CFG_GCCISH_CFLAGS := -march=i686
|
||||
CFG_GCCISH_LINK_FLAGS := -shared
|
||||
ifeq ($(CFG_CPUTYPE), x86_64)
|
||||
CFG_GCC_CFLAGS += -m32
|
||||
CFG_GCC_LINK_FLAGS += -m32
|
||||
CFG_GCCISH_CFLAGS += -m32
|
||||
CFG_GCCISH_LINK_FLAGS += -m32
|
||||
endif
|
||||
endif
|
||||
ifdef CFG_VALGRIND
|
||||
@ -132,14 +137,28 @@ ifdef CFG_UNIXY
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CFG_CLANG
|
||||
CFG_INFO := $(info cfg: using clang)
|
||||
CFG_GCCISH_CFLAGS += -Wall -Werror -fno-rtti -fno-exceptions -g
|
||||
CFG_GCCISH_LINK_FLAGS += -g
|
||||
CFG_COMPILE_C = $(CFG_GCCISH_CROSS)clang++ $(CFG_GCCISH_CFLAGS) \
|
||||
$(CFG_CLANG_CFLAGS) -c -o $(1) $(2)
|
||||
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)clang++ $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
|
||||
-MM $(2)
|
||||
CFG_LINK_C = $(CFG_GCCISH_CROSS)clang++ $(CFG_GCCISH_LINK_FLAGS) -o $(1) \
|
||||
$(CFG_GCCISH_DEF_FLAG)$(3) $(2)
|
||||
else
|
||||
ifdef CFG_GCC
|
||||
CFG_INFO := $(info cfg: using gcc)
|
||||
CFG_GCC_CFLAGS += -Wall -Werror -fno-rtti -fno-exceptions -g
|
||||
CFG_GCC_LINK_FLAGS += -g
|
||||
CFG_COMPILE_C = $(CFG_GCC_CROSS)g++ $(CFG_GCC_CFLAGS) -c -o $(1) $(2)
|
||||
CFG_DEPEND_C = $(CFG_GCC_CROSS)g++ $(CFG_GCC_CFLAGS) -MT "$(1)" -MM $(2)
|
||||
CFG_LINK_C = $(CFG_GCC_CROSS)g++ $(CFG_GCC_LINK_FLAGS) -o $(1) \
|
||||
$(CFG_GCC_DEF_FLAG)$(3) $(2)
|
||||
CFG_GCCISH_CFLAGS += -Wall -Werror -fno-rtti -fno-exceptions -g
|
||||
CFG_GCCISH_LINK_FLAGS += -g
|
||||
CFG_COMPILE_C = $(CFG_GCCISH_CROSS)g++ $(CFG_GCCISH_CFLAGS) \
|
||||
$(CFG_GCC_CFLAGS) -c -o $(1) $(2)
|
||||
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)g++ $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
|
||||
-MM $(2)
|
||||
CFG_LINK_C = $(CFG_GCCISH_CROSS)g++ $(CFG_GCCISH_LINK_FLAGS) -o $(1) \
|
||||
$(CFG_GCCISH_DEF_FLAG)$(3) $(2)
|
||||
else
|
||||
CFG_ERR := $(error please try on a system with gcc)
|
||||
CFG_ERR := $(error please try on a system with gcc or clang)
|
||||
endif
|
||||
endif
|
||||
|
2
mk/rt.mk
2
mk/rt.mk
@ -64,7 +64,7 @@ RUNTIME_HDR := rt/globals.h \
|
||||
RUNTIME_DEF := rt/rustrt$(CFG_DEF_SUFFIX)
|
||||
RUNTIME_INCS := -I $(S)src/rt/isaac -I $(S)src/rt/uthash
|
||||
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o)
|
||||
RUNTIME_LIBS := $(CFG_GCC_POST_LIB_FLAGS)
|
||||
RUNTIME_LIBS := $(CFG_GCCISH_POST_LIB_FLAGS)
|
||||
|
||||
|
||||
rt/%.o: rt/%.cpp $(MKFILES)
|
||||
|
@ -29,8 +29,8 @@ rustllvm/$(CFG_RUSTLLVM): rustllvm/rustllvmbits.a $(RUSTLLVM_OBJS_OBJS) \
|
||||
$(MKFILES) $(RUSTLLVM_HDR) $(RUSTLLVM_DEF)
|
||||
@$(call E, link: $@)
|
||||
$(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_OBJS_OBJS) \
|
||||
$(CFG_GCC_PRE_LIB_FLAGS) $(CFG_LLVM_LIBS) \
|
||||
$(CFG_GCC_POST_LIB_FLAGS) rustllvm/rustllvmbits.a \
|
||||
$(CFG_GCCISH_PRE_LIB_FLAGS) $(CFG_LLVM_LIBS) \
|
||||
$(CFG_GCCISH_POST_LIB_FLAGS) rustllvm/rustllvmbits.a \
|
||||
$(CFG_LLVM_LIBS) \
|
||||
$(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF))
|
||||
|
||||
|
@ -6,8 +6,8 @@ stage1/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
||||
|
||||
stage1/$(CFG_STDLIB): stage1/std.o stage1/glue.o
|
||||
@$(call E, link: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage1/glue.o $(CFG_GCC_LINK_FLAGS) -o $@ $< \
|
||||
-Lstage1 -Lrt -lrustrt
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage1/glue.o $(CFG_GCCISH_LINK_FLAGS) \
|
||||
-o $@ $< -Lstage1 -Lrt -lrustrt
|
||||
|
||||
stage1/rustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ0)
|
||||
@$(call E, compile: $@)
|
||||
@ -30,11 +30,11 @@ stage1/intrinsics.bc: $(INTRINSICS_BC)
|
||||
|
||||
stage1/%.o: stage1/%.s
|
||||
@$(call E, assemble [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) -o $@ -c $<
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) -o $@ -c $<
|
||||
|
||||
stage1/%$(X): stage1/%.o $(SREQ0)
|
||||
@$(call E, link [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage1/glue.o -o $@ $< \
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage1/glue.o -o $@ $< \
|
||||
-Lstage1 -Lrustllvm -Lrt -lrustrt -lrustllvm -lstd -lm
|
||||
@# dsymutil sometimes fails or prints a warning, but the
|
||||
@# program still runs. Since it simplifies debugging other
|
||||
|
@ -6,8 +6,8 @@ stage2/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
||||
|
||||
stage2/$(CFG_STDLIB): stage2/std.o stage2/glue.o
|
||||
@$(call E, link: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage2/glue.o $(CFG_GCC_LINK_FLAGS) -o $@ $< \
|
||||
-Lstage2 -Lrt -lrustrt
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage2/glue.o $(CFG_GCCISH_LINK_FLAGS) -o \
|
||||
$@ $< -Lstage2 -Lrt -lrustrt
|
||||
|
||||
stage2/rustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ1)
|
||||
@$(call E, compile: $@)
|
||||
@ -30,11 +30,11 @@ stage2/intrinsics.bc: $(INTRINSICS_BC)
|
||||
|
||||
stage2/%.o: stage2/%.s
|
||||
@$(call E, assemble [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) -o $@ -c $<
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) -o $@ -c $<
|
||||
|
||||
stage2/%$(X): stage2/%.o $(SREQ1)
|
||||
@$(call E, link [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage2/glue.o -o $@ $< \
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage2/glue.o -o $@ $< \
|
||||
-Lstage2 -Lrustllvm -Lrt -lrustrt -lrustllvm -lstd -lm
|
||||
@# dsymutil sometimes fails or prints a warning, but the
|
||||
@# program still runs. Since it simplifies debugging other
|
||||
|
@ -6,8 +6,8 @@ stage3/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
||||
|
||||
stage3/$(CFG_STDLIB): stage3/std.o stage3/glue.o
|
||||
@$(call E, link: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage3/glue.o $(CFG_GCC_LINK_FLAGS) -o $@ $< \
|
||||
-Lstage3 -Lrt -lrustrt
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage3/glue.o $(CFG_GCCISH_LINK_FLAGS) -o \
|
||||
$@ $< -Lstage3 -Lrt -lrustrt
|
||||
|
||||
stage3/rustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ2)
|
||||
@$(call E, compile: $@)
|
||||
@ -30,11 +30,11 @@ stage3/intrinsics.bc: $(INTRINSICS_BC)
|
||||
|
||||
stage3/%.o: stage3/%.s
|
||||
@$(call E, assemble [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) -o $@ -c $<
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) -o $@ -c $<
|
||||
|
||||
stage3/%$(X): stage3/%.o $(SREQ2)
|
||||
@$(call E, link [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage3/glue.o -o $@ $< \
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage3/glue.o -o $@ $< \
|
||||
-Lstage3 -Lrustllvm -Lrt -lrustrt -lrustllvm -lstd -lm
|
||||
@# dsymutil sometimes fails or prints a warning, but the
|
||||
@# program still runs. Since it simplifies debugging other
|
||||
|
@ -185,7 +185,7 @@ compile-check: tidy \
|
||||
|
||||
%.stage0$(X): %.stage0.o $(SREQ0)
|
||||
@$(call E, link [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage1/glue.o -o $@ $< \
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage1/glue.o -o $@ $< \
|
||||
-Lstage1 -Lrt -lrustrt -lstd -lm
|
||||
@# dsymutil sometimes fails or prints a warning, but the
|
||||
@# program still runs. Since it simplifies debugging other
|
||||
@ -194,7 +194,7 @@ compile-check: tidy \
|
||||
|
||||
%.stage1$(X): %.stage1.o $(SREQ1)
|
||||
@$(call E, link [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage2/glue.o -o $@ $< \
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage2/glue.o -o $@ $< \
|
||||
-Lstage2 -Lrt -lrustrt -lstd -lm
|
||||
@# dsymutil sometimes fails or prints a warning, but the
|
||||
@# program still runs. Since it simplifies debugging other
|
||||
@ -203,7 +203,7 @@ compile-check: tidy \
|
||||
|
||||
%.stage2$(X): %.stage2.o $(SREQ2)
|
||||
@$(call E, link [gcc]: $@)
|
||||
$(Q)gcc $(CFG_GCC_CFLAGS) stage3/glue.o -o $@ $< \
|
||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage3/glue.o -o $@ $< \
|
||||
-Lstage3 -Lrt -lrustrt -lstd -lm
|
||||
@# dsymutil sometimes fails or prints a warning, but the
|
||||
@# program still runs. Since it simplifies debugging other
|
||||
|
Loading…
Reference in New Issue
Block a user