Skip to content

Commit e889f80

Browse files
committed
Look for standard crates in LIBDIR provided by --libdir option,
not in hardcoded libdir path. If there was no LIBDIR provided during configuration fallback to hardcoded paths. Thanks to Jan Niklas Hasse for solution and to Alex Crichton for improvements. Closes #11671
1 parent 7e43f41 commit e889f80

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

configure

+21-2
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,19 @@ CFG_LIBDIR_RELATIVE=lib
550550
if [ "$CFG_OSTYPE" = "pc-windows-gnu" ]
551551
then
552552
CFG_LIBDIR_RELATIVE=bin
553-
fi
553+
CFG_LIBDIR="${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}"
554+
else
555+
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries (ignored on windows platform)"
556+
557+
case "$CFG_LIBDIR" in
558+
"$CFG_PREFIX"/*) CAT_INC=2;;
559+
"$CFG_PREFIX"*) CAT_INC=1;;
560+
*)
561+
err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
562+
esac
554563

555-
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
564+
CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
565+
fi
556566

557567
if [ $HELP -eq 1 ]
558568
then
@@ -989,6 +999,15 @@ for h in $CFG_HOST
989999
do
9901000
for t in $CFG_TARGET
9911001
do
1002+
# host lib dir stage0
1003+
make_dir $h/stage0/lib
1004+
1005+
# target bin dir stage0
1006+
make_dir $h/stage0/lib/rustlib/$t/bin
1007+
1008+
# target lib dir stage0
1009+
make_dir $h/stage0/lib/rustlib/$t/lib
1010+
9921011
for i in 0 1 2 3
9931012
do
9941013
# host bin dir

mk/main.mk

+8
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,15 @@ define SREQ
332332
# Destinations of artifacts for the host compiler
333333
HROOT$(1)_H_$(3) = $(3)/stage$(1)
334334
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
335+
ifeq ($$(CFG_WINDOWSY_$(3)),1)
335336
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
337+
else
338+
ifeq ($(1),0)
339+
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
340+
else
341+
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
342+
endif
343+
endif
336344

337345
# Destinations of artifacts for target architectures
338346
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)

src/etc/install.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,16 @@ fi
301301
flag uninstall "only uninstall from the installation prefix"
302302
opt verify 1 "verify that the installed binaries run correctly"
303303
valopt prefix "/usr/local" "set installation prefix"
304-
# NB This isn't quite the same definition as in `configure`.
305-
# just using 'lib' instead of CFG_LIBDIR_RELATIVE
304+
# NB This is exactly the same definition as in `configure`.
306305
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
306+
case "$CFG_LIBDIR" in
307+
"$CFG_PREFIX"/*) CAT_INC=2;;
308+
"$CFG_PREFIX"*) CAT_INC=1;;
309+
*)
310+
err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
311+
esac
312+
CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
313+
307314
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
308315

309316
if [ $HELP -eq 1 ]
@@ -428,9 +435,9 @@ while read p; do
428435
# Decide the destination of the file
429436
FILE_INSTALL_PATH="${CFG_PREFIX}/$p"
430437

431-
if echo "$p" | grep "^lib/" > /dev/null
438+
if echo "$p" | grep "^${CFG_LIBDIR_RELATIVE}/" > /dev/null
432439
then
433-
pp=`echo $p | sed 's/^lib\///'`
440+
pp=`echo $p | sed "s%^${CFG_LIBDIR_RELATIVE}/%%"`
434441
FILE_INSTALL_PATH="${CFG_LIBDIR}/$pp"
435442
fi
436443

src/librustc/metadata/filesearch.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,16 @@ fn find_libdir(sysroot: &Path) -> String {
255255
// to lib64/lib32. This would be more foolproof by basing the sysroot off
256256
// of the directory where librustc is located, rather than where the rustc
257257
// binary is.
258-
259-
if sysroot.join(primary_libdir_name()).join(rustlibdir()).exists() {
260-
return primary_libdir_name();
261-
} else {
262-
return secondary_libdir_name();
258+
//If --libdir is set during configuration to the value other than
259+
// "lib" (i.e. non-default), this value is used (see issue #16552).
260+
261+
match option_env!("CFG_LIBDIR_RELATIVE") {
262+
Some(libdir) if libdir != "lib" => return libdir.to_string(),
263+
_ => if sysroot.join(primary_libdir_name()).join(rustlibdir()).exists() {
264+
return primary_libdir_name();
265+
} else {
266+
return secondary_libdir_name();
267+
}
263268
}
264269

265270
#[cfg(target_word_size = "64")]

0 commit comments

Comments
 (0)