Skip to content

Commit 749625a

Browse files
committed
Auto merge of #29500 - vadimcn:rustlib, r=alexcrichton
According to a recent [discussion on IRC](https://botbot.me/mozilla/rust-tools/2015-10-27/?msg=52887517&page=2), there's no good reason for Windows builds to store target libraries under `bin`, when on every other platform they are under `lib`. This might be a [breaking-change] for some users. I am pretty sure VisualRust has that path hard-coded somewhere. r? @brson
2 parents e2bb53c + 8cf50bc commit 749625a

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

configure

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -632,18 +632,9 @@ putvar CFG_BUILD # Yes, this creates a duplicate entry, but the last one wins.
632632
CFG_HOST=$(to_llvm_triple $CFG_HOST)
633633
CFG_TARGET=$(to_llvm_triple $CFG_TARGET)
634634

635-
# On windows we just store the libraries in the bin directory because
636-
# there's no rpath. This is where the build system itself puts libraries;
637-
# --libdir is used to configure the installation directory.
638-
# FIXME: This needs to parameterized over target triples. Do it in platform.mk
639-
if [ "$CFG_OSTYPE" = "pc-windows-gnu" ] || [ "$CFG_OSTYPE" = "pc-windows-msvc" ]
640-
then
641-
CFG_LIBDIR_RELATIVE=bin
642-
else
643-
CFG_LIBDIR_RELATIVE=lib
644-
fi
645-
646-
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries (do not set it on windows platform)"
635+
# On Windows this determines root of the subtree for target libraries.
636+
# Host runtime libs always go to 'bin'.
637+
valopt libdir "${CFG_PREFIX}/lib" "install libraries"
647638

648639
case "$CFG_LIBDIR" in
649640
"$CFG_PREFIX"/*) CAT_INC=2;;
@@ -654,11 +645,6 @@ esac
654645

655646
CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
656647

657-
if ( [ "$CFG_OSTYPE" = "pc-windows-gnu" ] || [ "$CFG_OSTYPE" = "pc-windows-msvc" ] ) \
658-
&& [ "$CFG_LIBDIR_RELATIVE" != "bin" ]; then
659-
err "libdir on windows should be set to 'bin'"
660-
fi
661-
662648
if [ $HELP -eq 1 ]
663649
then
664650
echo

mk/main.mk

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,18 +376,29 @@ define SREQ
376376
# Destinations of artifacts for the host compiler
377377
HROOT$(1)_H_$(3) = $(3)/stage$(1)
378378
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
379+
379380
ifeq ($$(CFG_WINDOWSY_$(3)),1)
380-
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
381+
# On Windows we always store host runtime libraries in the 'bin' directory because
382+
# there's no rpath. Target libraries go under $CFG_LIBDIR_RELATIVE (usually 'lib').
383+
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
384+
TROOT$(1)_T_$(2)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)/rustlib/$(2)
385+
# Remove the next 3 lines after a snapshot
386+
ifeq ($(1),0)
387+
RUSTFLAGS_STAGE0 += -L $$(TROOT$(1)_T_$(2)_H_$(3))/lib
388+
endif
389+
381390
else
391+
382392
ifeq ($(1),0)
383393
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
384394
else
385395
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
386396
endif
397+
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)
398+
387399
endif
388400

389401
# Destinations of artifacts for target architectures
390-
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)
391402
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
392403
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
393404

src/etc/make-win-dist.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def find_files(files, path):
3333
return found
3434

3535

36-
def make_win_dist(rust_root, gcc_root, target_triple):
36+
# rust_root - root directory of the host binaries image
37+
# plat_root - root directory of the target platform tools and libs image
38+
# (the two get overlayed on top of each other during installation)
39+
# target_triple - triple of the target image being layed out
40+
def make_win_dist(rust_root, plat_root, target_triple):
3741
# Ask gcc where it keeps its stuff
3842
gcc_out = subprocess.check_output(["gcc.exe", "-print-search-dirs"])
3943
bin_path = os.environ["PATH"].split(os.pathsep)
@@ -107,14 +111,14 @@ def make_win_dist(rust_root, gcc_root, target_triple):
107111
shutil.copy(src, dist_bin_dir)
108112

109113
# Copy platform tools to platform-specific bin directory
110-
target_bin_dir = os.path.join(gcc_root, "bin", "rustlib", target_triple, "bin")
114+
target_bin_dir = os.path.join(plat_root, "lib", "rustlib", target_triple, "bin")
111115
if not os.path.exists(target_bin_dir):
112116
os.makedirs(target_bin_dir)
113117
for src in target_tools:
114118
shutil.copy(src, target_bin_dir)
115119

116120
# Copy platform libs to platform-specific lib directory
117-
target_lib_dir = os.path.join(gcc_root, "bin", "rustlib", target_triple, "lib")
121+
target_lib_dir = os.path.join(plat_root, "lib", "rustlib", target_triple, "lib")
118122
if not os.path.exists(target_lib_dir):
119123
os.makedirs(target_lib_dir)
120124
for src in target_libs:

src/librustc/metadata/filesearch.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ pub fn rust_path() -> Vec<PathBuf> {
258258
}
259259

260260
// The name of the directory rustc expects libraries to be located.
261-
// On Unix should be "lib", on windows "bin"
262-
#[cfg(unix)]
263261
fn find_libdir(sysroot: &Path) -> String {
264262
// FIXME: This is a quick hack to make the rustc binary able to locate
265263
// Rust libraries in Linux environments where libraries might be installed
@@ -293,11 +291,6 @@ fn find_libdir(sysroot: &Path) -> String {
293291
}
294292
}
295293

296-
#[cfg(windows)]
297-
fn find_libdir(_sysroot: &Path) -> String {
298-
"bin".to_string()
299-
}
300-
301294
// The name of rustc's own place to organize libraries.
302295
// Used to be "rustc", now the default is "rustlib"
303296
pub fn rustlibdir() -> String {

0 commit comments

Comments
 (0)