diff --git a/mk/main.mk b/mk/main.mk index 2c7c7c7cecd..e52704c0fd3 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -341,10 +341,10 @@ endif ifdef CFG_DISABLE_RPATH ifeq ($$(OSTYPE_$(3)),apple-darwin) RPATH_VAR$(1)_T_$(2)_H_$(3) := \ - DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(HLIB$(1)_H_$(3))" + DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))" else RPATH_VAR$(1)_T_$(2)_H_$(3) := \ - LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(HLIB$(1)_H_$(3))" + LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))" endif else RPATH_VAR$(1)_T_$(2)_H_$(3) := diff --git a/mk/tests.mk b/mk/tests.mk index 787bbac8e6f..4d152b3c388 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -706,8 +706,9 @@ check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3) ifeq ($(2),$$(CFG_BUILD)) $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4)) @$$(call E, run doc-$(4) [$(2)]) - $$(Q)$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) --test \ - $$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@ + $$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3)) \ + $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) --test \ + $$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@ else $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): touch $$@ @@ -934,7 +935,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ $(3)/test/run-make/$$* \ "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \ $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \ - "$$(TESTNAME)" + "$$(TESTNAME)" \ + "$$(RPATH_VAR$(1)_T_$(2)_H_$(3))" @touch $$@ else # FIXME #11094 - The above rule doesn't work right for multiple targets diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 1016c3cf0e6..f3b53ce1c2a 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -36,8 +36,26 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] { #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] -fn target_env(_lib_path: &str, _prog: &str) -> ~[(~str,~str)] { - os::env() +fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] { + // Make sure we include the aux directory in the path + let aux_path = prog + ".libaux"; + + let mut env = os::env(); + let var = if cfg!(target_os = "macos") { + "DYLD_LIBRARY_PATH" + } else { + "LD_LIBRARY_PATH" + }; + let prev = match env.iter().position(|&(ref k, _)| k.as_slice() == var) { + Some(i) => env.remove(i).unwrap().val1(), + None => ~"", + }; + env.push((var.to_owned(), if prev.is_empty() { + lib_path + ":" + aux_path + } else { + lib_path + ":" + aux_path + ":" + prev + })); + return env; } pub struct Result {status: ProcessExit, out: ~str, err: ~str} diff --git a/src/etc/maketest.py b/src/etc/maketest.py index fb886f30bd6..8afe6cf987a 100644 --- a/src/etc/maketest.py +++ b/src/etc/maketest.py @@ -17,6 +17,9 @@ os.putenv('TMPDIR', os.path.abspath(sys.argv[3])) os.putenv('CC', sys.argv[4]) os.putenv('RUSTDOC', os.path.abspath(sys.argv[5])) filt = sys.argv[6] +ldpath = sys.argv[7] +if ldpath != '': + os.putenv(ldpath.split('=')[0], ldpath.split('=')[1]) if not filt in sys.argv[1]: sys.exit(0) diff --git a/src/test/run-make/bootstrap-from-c-with-green/Makefile b/src/test/run-make/bootstrap-from-c-with-green/Makefile index 9a198977aa3..2144a2ca574 100644 --- a/src/test/run-make/bootstrap-from-c-with-green/Makefile +++ b/src/test/run-make/bootstrap-from-c-with-green/Makefile @@ -3,7 +3,7 @@ all: $(RUSTC) lib.rs -C gen-crate-map ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot) - $(CC) main.c -o $(call RUN,main) -lboot -Wl,-rpath,$(TMPDIR) + $(CC) main.c -o $(call RUN,main) -lboot $(call RUN,main) rm $(call DYLIB,boot) $(call FAIL,main) diff --git a/src/test/run-make/bootstrap-from-c-with-native/Makefile b/src/test/run-make/bootstrap-from-c-with-native/Makefile index 9a198977aa3..2144a2ca574 100644 --- a/src/test/run-make/bootstrap-from-c-with-native/Makefile +++ b/src/test/run-make/bootstrap-from-c-with-native/Makefile @@ -3,7 +3,7 @@ all: $(RUSTC) lib.rs -C gen-crate-map ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot) - $(CC) main.c -o $(call RUN,main) -lboot -Wl,-rpath,$(TMPDIR) + $(CC) main.c -o $(call RUN,main) -lboot $(call RUN,main) rm $(call DYLIB,boot) $(call FAIL,main) diff --git a/src/test/run-make/c-dynamic-dylib/Makefile b/src/test/run-make/c-dynamic-dylib/Makefile index 940797c85c4..2b2e5d56e92 100644 --- a/src/test/run-make/c-dynamic-dylib/Makefile +++ b/src/test/run-make/c-dynamic-dylib/Makefile @@ -1,10 +1,5 @@ -include ../tools.mk -# needed so that libfoo can find libcfoo -ifeq ($(shell uname),Linux) -export LD_LIBRARY_PATH := $(TMPDIR) -endif - # This hits an assertion in the linker on older versions of osx apparently ifeq ($(shell uname),Darwin) all: diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index 2d670cb873f..26e6e06c2ed 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -1,3 +1,6 @@ +export LD_LIBRARY_PATH:=$(TMPDIR):$(LD_LIBRARY_PATH) +export DYLD_LIBRARY_PATH:=$(TMPDIR):$(DYLD_LIBRARY_PATH) + RUSTC := $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) CC := $(CC) -L $(TMPDIR)