Skip to content

Commit 8bb55db

Browse files
committed
auto merge of #9662 : vadimcn/rust/package-runtime-deps, r=brson
This will make sure that system files that rust binaries depend on in Windows get packaged into stage0 snapshots as well as into Windows installer. Currently these include `libgcc_s_dw2-1.dll`, `libstdc++-6.dll` and `libpthread-2.dll`. Note that the latter will need to be changed to `pthreadGC2.dll` once Windows build bots get upgraded to mingw 4.0 Closes #9252 Closes #5878 Closes #9218 Closes #5712
2 parents dfe29e2 + 4e59ab0 commit 8bb55db

File tree

8 files changed

+1288
-3
lines changed

8 files changed

+1288
-3
lines changed

mk/dist.mk

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
6060

6161
$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
6262
$(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
63+
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py i686-pc-mingw32/stage3/bin
6364
@$(call E, ISCC: $@)
6465
$(Q)"$(CFG_ISCC)" $<
6566
endif

src/etc/copy-runtime-deps.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
# xfail-license
3+
4+
# Copies Rust runtime dependencies to the specified directory
5+
6+
import snapshot, sys, os, shutil
7+
8+
def copy_runtime_deps(dest_dir):
9+
for path in snapshot.get_winnt_runtime_deps():
10+
shutil.copy(path, dest_dir)
11+
12+
lic_dest = os.path.join(dest_dir, "third-party")
13+
shutil.rmtree(lic_dest) # copytree() won't overwrite existing files
14+
shutil.copytree(os.path.join(os.path.dirname(__file__), "third-party"), lic_dest)
15+
16+
copy_runtime_deps(sys.argv[1])

src/etc/pkg/rust.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DisableStartupPrompt=true
1919

2020
OutputDir=.\
2121
SourceDir=.\
22-
OutputBaseFilename=rust-{#CFG_VERSION}-install
22+
OutputBaseFilename=rust-{#CFG_VERSION_WIN}-install
2323
DefaultDirName={pf32}\Rust
2424

2525
Compression=lzma2/ultra

src/etc/snapshot.py

+27-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def scrub(b):
5555
"lib/librustllvm.so"]
5656
}
5757

58+
winnt_runtime_deps = ["libgcc_s_dw2-1.dll",
59+
"libstdc++-6.dll",
60+
"libpthread-2.dll"]
61+
5862
def parse_line(n, line):
5963
global snapshotfile
6064

@@ -155,6 +159,19 @@ def hash_file(x):
155159
h.update(open(x, "rb").read())
156160
return scrub(h.hexdigest())
157161

162+
# Returns a list of paths of Rust's system runtime dependencies
163+
def get_winnt_runtime_deps():
164+
runtime_deps = []
165+
path_dirs = os.environ["PATH"].split(';')
166+
for name in winnt_runtime_deps:
167+
for dir in path_dirs:
168+
matches = glob.glob(os.path.join(dir, name))
169+
if matches:
170+
runtime_deps.append(matches[0])
171+
break
172+
else:
173+
raise Exception("Could not find runtime dependency: %s" % name)
174+
return runtime_deps
158175

159176
def make_snapshot(stage, triple):
160177
kernel = get_kernel(triple)
@@ -170,6 +187,7 @@ def in_tar_name(fn):
170187
return os.sep.join(cs[-2:])
171188

172189
tar = tarfile.open(file0, "w:bz2")
190+
173191
for name in snapshot_files[kernel]:
174192
dir = stage
175193
if stage == "stage1" and re.match(r"^lib/(lib)?std.*", name):
@@ -181,8 +199,15 @@ def in_tar_name(fn):
181199
if len(matches) == 1:
182200
tar.add(matches[0], "rust-stage0/" + in_tar_name(matches[0]))
183201
else:
184-
raise Exception("Found stale files: \n %s\n\
185-
Please make a clean build." % "\n ".join(matches))
202+
raise Exception("Found stale files: \n %s\n"
203+
"Please make a clean build." % "\n ".join(matches))
204+
205+
if kernel=="winnt":
206+
for path in get_winnt_runtime_deps():
207+
tar.add(path, "rust-stage0/bin/" + os.path.basename(path))
208+
tar.add(os.path.join(os.path.dirname(__file__), "third-party"),
209+
"rust-stage0/bin/third-party")
210+
186211
tar.close()
187212

188213
h = hash_file(file0)

src/etc/third-party/COPYING.LIB

+482
Large diffs are not rendered by default.

src/etc/third-party/COPYING.RUNTIME

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
GCC RUNTIME LIBRARY EXCEPTION
2+
3+
Version 3.1, 31 March 2009
4+
5+
Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>
6+
7+
Everyone is permitted to copy and distribute verbatim copies of this
8+
license document, but changing it is not allowed.
9+
10+
This GCC Runtime Library Exception ("Exception") is an additional
11+
permission under section 7 of the GNU General Public License, version
12+
3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
13+
bears a notice placed by the copyright holder of the file stating that
14+
the file is governed by GPLv3 along with this Exception.
15+
16+
When you use GCC to compile a program, GCC may combine portions of
17+
certain GCC header files and runtime libraries with the compiled
18+
program. The purpose of this Exception is to allow compilation of
19+
non-GPL (including proprietary) programs to use, in this way, the
20+
header files and runtime libraries covered by this Exception.
21+
22+
0. Definitions.
23+
24+
A file is an "Independent Module" if it either requires the Runtime
25+
Library for execution after a Compilation Process, or makes use of an
26+
interface provided by the Runtime Library, but is not otherwise based
27+
on the Runtime Library.
28+
29+
"GCC" means a version of the GNU Compiler Collection, with or without
30+
modifications, governed by version 3 (or a specified later version) of
31+
the GNU General Public License (GPL) with the option of using any
32+
subsequent versions published by the FSF.
33+
34+
"GPL-compatible Software" is software whose conditions of propagation,
35+
modification and use would permit combination with GCC in accord with
36+
the license of GCC.
37+
38+
"Target Code" refers to output from any compiler for a real or virtual
39+
target processor architecture, in executable form or suitable for
40+
input to an assembler, loader, linker and/or execution
41+
phase. Notwithstanding that, Target Code does not include data in any
42+
format that is used as a compiler intermediate representation, or used
43+
for producing a compiler intermediate representation.
44+
45+
The "Compilation Process" transforms code entirely represented in
46+
non-intermediate languages designed for human-written code, and/or in
47+
Java Virtual Machine byte code, into Target Code. Thus, for example,
48+
use of source code generators and preprocessors need not be considered
49+
part of the Compilation Process, since the Compilation Process can be
50+
understood as starting with the output of the generators or
51+
preprocessors.
52+
53+
A Compilation Process is "Eligible" if it is done using GCC, alone or
54+
with other GPL-compatible software, or if it is done without using any
55+
work based on GCC. For example, using non-GPL-compatible Software to
56+
optimize any GCC intermediate representations would not qualify as an
57+
Eligible Compilation Process.
58+
59+
1. Grant of Additional Permission.
60+
61+
You have permission to propagate a work of Target Code formed by
62+
combining the Runtime Library with Independent Modules, even if such
63+
propagation would otherwise violate the terms of GPLv3, provided that
64+
all Target Code was generated by Eligible Compilation Processes. You
65+
may then convey such a combination under terms of your choice,
66+
consistent with the licensing of the Independent Modules.
67+
68+
2. No Weakening of GCC Copyleft.
69+
70+
The availability of this Exception does not imply any general
71+
presumption that third-party software is unaffected by the copyleft
72+
requirements of the license of GCC.
73+

0 commit comments

Comments
 (0)