auto merge of #14000 : pnkfelix/rust/fsk-fix-issue13732, r=alexcrichton

Fix #13732.

This is a revised, much less hacky form of PR #13753

The changes here:

 * add instrumentation to aid debugging of linkage errors,
 * fine tune some things in the Makefile where we are telling binaries to use a host-oriented path for finding dynamic libraries, when it should be feeding the binaries a target-oriented path for dynamic libraries.
 * pass along the current stage number to run-make tests, and
 * skip certain tests when running atop stage1.

Fix #13746 as well.
This commit is contained in:
bors 2014-05-18 14:41:35 -07:00
commit e1403e1d83
30 changed files with 279 additions and 120 deletions

View file

@ -1,9 +1,13 @@
-include ../tools.mk
HOST_LIB_DIR=$(TMPDIR)/../../../stage$(RUST_BUILD_STAGE)/lib
# This overrides the LD_LIBRARY_PATH for RUN
TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
all:
$(RUSTC) lib.rs
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot)
$(CC) main.c -o $(call RUN,main) -lboot
$(CC) main.c -o $(call RUN_BINFILE,main) $(call RPATH_LINK_SEARCH,$(HOST_LIB_DIR)) -lboot
$(call RUN,main)
rm $(call DYLIB,boot)
$(call REMOVE_DYLIBS,boot)
$(call FAIL,main)

View file

@ -1,9 +1,13 @@
-include ../tools.mk
HOST_LIB_DIR=$(TMPDIR)/../../../stage$(RUST_BUILD_STAGE)/lib
# This overrides the LD_LIBRARY_PATH for RUN
TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
all:
$(RUSTC) lib.rs
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot)
$(CC) main.c -o $(call RUN,main) -lboot
$(CC) main.c -o $(call RUN_BINFILE,main) $(call RPATH_LINK_SEARCH,$(HOST_LIB_DIR)) -lboot
$(call RUN,main)
rm $(call DYLIB,boot)
$(call REMOVE_DYLIBS,boot)
$(call FAIL,main)

View file

@ -9,6 +9,6 @@ all: $(call DYLIB,cfoo)
$(RUSTC) foo.rs
$(RUSTC) bar.rs
$(call RUN,bar)
rm $(TMPDIR)/$(call DYLIB_GLOB,cfoo)
$(call REMOVE_DYLIBS,cfoo)
$(call FAIL,bar)
endif

View file

@ -1,5 +1,8 @@
-include ../tools.mk
# This overrides the LD_LIBRARY_PATH for RUN
TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
# This hits an assertion in the linker on older versions of osx apparently
ifeq ($(shell uname),Darwin)
all:
@ -8,7 +11,7 @@ else
all: $(call DYLIB,cfoo)
$(RUSTC) foo.rs
$(RUSTC) bar.rs
LD_LIBRARY_PATH=$(TMPDIR) $(call RUN,bar)
rm $(TMPDIR)/$(call DYLIB_GLOB,cfoo)
$(call RUN,bar)
$(call REMOVE_DYLIBS,cfoo)
$(call FAIL,bar)
endif

View file

@ -1,9 +1,11 @@
-include ../tools.mk
HOST_LIB_DIR=$(TMPDIR)/../../../stage$(RUST_BUILD_STAGE)/lib
all:
$(RUSTC) foo.rs
ln -s $(call DYLIB,foo-*) $(call DYLIB,foo)
$(CC) bar.c -lfoo -o $(call RUN,bar) -Wl,-rpath,$(TMPDIR)
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(call RPATH_LINK_SEARCH,$(HOST_LIB_DIR)) -Wl,-rpath,$(TMPDIR)
$(call RUN,bar)
rm $(call DYLIB,foo)
$(call REMOVE_DYLIBS,foo)
$(call FAIL,bar)

View file

@ -11,7 +11,7 @@ ifneq ($(shell uname),FreeBSD)
all:
$(RUSTC) foo.rs
ln -s $(call STATICLIB,foo-*) $(call STATICLIB,foo)
$(CC) bar.c -lfoo -o $(call RUN,bar) $(EXTRAFLAGS) -lstdc++
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRAFLAGS) -lstdc++
$(call RUN,bar)
rm $(call STATICLIB,foo*)
$(call RUN,bar)

View file

@ -5,5 +5,5 @@ all: $(call STATICLIB,cfoo)
$(RUSTC) bar.rs
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
$(call RUN,bar)
rm $(TMPDIR)/$(call DYLIB_GLOB,foo)
$(call REMOVE_DYLIBS,foo)
$(call FAIL,bar)

View file

@ -3,6 +3,6 @@
all: $(call STATICLIB,cfoo)
$(RUSTC) foo.rs
$(RUSTC) bar.rs
rm $(TMPDIR)/$(call RLIB_GLOB,foo)
$(call REMOVE_RLIBS,foo)
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
$(call RUN,bar)

View file

@ -6,7 +6,7 @@ all:
$(RUSTC) m3.rs
$(RUSTC) m4.rs
$(call RUN,m4)
rm $(TMPDIR)/$(call DYLIB_GLOB,m1)
rm $(TMPDIR)/$(call DYLIB_GLOB,m2)
rm $(TMPDIR)/$(call DYLIB_GLOB,m3)
$(call REMOVE_DYLIBS,m1)
$(call REMOVE_DYLIBS,m2)
$(call REMOVE_DYLIBS,m3)
$(call FAIL,m4)

View file

@ -1,5 +1,8 @@
-include ../tools.mk
# This overrides the LD_LIBRARY_PATH for RUN
TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
all:
$(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so
$(RUSTC) main.rs

View file

@ -19,5 +19,5 @@ CC := $(CC:-g=)
all:
$(RUSTC) foo.rs -Z lto
ln -s $(call STATICLIB,foo-*) $(call STATICLIB,foo)
$(CC) bar.c -lfoo -o $(call RUN,bar) $(EXTRAFLAGS) -lstdc++
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRAFLAGS) -lstdc++
$(call RUN,bar)

View file

@ -1,6 +1,18 @@
-include ../tools.mk
all:
# This test attempts to use syntax extensions, which are known to be
# incompatible with stage1 at the moment.
ifeq ($(RUST_BUILD_STAGE),1)
DOTEST=
else
DOTEST=dotest
endif
all: $(DOTEST)
dotest:
env
$(RUSTC) lib.rs
$(RUSTC) main.rs -Z lto
$(call RUN,main)

View file

@ -3,7 +3,7 @@
all:
$(RUSTC) --crate-type=rlib crateA.rs
$(RUSTC) --crate-type=rlib crateB.rs
rm $(TMPDIR)/$(call RLIB_GLOB,crateA)
$(call REMOVE_RLIBS,crateA)
# Ensure crateC fails to compile since dependency crateA is missing
$(RUSTC) crateC.rs 2>&1 | \
grep "error: can't find crate for \`crateA\` which \`crateB\` depends on"

View file

@ -5,5 +5,5 @@ all:
$(RUSTC) dylib.rs
$(RUSTC) rlib.rs --crate-type=dylib
$(RUSTC) dylib.rs
rm $(call DYLIB,rlib-*)
$(call REMOVE_DYLIBS,rlib)
$(RUSTC) prog.rs && exit 1 || exit 0

View file

@ -7,7 +7,7 @@
# fail if an rlib was built
all:
$(RUSTC) test.rs
rm $(TMPDIR)/$(call RLIB_GLOB,test)
rm $(TMPDIR)/$(call DYLIB_GLOB,test)
$(call REMOVE_RLIBS,test)
$(call REMOVE_DYLIBS,test)
$(RUSTC) --crate-type dylib test.rs
rm $(TMPDIR)/$(call RLIB_GLOB,test) && exit 1 || exit 0
$(call REMOVE_RLIBS,test) && exit 1 || exit 0

View file

@ -2,8 +2,8 @@
all:
$(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib
rm $(TMPDIR)/$(call RLIB_GLOB,bar)
rm $(TMPDIR)/$(call DYLIB_GLOB,bar)
$(call REMOVE_RLIBS,bar)
$(call REMOVE_DYLIBS,bar)
rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
$(RUSTC) foo.rs --crate-type=bin
rm $(TMPDIR)/$(call BIN,bar)
@ -41,4 +41,4 @@ all:
cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
rm $(TMPDIR)/bar.bc
rm $(TMPDIR)/foo.bc
rm $(TMPDIR)/$(call RLIB_GLOB,bar)
$(call REMOVE_RLIBS,bar)

View file

@ -5,4 +5,4 @@ all:
$(RUSTC) foo.rs -C prefer-dynamic
$(call RUN,foo)
rm $(TMPDIR)/*bar*
$(call FAILS,foo)
$(call FAIL,foo)

View file

@ -4,8 +4,20 @@ export DYLD_LIBRARY_PATH:=$(TMPDIR):$(DYLD_LIBRARY_PATH)
RUSTC := $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
CC := $(CC) -L $(TMPDIR)
RUN = $(TMPDIR)/$(1)
FAILS = $(TMPDIR)/$(1) && exit 1 || exit 0
# These deliberately use `=` and not `:=` so that client makefiles can
# augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
HOST_RPATH_ENV = \
$(LD_LIB_PATH_ENVVAR)=$$$(LD_LIB_PATH_ENVVAR):$(HOST_RPATH_DIR)
TARGET_RPATH_ENV = \
$(LD_LIB_PATH_ENVVAR)=$$$(LD_LIB_PATH_ENVVAR):$(TARGET_RPATH_DIR)
# This is the name of the binary we will generate and run; use this
# e.g. for `$(CC) -o $(RUN_BINFILE)`.
RUN_BINFILE = $(TMPDIR)/$(1)
# RUN and FAIL are basic way we will invoke the generated binary. On
# non-windows platforms, they set the LD_LIBRARY_PATH environment
# variable before running the binary.
RLIB_GLOB = lib$(1)*.rlib
STATICLIB = $(TMPDIR)/lib$(1).a
@ -18,20 +30,32 @@ IS_WINDOWS=1
endif
ifeq ($(UNAME),Darwin)
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
DYLIB_GLOB = lib$(1)*.dylib
DYLIB = $(TMPDIR)/lib$(1).dylib
RPATH_LINK_SEARCH =
else
ifdef IS_WINDOWS
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
DYLIB_GLOB = $(1)*.dll
DYLIB = $(TMPDIR)/$(1).dll
BIN = $(1).exe
export PATH := $(PATH):$(LD_LIBRARY_PATH)
RPATH_LINK_SEARCH =
RUSTC := PATH="$(PATH):$(LD_LIBRARY_PATH)" $(RUSTC)
else
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
DYLIB_GLOB = lib$(1)*.so
DYLIB = $(TMPDIR)/lib$(1).so
RPATH_LINK_SEARCH = -Wl,-rpath-link=$(1)
endif
endif
REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
%.a: %.o
ar crus $@ $<
%.dylib: %.o

View file

@ -1,9 +1,21 @@
-include ../tools.mk
# This test attempts to run rustc itself from the compiled binary; but
# that means that you need to set the LD_LIBRARY_PATH for rustc itself
# while running multiple_files, and that won't work for stage1.
# FIXME ignore windows
ifndef IS_WINDOWS
ifeq ($(RUST_BUILD_STAGE),1)
DOTEST=
else
DOTEST=dotest
endif
endif
all:
all: $(DOTEST)
dotest:
# check that we don't ICE on unicode input, issue #11178
$(RUSTC) multiple_files.rs
$(call RUN,multiple_files) "$(RUSTC)" "$(TMPDIR)"
@ -12,8 +24,3 @@ all:
# correct length. issue #8706
$(RUSTC) span_length.rs
$(call RUN,span_length) "$(RUSTC)" "$(TMPDIR)"
else
all:
endif