Skip to content

Commit 6b398e1

Browse files
committed
Merge pull request #2184 from evanmcc/local_rust
add the configure option --enable-local-rust to pull rust from your environment
2 parents f466a2f + 2c93b1b commit 6b398e1

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

configure

+10-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
294294
opt manage-submodules 1 "let the build manage the git submodules"
295295
opt mingw-cross 0 "cross-compile for win32 using mingw"
296296
opt clang 0 "prefer clang to gcc for building the runtime"
297+
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
297298
valopt prefix "/usr/local" "set installation prefix"
299+
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
298300
valopt llvm-root "" "set LLVM root"
299301
valopt host-triple "${DEFAULT_HOST_TRIPLE}" "LLVM host triple"
300302
valopt target-triples "${CFG_HOST_TRIPLE}" "LLVM target triples"
@@ -337,7 +339,6 @@ probe CFG_XETEX xetex
337339
probe CFG_LUATEX luatex
338340
probe CFG_NODE nodejs node
339341

340-
341342
if [ ! -z "$CFG_PANDOC" ]
342343
then
343344
PV=$(pandoc --version | awk '/^pandoc/ {print $2}')
@@ -348,6 +349,14 @@ then
348349
fi
349350
fi
350351

352+
if [ ! -z "$CFG_ENABLE_LOCAL_RUST" -a ! -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc ]
353+
then
354+
err "no local rust to use"
355+
else
356+
LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version`
357+
step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: " $LRV
358+
fi
359+
351360
if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
352361
then
353362
err "either clang or gcc is required"
@@ -716,7 +725,6 @@ do
716725
putvar $CFG_LLVM_INST_DIR
717726
done
718727

719-
720728
# Munge any paths that appear in config.mk back to posix-y
721729
perl -i.bak -p -e 's@ ([a-zA-Z]):[/\\]@ /\1/@go;' \
722730
-e 's@\\@/@go;' config.tmp

mk/stage0.mk

+6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# Extract the snapshot host compiler
22

3+
4+
35
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X): \
46
$(S)src/snapshots.txt \
57
$(S)src/etc/get-snapshot.py $(MKFILE_DEPS)
68
@$(call E, fetch: $@)
79
# Note: the variable "SNAPSHOT_FILE" is generally not set, and so
810
# we generally only pass one argument to this script.
11+
ifdef CFG_ENABLE_LOCAL_RUST
12+
$(Q)$(S)src/etc/local_stage0.sh $(CFG_HOST_TRIPLE) $(CFG_LOCAL_RUST_ROOT)
13+
else
914
$(Q)$(S)src/etc/get-snapshot.py $(CFG_HOST_TRIPLE) $(SNAPSHOT_FILE)
15+
endif
1016
$(Q)touch $@
1117

1218
# Host libs will be extracted by the above rule

src/etc/local_stage0.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
3+
TARG_DIR=$1
4+
PREFIX=$2
5+
6+
BINDIR=bin
7+
LIBDIR=lib
8+
9+
OS=`uname -s`
10+
case $OS in
11+
("Linux"|"FreeBSD")
12+
BIN_SUF=
13+
LIB_SUF=.so
14+
break
15+
;;
16+
("Darwin")
17+
BIN_SUF=
18+
LIB_SUF=.dylib
19+
break
20+
;;
21+
(*)
22+
BIN_SUF=.exe
23+
LIB_SUF=.dll
24+
LIBDIR=bin
25+
break
26+
;;
27+
esac
28+
29+
if [ -z $PREFIX ]; then
30+
echo "No local rust specified."
31+
exit 1
32+
fi
33+
34+
if [ ! -e ${PREFIX}/bin/rustc ]; then
35+
echo "No local rust installed at ${PREFIX}"
36+
exit 1
37+
fi
38+
39+
if [ -z $TARG_DIR ]; then
40+
echo "No target directory specified."
41+
exit 1
42+
fi
43+
44+
cp ${PREFIX}/bin/rustc ${TARG_DIR}/stage0/bin/
45+
cp ${PREFIX}/lib/rustc/${TARG_DIR}/${LIBDIR}/* ${TARG_DIR}/stage0/${LIBDIR}/
46+
cp ${PREFIX}/lib/librust*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
47+
cp ${PREFIX}/lib/libcore*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
48+
cp ${PREFIX}/lib/libstd*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/

0 commit comments

Comments
 (0)