From 6abe0ef32eb88965a7263f8e37a275a408fce5c8 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Sun, 5 Jan 2014 01:55:20 +0000 Subject: [PATCH] Make rustc's own lib directory configurable and change the default to rustlib. Fixes #3319 --- Makefile.in | 5 +++-- configure | 11 +++++++++-- mk/install.mk | 2 +- mk/stage0.mk | 2 +- mk/target.mk | 20 ++++++++++++++++++++ mk/tests.mk | 2 +- src/etc/local_stage0.sh | 3 ++- src/librustc/back/rpath.rs | 5 ++++- src/librustc/metadata/filesearch.rs | 8 +++++++- src/librustpkg/context.rs | 5 +++-- src/librustpkg/tests.rs | 4 ++-- 11 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Makefile.in b/Makefile.in index 230b1d4eaaf..be1d0fc62c2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -33,7 +33,7 @@ # stageN - this is the system root, corresponding to, e.g. /usr # bin - binaries compiled for the host # lib - libraries used by the host compiler -# rustc - rustc's own place to organize libraries +# rustlib - rustc's own place to organize libraries # $(target) - target-specific artifacts # bin - binaries for target architectures # lib - libraries for target architectures @@ -415,6 +415,7 @@ export CFG_LLVM_ROOT export CFG_ENABLE_MINGW_CROSS export CFG_PREFIX export CFG_LIBDIR +export CFG_RUSTLIBDIR ###################################################################### # Subprograms @@ -435,7 +436,7 @@ HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR) # Destinations of artifacts for target architectures -TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2) +TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLIBDIR)/$(2) TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR) diff --git a/configure b/configure index 1e3d8b30e11..89cf5242c33 100755 --- a/configure +++ b/configure @@ -398,6 +398,7 @@ valopt datadir "${CFG_PREFIX}/share" "install data" valopt infodir "${CFG_PREFIX}/share/info" "install additional info" valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH" valopt libdir "${CFG_PREFIX}/lib" "install libraries" +valopt rustlibdir "rustlib" "subdirectory name for rustc's libraries" # Validate Options step_msg "validating $CFG_SELF args" @@ -775,11 +776,16 @@ do make_dir $h/stage$i/test # target bin dir - make_dir $h/stage$i/$CFG_LIBDIR/rustc/$t/bin + make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/bin # target lib dir - make_dir $h/stage$i/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR + make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/$CFG_LIBDIR done + + # Fix stage0: + make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/bin + make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR + done make_dir $h/test/run-pass @@ -1031,6 +1037,7 @@ putvar CFG_HOST putvar CFG_TARGET putvar CFG_C_COMPILER putvar CFG_LIBDIR +putvar CFG_RUSTLIBDIR putvar CFG_DISABLE_MANAGE_SUBMODULES putvar CFG_ANDROID_CROSS_PATH putvar CFG_MINGW32_CROSS_PATH diff --git a/mk/install.mk b/mk/install.mk index f81367010ed..5dc11d6efbf 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -74,7 +74,7 @@ TB$(1)$(2) = $$(TBIN$$(ISTAGE)_T_$(1)_H_$(2)) TL$(1)$(2) = $$(TLIB$$(ISTAGE)_T_$(1)_H_$(2)) # PT{R,B,L} == Prefix Target {Root, Bin, Lib} -PTR$(1)$(2) = $$(PREFIX_LIB)/rustc/$(1) +PTR$(1)$(2) = $$(PREFIX_LIB)/$(CFG_RUSTLIBDIR)/$(1) PTB$(1)$(2) = $$(PTR$(1)$(2))/bin PTL$(1)$(2) = $$(PTR$(1)$(2))/$(CFG_LIBDIR) diff --git a/mk/stage0.mk b/mk/stage0.mk index ddc9ec5ac78..5582e50b7c4 100644 --- a/mk/stage0.mk +++ b/mk/stage0.mk @@ -15,7 +15,7 @@ $(SNAPSHOT_RUSTC_POST_CLEANUP): \ # Note: the variable "SNAPSHOT_FILE" is generally not set, and so # we generally only pass one argument to this script. ifdef CFG_ENABLE_LOCAL_RUST - $(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD) $(CFG_LOCAL_RUST_ROOT) + $(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD) $(CFG_LOCAL_RUST_ROOT) $(CFG_RUSTLIBDIR) else $(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD) $(SNAPSHOT_FILE) ifdef CFG_ENABLE_PAX_FLAGS diff --git a/mk/target.mk b/mk/target.mk index 64bc6ab3afd..293f134fb44 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -59,6 +59,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \ $$(TSREQ$(1)_T_$(2)_H_$(3)) \ | $$(TLIB$(1)_T_$(2)_H_$(3))/ @$$(call E, compile_and_link: $$@) +ifeq ($(1),0) + $$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \ + $(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/ +endif $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@)) $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@)) $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@ @@ -71,6 +75,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \ $$(TSREQ$(1)_T_$(2)_H_$(3)) \ | $$(TLIB$(1)_T_$(2)_H_$(3))/ @$$(call E, compile_and_link: $$@) +ifeq ($(1),0) + $$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \ + $(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/ +endif $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@)) $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@)) $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@ @@ -127,6 +135,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \ $$(TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3)) \ | $$(TLIB$(1)_T_$(2)_H_$(3))/ @$$(call E, compile_and_link: $$@) +ifeq ($(1),0) + $$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \ + $(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/ +endif $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@)) $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_RGLOB_$(2)),$$(notdir $$@)) $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@ @@ -152,6 +164,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \ | $$(TLIB$(1)_T_$(2)_H_$(3))/ @$$(call E, compile_and_link: $$@) +ifeq ($(1),0) + $$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \ + $(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/ +endif $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@)) $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@)) $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \ @@ -166,6 +182,10 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \ | $$(TBIN$(1)_T_$(2)_H_$(3))/ @$$(call E, compile_and_link: $$@) +ifeq ($(1),0) + $$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \ + $(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/ +endif $$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$< ifdef CFG_ENABLE_PAX_FLAGS @$$(call E, apply PaX flags: $$@) diff --git a/mk/tests.mk b/mk/tests.mk index 4573ca3a14f..bfde67dd38a 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -108,7 +108,7 @@ ifdef CFG_WINDOWSY_$(1) stage2/$$(CFG_LIBDIR), \ $$(if $$(findstring stage3,$$(1)), \ stage3/$$(CFG_LIBDIR), \ - )))))/rustc/$$(CFG_BUILD)/$$(CFG_LIBDIR) + )))))/$$(CFG_RUSTLIBDIR)/$$(CFG_BUILD)/$$(CFG_LIBDIR) CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1)) endif diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh index af9f570a8b0..a0785cbad2b 100755 --- a/src/etc/local_stage0.sh +++ b/src/etc/local_stage0.sh @@ -2,6 +2,7 @@ TARG_DIR=$1 PREFIX=$2 +RUSTLIBDIR=$3 LIB_DIR=lib LIB_PREFIX=lib @@ -43,7 +44,7 @@ if [ -z $TARG_DIR ]; then fi cp ${PREFIX}/bin/rustc${BIN_SUF} ${TARG_DIR}/stage0/bin/ -cp ${PREFIX}/${LIB_DIR}/rustc/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/ +cp ${PREFIX}/${LIB_DIR}/${RUSTLIBDIR}/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}rust*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}std*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/ diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 43267a08a14..ecf4dd95cec 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -185,6 +185,7 @@ mod test { use back::rpath::{get_absolute_rpath, get_install_prefix_rpath}; use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output}; use syntax::abi; + use metadata::filesearch; #[test] fn test_rpaths_to_flags() { @@ -196,7 +197,9 @@ fn test_rpaths_to_flags() { fn test_prefix_rpath() { let res = get_install_prefix_rpath("triple"); let mut d = Path::new(env!("CFG_PREFIX")); - d.push("lib/rustc/triple/lib"); + d.push("lib"); + d.push(filesearch::rustlibdir()); + d.push("triple/lib"); debug!("test_prefix_path: {} vs. {}", res, d.display()); diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 692cc12ec6f..3e99cbeb727 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -157,7 +157,7 @@ pub fn relative_target_lib_path(target_triple: &str) -> Path { let dir = libdir(); let mut p = Path::new(dir.as_slice()); assert!(p.is_relative()); - p.push("rustc"); + p.push(rustlibdir()); p.push(target_triple); p.push(dir); p @@ -247,3 +247,9 @@ pub fn rust_path() -> ~[Path] { pub fn libdir() -> ~str { (env!("CFG_LIBDIR")).to_owned() } + +// The name of rustc's own place to organize libraries. +// Used to be "rustc", now the default is "rustlib" +pub fn rustlibdir() -> ~str { + (env!("CFG_RUSTLIBDIR")).to_owned() +} diff --git a/src/librustpkg/context.rs b/src/librustpkg/context.rs index 31515f0cb72..a1b8a48108c 100644 --- a/src/librustpkg/context.rs +++ b/src/librustpkg/context.rs @@ -12,6 +12,7 @@ use extra::workcache; use rustc::driver::session; +use rustc::metadata::filesearch::rustlibdir; use std::hashmap::HashSet; @@ -168,13 +169,13 @@ pub fn add_library_path(&mut self, p: Path) { } } -/// We assume that if ../../rustc exists, then we're running +/// We assume that if ../../rustlib exists, then we're running /// rustpkg from a Rust target directory. This is part of a /// kludgy hack used to adjust the sysroot. pub fn in_target(sysroot: &Path) -> bool { debug!("Checking whether {} is in target", sysroot.display()); let mut p = sysroot.dir_path(); - p.set_filename("rustc"); + p.set_filename(rustlibdir()); p.is_dir() } diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 2ceed4f3df7..ffa5f1e9d5b 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.rs @@ -33,7 +33,7 @@ built_library_in_workspace, built_executable_in_workspace, target_build_dir, chmod_read_only, platform_library_name}; use rustc::back::link::get_cc_prog; -use rustc::metadata::filesearch::rust_path; +use rustc::metadata::filesearch::{rust_path, libdir, rustlibdir}; use rustc::driver::session; use rustc::driver::driver::{build_session, build_session_options, host_triple, optgroups}; use syntax::diagnostic; @@ -220,7 +220,7 @@ fn test_sysroot() -> Path { fn rustpkg_exec() -> Path { // Ugh let first_try = test_sysroot().join_many( - [~"lib", ~"rustc", host_triple(), ~"bin", ~"rustpkg"]); + [libdir(), rustlibdir(), host_triple(), ~"bin", ~"rustpkg"]); if is_executable(&first_try) { first_try }