From f929ec029894185f1a22b26ddaab91760a6ac8df Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 11:55:10 +0200 Subject: [PATCH 1/9] Added `--install-prefix PATH` for overriding embedded `env!($CFG_PREFIX)` --- src/librustc/back/rpath.rs | 25 ++++++++++++------------- src/librustc/driver/driver.rs | 5 +++++ src/librustc/driver/session.rs | 12 ++++++++++++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index ce79bea5cee7d..78a885be2bff8 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -47,8 +47,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<~str> { l.map(|p| p.clone()) }).collect::<~[_]>(); - let rpaths = get_rpaths(os, sysroot, output, libs, - sess.opts.target_triple); + let rpaths = get_rpaths(sess, os, sysroot, output, libs); flags.push_all(rpaths_to_flags(rpaths.as_slice()).as_slice()); flags } @@ -61,11 +60,12 @@ pub fn rpaths_to_flags(rpaths: &[~str]) -> Vec<~str> { return ret; } -fn get_rpaths(os: abi::Os, +fn get_rpaths(sess: &Session, + os: abi::Os, sysroot: &Path, output: &Path, - libs: &[Path], - target_triple: &str) -> Vec<~str> { + libs: &[Path]) -> Vec<~str> { + let target_triple = sess.opts.target_triple.as_slice(); debug!("sysroot: {}", sysroot.display()); debug!("output: {}", output.display()); debug!("libs:"); @@ -80,7 +80,8 @@ fn get_rpaths(os: abi::Os, let rel_rpaths = get_rpaths_relative_to_output(os, output, libs); // And a final backup rpath to the global library location. - let fallback_rpaths = vec!(get_install_prefix_rpath(sysroot, target_triple)); + let fallback_rpaths = vec!(install_prefix_to_rpath(sess.install_prefix(), + sysroot, target_triple)); fn log_rpaths(desc: &str, rpaths: &[~str]) { debug!("{} rpaths:", desc); @@ -132,11 +133,9 @@ pub fn get_rpath_relative_to_output(os: abi::Os, prefix+"/"+relative.as_str().expect("non-utf8 component in path") } -pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> ~str { - let install_prefix = env!("CFG_PREFIX"); - +fn install_prefix_to_rpath(install_prefix: Path, sysroot: &Path, target_triple: &str) -> ~str { let tlib = filesearch::relative_target_lib_path(sysroot, target_triple); - let mut path = Path::new(install_prefix); + let mut path = install_prefix; path.push(&tlib); let path = os::make_absolute(&path); // FIXME (#9639): This needs to handle non-utf8 paths @@ -156,7 +155,7 @@ pub fn minimize_rpaths(rpaths: &[~str]) -> Vec<~str> { #[cfg(unix, test)] mod test { - use back::rpath::get_install_prefix_rpath; + use back::rpath::install_prefix_to_rpath; use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output}; use syntax::abi; use metadata::filesearch; @@ -170,8 +169,8 @@ mod test { #[test] fn test_prefix_rpath() { let sysroot = filesearch::get_or_default_sysroot(); - let res = get_install_prefix_rpath(&sysroot, "triple"); let mut d = Path::new(env!("CFG_PREFIX")); + let res = install_prefix_to_rpath(d.clone(), &sysroot, "triple"); d.push("lib"); d.push(filesearch::rustlibdir()); d.push("triple/lib"); @@ -184,7 +183,7 @@ mod test { #[test] fn test_prefix_rpath_abs() { let sysroot = filesearch::get_or_default_sysroot(); - let res = get_install_prefix_rpath(&sysroot, "triple"); + let res = install_prefix_to_rpath(env!("CFG_PREFIX"), &sysroot, "triple"); assert!(Path::new(res).is_absolute()); } diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index bfa4a310cba00..2a152106538cb 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -899,6 +899,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> session::Options { } let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m)); + let install_prefix_opt = matches.opt_str("install-prefix").map(|m| Path::new(m)); let target = matches.opt_str("target").unwrap_or(host_triple().to_owned()); let opt_level = { if (debugging_opts & session::NO_OPT) != 0 { @@ -978,6 +979,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> session::Options { write_dependency_info: write_dependency_info, print_metas: print_metas, cg: cg, + maybe_install_prefix_override: install_prefix_opt, } } @@ -1118,6 +1120,9 @@ pub fn optgroups() -> Vec { "Output dependency info to after compiling, \ in a format suitable for use by Makefiles", "FILENAME"), optopt("", "sysroot", "Override the system root", "PATH"), + optopt("", "install-prefix", format!("Override the install prefix ({:s})", + option_env!("CFG_PREFIX").unwrap_or( + "unset")), "PATH"), optflag("", "test", "Build a test harness"), optopt("", "target", "Target triple cpu-manufacturer-kernel[-os] to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/ diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 950e6bd8ee833..77473ec0cff0f 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -154,6 +154,8 @@ pub struct Options { /// Crate id-related things to maybe print. It's (crate_id, crate_name, crate_file_name). pub print_metas: (bool, bool, bool), pub cg: CodegenOptions, + /// If set, use path as install prefix; otherwise use `env!("CFG_PREFIX")` + pub maybe_install_prefix_override: Option, } // The type of entry function, so @@ -338,6 +340,15 @@ impl Session { host_triple(), &self.opts.addl_lib_search_paths) } + + pub fn install_prefix<'a>(&'a self) -> Path { + Path::new(self.opts.maybe_install_prefix_override.clone() + .or(option_env!("CFG_PREFIX").map(Path::new)) + .unwrap_or_else(|| { + fail!("built without CFG_PREFIX set; \ + set install prefix via command line.") + })) + } } /// Some reasonable defaults @@ -361,6 +372,7 @@ pub fn basic_options() -> Options { write_dependency_info: (false, None), print_metas: (false, false, false), cg: basic_codegen_options(), + maybe_install_prefix_override: None, } } From 0446ef1c68c769bf8715c64016f8b63252bfd087 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 18:06:49 +0200 Subject: [PATCH 2/9] Include file paths when dumping the list of resolved crates via `debug!`. --- src/librustc/metadata/creader.rs | 9 +++++++-- src/librustc/metadata/cstore.rs | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 916d2a6f07ca2..59b913e8bbeb8 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -17,7 +17,7 @@ use back::svh::Svh; use driver::session::Session; use driver::{driver, session}; use metadata::cstore; -use metadata::cstore::CStore; +use metadata::cstore::{CStore, CrateSource}; use metadata::decoder; use metadata::loader; use metadata::loader::CratePaths; @@ -68,10 +68,15 @@ impl<'a> visit::Visitor<()> for Env<'a> { fn dump_crates(cstore: &CStore) { debug!("resolved crates:"); - cstore.iter_crate_data(|_, data| { + cstore.iter_crate_data_origins(|_, data, opt_source| { debug!("crate_id: {}", data.crate_id()); debug!(" cnum: {}", data.cnum); debug!(" hash: {}", data.hash()); + opt_source.map(|cs| { + let CrateSource { dylib, rlib, cnum: _ } = cs; + dylib.map(|dl| debug!(" dylib: {}", dl.display())); + rlib.map(|rl| debug!(" rlib: {}", rl.display())); + }); }) } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 8e731a98dd7e7..13bddb06e8fcd 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -114,6 +114,17 @@ impl CStore { } } + /// Like `iter_crate_data`, but passes source paths (if available) as well. + pub fn iter_crate_data_origins(&self, i: |ast::CrateNum, + &crate_metadata, + Option|) { + for (&k, v) in self.metas.borrow().iter() { + let origin = self.get_used_crate_source(k); + origin.as_ref().map(|cs| { assert!(k == cs.cnum); }); + i(k, &**v, origin); + } + } + pub fn add_used_crate_source(&self, src: CrateSource) { let mut used_crate_sources = self.used_crate_sources.borrow_mut(); if !used_crate_sources.contains(&src) { From 16f7699a64361633b3275c1f391e0f77647ecce4 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 18:09:37 +0200 Subject: [PATCH 3/9] stage1: use `--install-prefix` to point at stage1 dir instead of `CFG_PREFIX`. --- mk/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/main.mk b/mk/main.mk index 24ab522ec6098..1c1d275cb8d64 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -134,7 +134,7 @@ endif # worry about the distribution of one file (with its native dynamic # dependencies) RUSTFLAGS_STAGE0 += -C prefer-dynamic -RUSTFLAGS_STAGE1 += -C prefer-dynamic +RUSTFLAGS_STAGE1 += -C prefer-dynamic --install-prefix $(CFG_BUILD_DIR)/$(CFG_HOST)/stage1 # platform-specific auto-configuration include $(CFG_SRC_DIR)mk/platform.mk From 2b267b16f11b6e69ef83841f7f17554ce144ec99 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 18:22:23 +0200 Subject: [PATCH 4/9] Refactoring: Introduce distinct host and target rpath var setters. `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 _RPATH_VAR = "=" This should be a pure refactoring apart from the introduction of the two new make environment variables. --- mk/main.mk | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mk/main.mk b/mk/main.mk index 1c1d275cb8d64..5bf98e91ff9c0 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -357,13 +357,19 @@ endef define SREQ_CMDS ifeq ($$(OSTYPE_$(3)),apple-darwin) - RPATH_VAR$(1)_T_$(2)_H_$(3) := \ + HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \ DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))" + TARGET_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) := \ + HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \ LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))" + TARGET_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) := $$(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. @@ -379,13 +385,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 From d89b98ada6a06e380441303599629bd92eaa19f5 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 18:29:46 +0200 Subject: [PATCH 5/9] run-make tests must distinguish between HOST_RPATH and TARGET_RPATH. 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` * 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. I should have tried to fix #13746 but I got distracted, and decided fixing that is orthgonal to the changes in this branch of work. Note that even with these changes, `make check-stage1` still does not work all the way to completion. (It just gets further than it did before, but still breaks down in the `run-make` tests.) --- mk/tests.mk | 3 ++- src/etc/maketest.py | 8 +++++--- src/test/run-make/bootstrap-from-c-with-green/Makefile | 2 +- src/test/run-make/bootstrap-from-c-with-native/Makefile | 2 +- src/test/run-make/c-link-to-rust-dylib/Makefile | 2 +- src/test/run-make/c-link-to-rust-staticlib/Makefile | 2 +- src/test/run-make/lto-smoke-c/Makefile | 2 +- src/test/run-make/tools.mk | 9 +++++++-- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 9fc1c7390ccd0..219b017bd47d2 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -908,7 +908,8 @@ $(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))" + "$$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))" \ + "$$(TARGET_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/etc/maketest.py b/src/etc/maketest.py index 9e8bee3abb6c0..39c2135aad892 100644 --- a/src/etc/maketest.py +++ b/src/etc/maketest.py @@ -23,9 +23,11 @@ os.putenv('CC', sys.argv[5]) os.putenv('RUSTDOC', os.path.abspath(sys.argv[6])) filt = sys.argv[7] -ldpath = sys.argv[8] -if ldpath != '': - os.putenv(ldpath.split('=')[0], ldpath.split('=')[1]) +os.putenv('HOST_RPATH_ENV', sys.argv[8]); +host_ldpath = sys.argv[8] +#if host_ldpath != '': +# os.putenv(host_ldpath.split('=')[0], host_ldpath.split('=')[1]) +os.putenv('TARGET_RPATH_ENV', sys.argv[9]); 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 43388fd9a6f94..33c28258a1eed 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 ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot) - $(CC) main.c -o $(call RUN,main) -lboot + $(CC) main.c -o $(call RUN_BINFILE,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 43388fd9a6f94..33c28258a1eed 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 ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot) - $(CC) main.c -o $(call RUN,main) -lboot + $(CC) main.c -o $(call RUN_BINFILE,main) -lboot $(call RUN,main) rm $(call DYLIB,boot) $(call FAIL,main) diff --git a/src/test/run-make/c-link-to-rust-dylib/Makefile b/src/test/run-make/c-link-to-rust-dylib/Makefile index fb57a08a8261c..e76ab7f7709a0 100644 --- a/src/test/run-make/c-link-to-rust-dylib/Makefile +++ b/src/test/run-make/c-link-to-rust-dylib/Makefile @@ -3,7 +3,7 @@ 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) -Wl,-rpath,$(TMPDIR) $(call RUN,bar) rm $(call DYLIB,foo) $(call FAIL,bar) diff --git a/src/test/run-make/c-link-to-rust-staticlib/Makefile b/src/test/run-make/c-link-to-rust-staticlib/Makefile index 78ac1f66bfcbe..0c6d720dd2e03 100644 --- a/src/test/run-make/c-link-to-rust-staticlib/Makefile +++ b/src/test/run-make/c-link-to-rust-staticlib/Makefile @@ -9,7 +9,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) diff --git a/src/test/run-make/lto-smoke-c/Makefile b/src/test/run-make/lto-smoke-c/Makefile index de8588bac9b7c..5749cfdccbdc6 100644 --- a/src/test/run-make/lto-smoke-c/Makefile +++ b/src/test/run-make/lto-smoke-c/Makefile @@ -15,5 +15,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) diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index 26e6e06c2ed8a..1eb620270cc62 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -4,8 +4,13 @@ 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 +# 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) +# This the basic way we will invoke the generated binary. It sets the +# LD_LIBRARY_PATH environment variable before running the binary. +RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) +FAILS = $(TARGET_RPATH_ENV) ( $(RUN_BINFILE) && exit 1 || exit 0 ) RLIB_GLOB = lib$(1)*.rlib STATICLIB = $(TMPDIR)/lib$(1).a From 530f0e5bdebf8f0298b0fe5c43fd6e65ebc5e545 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 18:33:07 +0200 Subject: [PATCH 6/9] Output debug info on how `#[phase] extern crate foo;` gets resolved. --- src/libsyntax/ext/expand.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 734d07ccb8f9b..5471cea15fc2a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -515,6 +515,9 @@ fn load_extern_macros(krate: &ast::ViewItem, fld: &mut MacroExpander) { None => return }; + debug!("load_extern_macros: mapped crate {} to path {} and registrar {:s}", + crate_name, path.display(), registrar); + let lib = match DynamicLibrary::open(Some(&path)) { Ok(lib) => lib, // this is fatal: there are almost certainly macros we need From 6f51eca2e77e0e7cde7eaf0ef9c96378cf813d85 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 19:50:36 +0200 Subject: [PATCH 7/9] Pass stage 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. --- mk/tests.mk | 3 ++- src/etc/maketest.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mk/tests.mk b/mk/tests.mk index 219b017bd47d2..32dc1d4327ec3 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -909,7 +909,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \ "$$(TESTNAME)" \ "$$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))" \ - "$$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))" + "$$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))" \ + RUST_BUILD_STAGE=$(1) @touch $$@ else # FIXME #11094 - The above rule doesn't work right for multiple targets diff --git a/src/etc/maketest.py b/src/etc/maketest.py index 39c2135aad892..68dfce05659b7 100644 --- a/src/etc/maketest.py +++ b/src/etc/maketest.py @@ -28,6 +28,9 @@ #if host_ldpath != '': # os.putenv(host_ldpath.split('=')[0], host_ldpath.split('=')[1]) os.putenv('TARGET_RPATH_ENV', sys.argv[9]); +rust_build_stage = sys.argv[10]; +if rust_build_stage != '': + os.putenv('RUST_BUILD_STAGE', rust_build_stage.split('=')[1]) if not filt in sys.argv[1]: sys.exit(0) From 4fbfc0bb0c11ea74dcbd6dad9e88ea5376d8e92f Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 19:53:40 +0200 Subject: [PATCH 8/9] Skip these tests at stage1. --- src/test/run-make/lto-syntax-extension/Makefile | 15 ++++++++++++++- src/test/run-make/unicode-input/Makefile | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/test/run-make/lto-syntax-extension/Makefile b/src/test/run-make/lto-syntax-extension/Makefile index 4652556d34401..b79ab11b15d0f 100644 --- a/src/test/run-make/lto-syntax-extension/Makefile +++ b/src/test/run-make/lto-syntax-extension/Makefile @@ -1,6 +1,19 @@ -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= +endif +ifeq ($(RUST_BUILD_STAGE),"2") +DOTEST=dotest +endif + +all: $(DOTEST) + +dotest: + env $(RUSTC) lib.rs $(RUSTC) main.rs -Z lto $(call RUN,main) diff --git a/src/test/run-make/unicode-input/Makefile b/src/test/run-make/unicode-input/Makefile index 2d6ecd3c55efc..6716366947344 100644 --- a/src/test/run-make/unicode-input/Makefile +++ b/src/test/run-make/unicode-input/Makefile @@ -1,6 +1,19 @@ -include ../tools.mk -all: +# 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 muliple_files, and that won't work for stage1. + +ifeq ($(RUST_BUILD_STAGE),"1") +DOTEST= +endif +ifeq ($(RUST_BUILD_STAGE),"2") +DOTEST=dotest +endif + +all: $(DOTEST) + +dotest: # check that we don't ICE on unicode input, issue #11178 $(RUSTC) multiple_files.rs $(call RUN,multiple_files) "$(RUSTC)" "$(TMPDIR)" From f716518f857b75eef50b45bf3ed908ccc5629b46 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 19:56:33 +0200 Subject: [PATCH 9/9] Fix syntactic mistake in earlier definition of FAILS. (Note that most tests are not using FAILS anyway, due to #13746.) --- src/test/run-make/tools.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index 1eb620270cc62..470e36a258f28 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -10,7 +10,7 @@ RUN_BINFILE = $(TMPDIR)/$(1) # This the basic way we will invoke the generated binary. It sets the # LD_LIBRARY_PATH environment variable before running the binary. RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) -FAILS = $(TARGET_RPATH_ENV) ( $(RUN_BINFILE) && exit 1 || exit 0 ) +FAILS = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 RLIB_GLOB = lib$(1)*.rlib STATICLIB = $(TMPDIR)/lib$(1).a