]> git.lizzy.rs Git - rust.git/commitdiff
Refactoring: Introduce distinct host and target rpath var setters.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 25 Apr 2014 16:22:23 +0000 (18:22 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Sun, 18 May 2014 20:56:26 +0000 (22:56 +0200)
Two line summary: Distinguish HOST_RPATH and TARGET_RPATH; added
RPATH_LINK_SEARCH; skip tests broken in stage1; general cleanup.

`HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)` and `TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3)`
both match the format of the old `RPATH_VAR$(1)_T_$(2)_H_$(3)` (which
is still being set the same way that it was before, to one of either
HOST/TARGET depending on what stage we are building).  Namely, the format
is <XXX>_RPATH_VAR = "<LD_LIB_PATH_ENVVAR>=<COLON_SEP_PATH_ENTRIES>"

What this commit does:

* Pass both of the (newly introduced) HOST and TARGET rpath setup vars
  to `maketest.py`

* Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself
  Instead, it passes along the HOST and TARGET rpath setup vars in
  environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV`

* Also, pass the current stage number to maketest.py; it in turn
  passes it (via an env var) to run-make tests.

  This allows the run-make tests to selectively change behavior
  (e.g. turn themselves off) to deal with incompatibilities with
  e.g. stage1.

* Cleanup: Distinguish in tools.mk between the command to run (`RUN`)
  and the file to generate to drive that command (`RUN_BINFILE`).  The
  main thing this enables is that `RUN` can now setup the
  `TARGET_RPATH_ENV` without having to dirty up the runner code in
  each of the `run-make` Makefiles.

* Cleanup: Factored out commands to delete dylib/rlib into
  REMOVE_DYLIBS/REMOVE_RLIBS.

  There were places where we were only calling `rm $(call DYLIB,foo)`
  even though we really needed to get rid of the whole glob (at least
  based on alex's findings on #13753 that removing the symlink does not
  suffice).

  Therefore rather than peppering the code with the awkward
  `rm $(TMPDIR)/$(call DYLIB_GLOB,foo)`, I instead introduced a common
  `REMOVE_DYLIBS` user function that expands into that when called.
  After I adding an analogous `REMOVE_RLIBS`, I changed all of the
  existing calls that rm dylibs or rlibs to use these routines
  instead.

  Note that the latter is not a true refactoring since I may have
  changed cases where it was our intent to only remove the sym-link.
  (But if that is the case, then we need to more deeply investigate
  alex's findings on #13753 where the system was still dynamically
  loading up the non-symlinked libraries that it finds on the load
  path.)

* Added RPATH_LINK_SEARCH command and use it on Linux.

  On some platforms, namely Linux, when you have libboot.so that has
  its internal rpath set (to e.g. $(ORIGIN)/path/to/HOSTDIR), the
  linker still complains when you do the link step and it does not
  know where to find libraries that libboot.so depends upon that live
  in HOSTDIR (think e.g. librustuv.so).

  As far as I can tell, the GNU linker will consult the
  LD_LIBRARY_PATH as part of the linking process to find such
  libraries.  But if you want to be more careful and not override
  LD_LIBRARY_PATH for the `gcc` invocation, then you need some other
  way to tell the linker where it can find the libraries that
  libboot.so needs.  The solution to this on Linux is the
  `-Wl,-rpath-link` command line option.

  However, this command line option does not exist on Mac OS X, (which
  appears to be figuring out how to resolve the libboot.dylib
  dependency by some other means, perhaps by consulting the rpath
  setting within libboot.dylib).

  So, in order to abstract over this distinction, I added the
  RPATH_LINK_SEARCH macro to the run-make infrastructure and added
  calls to it where necessary to get Linux working.  On architectures
  other than Linux, the macro expands to nothing.

* Disable miscellaneous tests atop stage1.

* An especially interesting instance of the previous bullet point:
  Excuse regex from doing rustdoc tests atop stage1.

  This was a (nearly-) final step to get `make check-stage1` working
  again.

  The use of a special-case check for regex here is ugly but is
  analogous other similar checks for regex such as the one that landed
  in PR #13844.

  The way this is written, the user will get a reminder that
  doc-crate-regex is being skipped whenever their rules attempt to do
  the crate documentation tests.  This is deliberate: I want people
  running `make check-stage1` to be reminded about which cases are
  being skipped.  (But if such echo noise is considered offensive, it
  can obviously be removed.)

* Got windows working with the above changes.

  This portion of the commit is a cleanup revision of the (previously
  mentioned on try builds) re-architecting of how the LD_LIBRARY_PATH
  setup and extension is handled in order to accommodate Windows' (1.)
  use of `$PATH` for that purpose and (2.) use of spaces in `$PATH`
  entries (problematic for make and for interoperation with tools at
  the shell).

* In addition, since the code has been rearchitected to pass the
  HOST_RPATH_DIR/TARGET_RPATH_DIR rather than a whole sh
  environment-variable setting command, there is no need to for the
  convert_path_spec calls in maketest.py, which in fact were put in
  place to placate Windows but were now causing the Windows builds to
  fail.  Instead we just convert the paths to absolute paths just like
  all of the other path arguments.

Also, note for makefile hackers: apparently you cannot quote operands
to `ifeq` in Makefile (or at least, you need to be careful about
adding them, e.g. to only one side).

22 files changed:
mk/main.mk
mk/tests.mk
src/etc/maketest.py
src/test/run-make/bootstrap-from-c-with-green/Makefile
src/test/run-make/bootstrap-from-c-with-native/Makefile
src/test/run-make/c-dynamic-dylib/Makefile
src/test/run-make/c-dynamic-rlib/Makefile
src/test/run-make/c-link-to-rust-dylib/Makefile
src/test/run-make/c-link-to-rust-staticlib/Makefile
src/test/run-make/c-static-dylib/Makefile
src/test/run-make/c-static-rlib/Makefile
src/test/run-make/dylib-chain/Makefile
src/test/run-make/extern-fn-reachable/Makefile
src/test/run-make/lto-smoke-c/Makefile
src/test/run-make/lto-syntax-extension/Makefile
src/test/run-make/missing-crate-dependency/Makefile
src/test/run-make/mixing-libs/Makefile
src/test/run-make/obey-crate-type-flag/Makefile
src/test/run-make/output-type-permutations/Makefile
src/test/run-make/prefer-dylib/Makefile
src/test/run-make/tools.mk
src/test/run-make/unicode-input/Makefile

index 5c0bffda7be24525dcd8240b16226f1e738d9dff..d652fac12f895f48f2ded97c10727c392dd99404 100644 (file)
@@ -349,18 +349,45 @@ CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
 endef
 
 # Same macro/variables as above, but defined in a separate loop so it can use
-# all the varibles above for all archs. The RPATH_VAR setup sometimes needs to
+# all the variables above for all archs. The RPATH_VAR setup sometimes needs to
 # reach across triples to get things in order.
+#
+# Defines (with the standard $(1)_T_$(2)_H_$(3) suffix):
+# * `LD_LIBRARY_PATH_ENV_NAME`: the name for the key to use in the OS
+#   environment to access or extend the lookup path for dynamic
+#   libraries.  Note on Windows, that key is `$PATH`, and thus not
+#   only conflates programs with dynamic libraries, but also often
+#   contains spaces which confuse make.
+# * `LD_LIBRARY_PATH_ENV_HOSTDIR`: the entry to add to lookup path for the host
+# * `LD_LIBRARY_PATH_ENV_TARGETDIR`: the entry to add to lookup path for target
+# 
+# Below that, HOST_RPATH_VAR and TARGET_RPATH_VAR are defined in terms of the
+# above settings.
+# 
 define SREQ_CMDS
 
 ifeq ($$(OSTYPE_$(3)),apple-darwin)
-  RPATH_VAR$(1)_T_$(2)_H_$(3) := \
-      DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
+  LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := DYLD_LIBRARY_PATH
+else
+ifeq ($$(CFG_WINDOWSY_$(2)),1)
+  LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := PATH
 else
-  RPATH_VAR$(1)_T_$(2)_H_$(3) := \
-      LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
+  LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := LD_LIBRARY_PATH
+endif
 endif
 
+LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3) := \
+    $$(CURDIR)/$$(HLIB$(1)_H_$(3))
+LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3) := \
+    $$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))
+
+HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
+  $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)):$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))
+TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
+  $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)):$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))
+
+RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))
+
 # Pass --cfg stage0 only for the build->host part of stage0;
 # if you're building a cross config, the host->* parts are
 # effectively stage1, since it uses the just-built stage0.
@@ -376,13 +403,7 @@ ifeq ($(1),0)
 ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
 
-ifeq ($$(OSTYPE_$(3)),apple-darwin)
-  RPATH_VAR$(1)_T_$(2)_H_$(3) := \
-      DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
-else
-  RPATH_VAR$(1)_T_$(2)_H_$(3) := \
-      LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
-endif
+RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))
 endif
 endif
 
index 8f20d55e3859cf997ee36e7dd75cd8f6042cd0eb..25f03751074fb9f3a6f9973a159abb3e6c25bdf5 100644 (file)
@@ -793,8 +793,27 @@ else
 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
 endif
 
+# (Issues #13732, #13983, #14000) The doc for the regex crate includes
+# uses of the `regex!` macro from the regex_macros crate.  There is
+# normally a dependence injected that makes the target's regex depend
+# upon the host's regex_macros (see #13845), but that dependency
+# injection is currently skipped for stage1 as a special case.
+#
+# Therefore, as a further special case, this conditional skips
+# attempting to run the doc tests for the regex crate atop stage1,
+# (since there is no regex_macros crate for the stage1 rustc to load).
+#
+# (Another approach for solving this would be to inject the desired
+# dependence for stage1 as well, by setting things up to generate a
+# regex_macros crate that was compatible with the stage1 rustc and
+# thus re-enable our ability to run this test.)
+ifeq (stage$(1)-crate-$(4),stage1-crate-regex)
+check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$(4)-exec:
+       @$$(call E, skipping doc-crate-$(4) as it uses macros and cannot run at stage$(1))
+else
 check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$(4)-exec: \
        $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4))
+endif
 
 ifeq ($(2),$$(CFG_BUILD))
 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
@@ -951,7 +970,10 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
            "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
            $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
            "$$(TESTNAME)" \
-           "$$(RPATH_VAR$(1)_T_$(2)_H_$(3))"
+           $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
+           "$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
+           "$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
+           $(1)
        @touch $$@
 else
 # FIXME #11094 - The above rule doesn't work right for multiple targets
index 7646113560bbb07a8e71cd1a929a41f6e1cda54b..0e2c1e77ab4c5624312d8746613a765478a5aa85 100644 (file)
@@ -30,6 +30,10 @@ def putenv(name, value):
         value = normalize_path(value)
     os.putenv(name, value)
 
+def convert_path_spec(name, value):
+    if os.name == 'nt' and name != 'PATH':
+        value = ":".join(normalize_path(v) for v in value.split(";"))
+    return value
 
 make = sys.argv[2]
 putenv('RUSTC', os.path.abspath(sys.argv[3]))
@@ -37,13 +41,10 @@ putenv('TMPDIR', os.path.abspath(sys.argv[4]))
 putenv('CC', sys.argv[5])
 putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
 filt = sys.argv[7]
-ldpath = sys.argv[8]
-if ldpath != '':
-    name = ldpath.split('=')[0]
-    value = ldpath.split('=')[1]
-    if os.name == 'nt' and name != 'PATH':
-        value = ":".join(normalize_path(v) for v in value.split(";"))
-    os.putenv(name, value)
+putenv('LD_LIB_PATH_ENVVAR', sys.argv[8]);
+putenv('HOST_RPATH_DIR', os.path.abspath(sys.argv[9]));
+putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[10]));
+putenv('RUST_BUILD_STAGE', sys.argv[11])
 
 if not filt in sys.argv[1]:
     sys.exit(0)
index 43388fd9a6f941787c61bf9d8c4ee364dc9e77f2..3b28af9b0e83f09c4db60be429cc14b171290f2d 100644 (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)
index 43388fd9a6f941787c61bf9d8c4ee364dc9e77f2..3b28af9b0e83f09c4db60be429cc14b171290f2d 100644 (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)
index 2b2e5d56e92da29cf4b51e0821c714c8c75cfc93..c4720c418a77a2adaa937eb43f54dd40488b0a08 100644 (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
index 18992703b2c8517a5df4b75ea4b5f54016f22360..e15cfd34d6c36f3e394635003b8644f6c56a931f 100644 (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
index fb57a08a8261c91dddb393fd50424f7500648172..e743004a9cbc6caf86e4a8ba6395674954f9fc2d 100644 (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)
index 7312a65c81238cebb2b8858321d3eb4d85468ee0..40b6feac678233f1154f768c1112215bae4a4f94 100644 (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)
index 62d9c8e90f21a452c84f28ed0102f847e70c50b0..6b047846cfdeb1f5a9e7b11ef3799de4cc99b112 100644 (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)
index 09eb4b1249e53515279bd25cddd859b7da8d84ae..02b24ef9846dd48cc9048b5f6b6463e35c3f6a69 100644 (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)
index e60e904240d188b410071832a1abb0dff77f4668..2149f2451470e2e41f283fb95327a9fa55b5aa8b 100644 (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)
index 0560626c9994feae3665e33b48660d50bd35629d..56748b1eb9b007dc75f4bd08a6fdb86b4ec01581 100644 (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
index 85b8d0e2dd82a62de798237d43116d064fab1a39..49a04ce42a0ae7f16a5fc60ba46c9fb6406a406d 100644 (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)
index 4652556d34401e0378d40f530b396b0d2dac7177..c522f30e2df13875396aff26f637be0af23df43c 100644 (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)
index a470ee0a7c1bb92f66c53aa95c6d307b4d008b0a..3f8b97f2566520a3c28d0e41b67e0e2d82151095 100644 (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"
index 4de0cb3276290b11ed7cc018bbf203df2ecef7f3..babeeef164dd4c9ac824a1ff55a202606e6270ae 100644 (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
index a3c58a6bf17fe276b66c179dae13366e7f1e4106..903349152dfd2efef824e551cdf1050ef37adc8c 100644 (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
index 5a309cddeb184b0f3326bb992b3e10b8f9458acd..c163a5bec086f7a5e0dafa95b2fcdde4e8d82e45 100644 (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)
index 38759b2f52490a52c97724df3f5eaafde5207a64..fe9bbb95095baee57f2375f7c74228336e743f44 100644 (file)
@@ -5,4 +5,4 @@ all:
        $(RUSTC) foo.rs -C prefer-dynamic
        $(call RUN,foo)
        rm $(TMPDIR)/*bar*
-       $(call FAILS,foo)
+       $(call FAIL,foo)
index 90274cdb3e7aab3eca9673368a48d8eea3dabb67..dedd739052ca0f5fd7d0fb0a1ce32b10ac394c1c 100644 (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
index 529bfc24a400ac688a3995fc4b069cab6fcf0963..f834a85cdcc741c0cc496fa1d55bffd7a3f79974 100644 (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: $(DOTEST)
 
-all:
+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