Skip to content

Commit 1a6b6c4

Browse files
committed
Package system runtime dependencies into snapshots
1 parent 7ddcd2a commit 1a6b6c4

File tree

5 files changed

+1270
-2
lines changed

5 files changed

+1270
-2
lines changed

src/etc/snapshot.py

Lines changed: 27 additions & 2 deletions
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)

0 commit comments

Comments
 (0)