aboutsummaryrefslogtreecommitdiff
blob: f895e76903e906d43971e70c438806f318d2bd8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
This patch adds proper support for --libdir configure option
See https://github.com/rust-lang/rust/issues/11671 and
https://github.com/rust-lang/rust/pull/16552

diff -r -u rust-0.11.0.orig/configure rust-0.11.0/configure
--- rust-0.11.0.orig/configure
+++ rust-0.11.0/configure
@@ -453,6 +453,14 @@
 
 valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
 
+case "$CFG_LIBDIR" in
+    "$CFG_PREFIX"/*) CAT_INC=2;;
+    "$CFG_PREFIX"*)  CAT_INC=1;;
+    *)
+        err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
+esac
+CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
+
 if [ $HELP -eq 1 ]
 then
     echo
@@ -838,6 +846,15 @@
 do
     for t in $CFG_TARGET
     do
+        # host lib dir stage0
+        make_dir $h/stage0/lib
+
+        # target bin dir stage0
+        make_dir $h/stage0/lib/rustlib/$t/bin
+
+        # target lib dir stage0
+        make_dir $h/stage0/lib/rustlib/$t/lib
+
         for i in 0 1 2 3
         do
             # host bin dir
diff -r -u rust-0.11.0.orig/mk/main.mk rust-0.11.0/mk/main.mk
--- rust-0.11.0.orig/mk/main.mk
+++ rust-0.11.0/mk/main.mk
@@ -304,7 +304,11 @@
 # Destinations of artifacts for the host compiler
 HROOT$(1)_H_$(3) = $(3)/stage$(1)
 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
+ifeq ($(1),0)
+HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
+else
 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
+endif
 
 # Destinations of artifacts for target architectures
 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)
diff -r -u rust-0.11.0.orig/src/etc/install.sh rust-0.11.0/src/etc/install.sh
--- rust-0.11.0.orig/src/etc/install.sh
+++ rust-0.11.0/src/etc/install.sh
@@ -35,6 +35,13 @@
     fi
 }
 
+need_cmd() {
+    if command -v $1 >/dev/null 2>&1
+    then msg "found $1"
+    else err "need $1"
+    fi
+}
+
 putvar() {
     local T
     eval T=\$$1
@@ -198,7 +205,16 @@
     ABSOLUTIFIED="${FILE_PATH}"
 }
 
-CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
+msg "looking for install programs"
+need_cmd mkdir
+need_cmd printf
+need_cmd cut
+need_cmd grep
+need_cmd uname
+need_cmd tr
+need_cmd sed
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
 CFG_SELF="$0"
 CFG_ARGS="$@"
 
@@ -216,16 +232,85 @@
     step_msg "processing $CFG_SELF args"
 fi
 
+# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
+# This logic is duplicated from configure in order to get the correct libdir
+# for Windows installs.
+CFG_OSTYPE=$(uname -s)
+
+case $CFG_OSTYPE in
+
+    MINGW32*)
+        CFG_OSTYPE=pc-mingw32
+        ;;
+
+    MINGW64*)
+        # msys2, MSYSTEM=MINGW64
+        CFG_OSTYPE=w64-mingw32
+        ;;
+
+# Thad's Cygwin identifers below
+
+#   Vista 32 bit
+    CYGWIN_NT-6.0)
+        CFG_OSTYPE=pc-mingw32
+        ;;
+
+#   Vista 64 bit
+    CYGWIN_NT-6.0-WOW64)
+        CFG_OSTYPE=w64-mingw32
+        ;;
+
+#   Win 7 32 bit
+    CYGWIN_NT-6.1)
+        CFG_OSTYPE=pc-mingw32
+        ;;
+
+#   Win 7 64 bit
+    CYGWIN_NT-6.1-WOW64)
+        CFG_OSTYPE=w64-mingw32
+        ;;
+esac
+
 OPTIONS=""
 BOOL_OPTIONS=""
 VAL_OPTIONS=""
 
+# On windows we just store the libraries in the bin directory because
+# there's no rpath. This is where the build system itself puts libraries;
+# --libdir is used to configure the installation directory.
+# FIXME: Thise needs to parameterized over target triples. Do it in platform.mk
+CFG_LIBDIR_RELATIVE=lib
+if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ]
+then
+    CFG_LIBDIR_RELATIVE=bin
+fi
+
+if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ]
+then
+    CFG_LD_PATH_VAR=PATH
+    CFG_OLD_LD_PATH_VAR=$PATH
+elif [ "$CFG_OSTYPE" = "Darwin" ]
+then
+    CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
+    CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
+else
+    CFG_LD_PATH_VAR=LD_LIBRARY_PATH
+    CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
+fi
+
 flag uninstall "only uninstall from the installation prefix"
 opt verify 1 "verify that the installed binaries run correctly"
 valopt prefix "/usr/local" "set installation prefix"
-# NB This isn't quite the same definition as in `configure`.
-# just using 'lib' instead of CFG_LIBDIR_RELATIVE
-valopt libdir "${CFG_PREFIX}/lib" "install libraries"
+# NB This is exactly the same definition as in `configure`.
+valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
+case "$CFG_LIBDIR" in
+    "$CFG_PREFIX"/*) CAT_INC=2;;
+    "$CFG_PREFIX"*)  CAT_INC=1;;
+    *)
+        err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
+esac
+CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
+
 valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
 
 if [ $HELP -eq 1 ]
@@ -247,11 +332,13 @@
     if [ -z "${CFG_UNINSTALL}" ]
     then
         msg "verifying platform can run binaries"
+        export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib":$CFG_OLD_LD_PATH_VAR
         "${CFG_SRC_DIR}/bin/rustc" --version > /dev/null
         if [ $? -ne 0 ]
         then
             err "can't execute rustc binary on this platform"
         fi
+        export $CFG_LD_PATH_VAR=$CFG_OLD_LD_PATH_VAR
     fi
 fi
 
@@ -348,9 +435,9 @@
     # Decide the destination of the file
     FILE_INSTALL_PATH="${CFG_PREFIX}/$p"
 
-    if echo "$p" | grep "^lib/" > /dev/null
+    if echo "$p" | grep "^${CFG_LIBDIR_RELATIVE}/" > /dev/null
     then
-        pp=`echo $p | sed 's/^lib\///'`
+        pp=`echo $p | sed "s%^${CFG_LIBDIR_RELATIVE}/%%"`
         FILE_INSTALL_PATH="${CFG_LIBDIR}/$pp"
     fi
 
@@ -384,24 +471,36 @@
     need_ok "failed to update manifest"
 
 # The manifest lists all files to install
-done < "${CFG_SRC_DIR}/lib/rustlib/manifest.in"
+done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/rustlib/manifest.in"
 
 # Sanity check: can we run the installed binaries?
+#
+# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
+# is in place. Try first without this variable, and if that fails try again with
+# the variable. If the second time tries, print a hopefully helpful message to
+# add something to the appropriate environment variable.
 if [ -z "${CFG_DISABLE_VERIFY}" ]
 then
     msg "verifying installed binaries are executable"
-    "${CFG_PREFIX}/bin/rustc" --version > /dev/null
+    "${CFG_PREFIX}/bin/rustc" --version 2> /dev/null 1> /dev/null
     if [ $? -ne 0 ]
     then
-        ERR="can't execute installed rustc binary. "
-        ERR="${ERR}installation may be broken. "
-        ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
-        ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
-        err "${ERR}"
+        export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib":$CFG_OLD_LD_PATH_VAR
+        "${CFG_PREFIX}/bin/rustc" --version > /dev/null
+        if [ $? -ne 0 ]
+        then
+            ERR="can't execute installed rustc binary. "
+            ERR="${ERR}installation may be broken. "
+            ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
+            ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
+            err "${ERR}"
+        else
+            echo
+            echo "    Note: please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
+        fi
     fi
 fi
 
-
 echo
 echo "    Rust is ready to roll."
 echo
diff -r -u rust-0.11.0.orig/src/librustc/metadata/filesearch.rs rust-0.11.0/src/librustc/metadata/filesearch.rs
--- rust-0.11.0.orig/src/librustc/metadata/filesearch.rs
+++ rust-0.11.0/src/librustc/metadata/filesearch.rs
@@ -243,10 +243,14 @@
     // of the directory where librustc is located, rather than where the rustc
     // binary is.
 
-    if sysroot.join(primary_libdir_name()).join(rustlibdir()).exists() {
-        return primary_libdir_name();
-    } else {
-        return secondary_libdir_name();
+    match option_env!("CFG_LIBDIR_RELATIVE") {
+        None => if sysroot.join(primary_libdir_name()).join(rustlibdir()).exists() {
+            return primary_libdir_name();
+        } else {
+            return secondary_libdir_name();
+        },
+
+        Some(libdir) => return libdir.to_string()
     }
 
     #[cfg(target_word_size = "64")]