Skip to content

Commit 6abe0ef

Browse files
committed
Make rustc's own lib directory configurable and change the default to rustlib. Fixes #3319
1 parent ea4219f commit 6abe0ef

File tree

11 files changed

+53
-14
lines changed

11 files changed

+53
-14
lines changed

Diff for: Makefile.in

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# stageN - this is the system root, corresponding to, e.g. /usr
3434
# bin - binaries compiled for the host
3535
# lib - libraries used by the host compiler
36-
# rustc - rustc's own place to organize libraries
36+
# rustlib - rustc's own place to organize libraries
3737
# $(target) - target-specific artifacts
3838
# bin - binaries for target architectures
3939
# lib - libraries for target architectures
@@ -415,6 +415,7 @@ export CFG_LLVM_ROOT
415415
export CFG_ENABLE_MINGW_CROSS
416416
export CFG_PREFIX
417417
export CFG_LIBDIR
418+
export CFG_RUSTLIBDIR
418419

419420
######################################################################
420421
# Subprograms
@@ -435,7 +436,7 @@ HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
435436
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
436437

437438
# Destinations of artifacts for target architectures
438-
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
439+
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLIBDIR)/$(2)
439440
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
440441
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
441442

Diff for: configure

+9-2
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ valopt datadir "${CFG_PREFIX}/share" "install data"
398398
valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
399399
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
400400
valopt libdir "${CFG_PREFIX}/lib" "install libraries"
401+
valopt rustlibdir "rustlib" "subdirectory name for rustc's libraries"
401402

402403
# Validate Options
403404
step_msg "validating $CFG_SELF args"
@@ -775,11 +776,16 @@ do
775776
make_dir $h/stage$i/test
776777

777778
# target bin dir
778-
make_dir $h/stage$i/$CFG_LIBDIR/rustc/$t/bin
779+
make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/bin
779780

780781
# target lib dir
781-
make_dir $h/stage$i/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR
782+
make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/$CFG_LIBDIR
782783
done
784+
785+
# Fix stage0:
786+
make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/bin
787+
make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR
788+
783789
done
784790

785791
make_dir $h/test/run-pass
@@ -1031,6 +1037,7 @@ putvar CFG_HOST
10311037
putvar CFG_TARGET
10321038
putvar CFG_C_COMPILER
10331039
putvar CFG_LIBDIR
1040+
putvar CFG_RUSTLIBDIR
10341041
putvar CFG_DISABLE_MANAGE_SUBMODULES
10351042
putvar CFG_ANDROID_CROSS_PATH
10361043
putvar CFG_MINGW32_CROSS_PATH

Diff for: mk/install.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ TB$(1)$(2) = $$(TBIN$$(ISTAGE)_T_$(1)_H_$(2))
7474
TL$(1)$(2) = $$(TLIB$$(ISTAGE)_T_$(1)_H_$(2))
7575

7676
# PT{R,B,L} == Prefix Target {Root, Bin, Lib}
77-
PTR$(1)$(2) = $$(PREFIX_LIB)/rustc/$(1)
77+
PTR$(1)$(2) = $$(PREFIX_LIB)/$(CFG_RUSTLIBDIR)/$(1)
7878
PTB$(1)$(2) = $$(PTR$(1)$(2))/bin
7979
PTL$(1)$(2) = $$(PTR$(1)$(2))/$(CFG_LIBDIR)
8080

Diff for: mk/stage0.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $(SNAPSHOT_RUSTC_POST_CLEANUP): \
1515
# Note: the variable "SNAPSHOT_FILE" is generally not set, and so
1616
# we generally only pass one argument to this script.
1717
ifdef CFG_ENABLE_LOCAL_RUST
18-
$(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD) $(CFG_LOCAL_RUST_ROOT)
18+
$(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD) $(CFG_LOCAL_RUST_ROOT) $(CFG_RUSTLIBDIR)
1919
else
2020
$(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD) $(SNAPSHOT_FILE)
2121
ifdef CFG_ENABLE_PAX_FLAGS

Diff for: mk/target.mk

+20
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
5959
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
6060
| $$(TLIB$(1)_T_$(2)_H_$(3))/
6161
@$$(call E, compile_and_link: $$@)
62+
ifeq ($(1),0)
63+
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
64+
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
65+
endif
6266
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
6367
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
6468
$$(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)): \
7175
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
7276
| $$(TLIB$(1)_T_$(2)_H_$(3))/
7377
@$$(call E, compile_and_link: $$@)
78+
ifeq ($(1),0)
79+
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
80+
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
81+
endif
7482
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
7583
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
7684
$$(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)): \
127135
$$(TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
128136
| $$(TLIB$(1)_T_$(2)_H_$(3))/
129137
@$$(call E, compile_and_link: $$@)
138+
ifeq ($(1),0)
139+
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
140+
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
141+
endif
130142
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
131143
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_RGLOB_$(2)),$$(notdir $$@))
132144
$$(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)): \
152164
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
153165
| $$(TLIB$(1)_T_$(2)_H_$(3))/
154166
@$$(call E, compile_and_link: $$@)
167+
ifeq ($(1),0)
168+
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
169+
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
170+
endif
155171
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
156172
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@))
157173
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
@@ -166,6 +182,10 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \
166182
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
167183
| $$(TBIN$(1)_T_$(2)_H_$(3))/
168184
@$$(call E, compile_and_link: $$@)
185+
ifeq ($(1),0)
186+
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
187+
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
188+
endif
169189
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$<
170190
ifdef CFG_ENABLE_PAX_FLAGS
171191
@$$(call E, apply PaX flags: $$@)

Diff for: mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ifdef CFG_WINDOWSY_$(1)
108108
stage2/$$(CFG_LIBDIR), \
109109
$$(if $$(findstring stage3,$$(1)), \
110110
stage3/$$(CFG_LIBDIR), \
111-
)))))/rustc/$$(CFG_BUILD)/$$(CFG_LIBDIR)
111+
)))))/$$(CFG_RUSTLIBDIR)/$$(CFG_BUILD)/$$(CFG_LIBDIR)
112112
CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
113113
endif
114114

Diff for: src/etc/local_stage0.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
TARG_DIR=$1
44
PREFIX=$2
5+
RUSTLIBDIR=$3
56

67
LIB_DIR=lib
78
LIB_PREFIX=lib
@@ -43,7 +44,7 @@ if [ -z $TARG_DIR ]; then
4344
fi
4445

4546
cp ${PREFIX}/bin/rustc${BIN_SUF} ${TARG_DIR}/stage0/bin/
46-
cp ${PREFIX}/${LIB_DIR}/rustc/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/
47+
cp ${PREFIX}/${LIB_DIR}/${RUSTLIBDIR}/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/
4748
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
4849
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}rust*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
4950
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}std*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/

Diff for: src/librustc/back/rpath.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ mod test {
185185
use back::rpath::{get_absolute_rpath, get_install_prefix_rpath};
186186
use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
187187
use syntax::abi;
188+
use metadata::filesearch;
188189

189190
#[test]
190191
fn test_rpaths_to_flags() {
@@ -196,7 +197,9 @@ mod test {
196197
fn test_prefix_rpath() {
197198
let res = get_install_prefix_rpath("triple");
198199
let mut d = Path::new(env!("CFG_PREFIX"));
199-
d.push("lib/rustc/triple/lib");
200+
d.push("lib");
201+
d.push(filesearch::rustlibdir());
202+
d.push("triple/lib");
200203
debug!("test_prefix_path: {} vs. {}",
201204
res,
202205
d.display());

Diff for: src/librustc/metadata/filesearch.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn relative_target_lib_path(target_triple: &str) -> Path {
157157
let dir = libdir();
158158
let mut p = Path::new(dir.as_slice());
159159
assert!(p.is_relative());
160-
p.push("rustc");
160+
p.push(rustlibdir());
161161
p.push(target_triple);
162162
p.push(dir);
163163
p
@@ -247,3 +247,9 @@ pub fn rust_path() -> ~[Path] {
247247
pub fn libdir() -> ~str {
248248
(env!("CFG_LIBDIR")).to_owned()
249249
}
250+
251+
// The name of rustc's own place to organize libraries.
252+
// Used to be "rustc", now the default is "rustlib"
253+
pub fn rustlibdir() -> ~str {
254+
(env!("CFG_RUSTLIBDIR")).to_owned()
255+
}

Diff for: src/librustpkg/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use extra::workcache;
1414
use rustc::driver::session;
15+
use rustc::metadata::filesearch::rustlibdir;
1516

1617
use std::hashmap::HashSet;
1718

@@ -168,13 +169,13 @@ impl Context {
168169
}
169170
}
170171

171-
/// We assume that if ../../rustc exists, then we're running
172+
/// We assume that if ../../rustlib exists, then we're running
172173
/// rustpkg from a Rust target directory. This is part of a
173174
/// kludgy hack used to adjust the sysroot.
174175
pub fn in_target(sysroot: &Path) -> bool {
175176
debug!("Checking whether {} is in target", sysroot.display());
176177
let mut p = sysroot.dir_path();
177-
p.set_filename("rustc");
178+
p.set_filename(rustlibdir());
178179
p.is_dir()
179180
}
180181

Diff for: src/librustpkg/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use path_util::{target_executable_in_workspace, target_test_in_workspace,
3333
built_library_in_workspace, built_executable_in_workspace, target_build_dir,
3434
chmod_read_only, platform_library_name};
3535
use rustc::back::link::get_cc_prog;
36-
use rustc::metadata::filesearch::rust_path;
36+
use rustc::metadata::filesearch::{rust_path, libdir, rustlibdir};
3737
use rustc::driver::session;
3838
use rustc::driver::driver::{build_session, build_session_options, host_triple, optgroups};
3939
use syntax::diagnostic;
@@ -220,7 +220,7 @@ fn test_sysroot() -> Path {
220220
fn rustpkg_exec() -> Path {
221221
// Ugh
222222
let first_try = test_sysroot().join_many(
223-
[~"lib", ~"rustc", host_triple(), ~"bin", ~"rustpkg"]);
223+
[libdir(), rustlibdir(), host_triple(), ~"bin", ~"rustpkg"]);
224224
if is_executable(&first_try) {
225225
first_try
226226
}

0 commit comments

Comments
 (0)