Skip to content

Commit 9e40e43

Browse files
committed
build: Build libraries in the bin directory on win32
1 parent 8466430 commit 9e40e43

File tree

6 files changed

+52
-17
lines changed

6 files changed

+52
-17
lines changed

Makefile.in

+10
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export CFG_HOST_TRIPLE
262262
export CFG_LLVM_ROOT
263263
export CFG_ENABLE_MINGW_CROSS
264264
export CFG_PREFIX
265+
export CFG_LIBDIR
265266

266267
######################################################################
267268
# Subprograms
@@ -279,12 +280,21 @@ define SREQ
279280
# Destinations of artifacts for the host compiler
280281
HROOT$(1)_H_$(3) = $(3)/stage$(1)
281282
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
283+
# FIXME: Temporary hack for moving win32 libs to the bin directory
284+
ifeq ($(1),0)
282285
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
286+
else
287+
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
288+
endif
283289

284290
# Destinations of artifacts for target architectures
285291
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
286292
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
293+
ifeq ($(1),0)
287294
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
295+
else
296+
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
297+
endif
288298

289299
# The name of the core and standard libraries used by rustc
290300
ifdef CFG_DISABLE_SHAREDSTD

configure

+18-3
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ do
397397
done
398398
done
399399

400+
# On windows we just store the libraries in the bin directory because
401+
# there's no rpath
402+
CFG_LIBDIR=lib
403+
if [ "$CFG_OSTYPE" = "pc-mingw32" ]
404+
then
405+
CFG_LIBDIR=bin
406+
fi
407+
400408
for h in $CFG_TARGET_TRIPLES
401409
do
402410
for t in $CFG_TARGET_TRIPLES
@@ -407,13 +415,19 @@ do
407415
make_dir $h/stage$i/bin
408416

409417
# host lib dir
410-
make_dir $h/stage$i/lib
418+
make_dir $h/stage$i/$CFG_LIBDIR
419+
# FIXME: Transitional. remove
420+
make_dir $h/stage$i/lib
411421

412422
# target bin dir
413-
make_dir $h/stage$i/lib/rustc/$t/bin
423+
make_dir $h/stage$i/$CFG_LIBDIR/rustc/$t/bin
424+
# FIXME: Transitional. remove
425+
make_dir $h/stage$i/lib/rustc/$t/bin
414426

415427
# target lib dir
416-
make_dir $h/stage$i/lib/rustc/$t/lib
428+
make_dir $h/stage$i/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR
429+
# FIXME: Transitional. remove
430+
make_dir $h/stage$i/lib/rustc/$t/lib
417431
done
418432
done
419433

@@ -582,6 +596,7 @@ putvar CFG_HOST_TRIPLE
582596
putvar CFG_TARGET_TRIPLES
583597
putvar CFG_C_COMPILER
584598
putvar CFG_PREFIX
599+
putvar CFG_LIBDIR
585600

586601
# Setting this again because it may have been changed
587602
if [ $CFG_DISABLE_MANAGE_SUBMODULES ]

mk/platform.mk

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ endif
108108

109109
CFG_TESTLIB=$(CFG_BUILD_DIR)/$(2)/$(strip \
110110
$(if $(findstring stage0,$(1)), \
111-
stage0/lib, \
111+
stage0/$(CFG_LIBDIR), \
112112
$(if $(findstring stage1,$(1)), \
113-
stage1/lib, \
113+
stage1/$(CFG_LIBDIR), \
114114
$(if $(findstring stage2,$(1)), \
115-
stage2/lib, \
115+
stage2/$(CFG_LIBDIR), \
116116
$(if $(findstring stage3,$(1)), \
117-
stage3/lib, \
118-
)))))/rustc/$(CFG_HOST_TRIPLE)/lib
117+
stage3/$(CFG_LIBDIR), \
118+
)))))/rustc/$(CFG_HOST_TRIPLE)/$(CFG_LIBDIR)
119119

120120
ifdef CFG_UNIXY
121121
CFG_INFO := $(info cfg: unix-y environment)

src/comp/back/rpath.rs

-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ fn minimize_rpaths(rpaths: [str]) -> [str] {
191191
#[cfg(target_os = "linux")]
192192
#[cfg(target_os = "macos")]
193193
#[cfg(target_os = "freebsd")]
194-
#[cfg(test)]
195194
mod test {
196195
#[test]
197196
fn test_rpaths_to_flags() {

src/comp/util/filesearch.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export pick_file;
1616
export search;
1717
export relative_target_lib_path;
1818
export get_cargo_root;
19+
export libdir;
1920

2021
type pick<T> = block(path: fs::path) -> option::t<T>;
2122

@@ -81,7 +82,7 @@ fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
8182
}
8283

8384
fn relative_target_lib_path(target_triple: str) -> [fs::path] {
84-
["lib", "rustc", target_triple, "lib"]
85+
[libdir(), "rustc", target_triple, libdir()]
8586
}
8687

8788
fn make_target_lib_path(sysroot: fs::path,
@@ -122,6 +123,16 @@ fn get_cargo_root() -> result::t<fs::path, str> {
122123

123124
fn get_cargo_lib_path() -> result::t<fs::path, str> {
124125
result::chain(get_cargo_root()) { |p|
125-
result::ok(fs::connect(p, "lib"))
126+
result::ok(fs::connect(p, libdir()))
126127
}
127-
}
128+
}
129+
130+
// The name of the directory rustc expects libraries to be located.
131+
// On Unix should be "lib", on windows "bin"
132+
fn libdir() -> str {
133+
let libdir = #env("CFG_LIBDIR");
134+
if str::is_empty(libdir) {
135+
fail "rustc compiled without CFG_LIBDIR environment variable";
136+
}
137+
libdir
138+
}

src/etc/snapshot.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def scrub(b):
2929
"lib/librustrt.dylib",
3030
"lib/librustllvm.dylib"],
3131
"winnt": ["bin/rustc.exe",
32-
"lib/core-*.dll",
33-
"lib/std-*.dll",
34-
"lib/rustc-*.dll",
35-
"lib/rustrt.dll",
36-
"lib/rustllvm.dll"],
32+
"bin/core-*.dll",
33+
"bin/std-*.dll",
34+
"bin/rustc-*.dll",
35+
"bin/rustrt.dll",
36+
"bin/rustllvm.dll"],
3737
"freebsd": ["bin/rustc",
3838
"lib/libcore-*.so",
3939
"lib/libstd-*.so",

0 commit comments

Comments
 (0)