Skip to content

Commit

Permalink
auto merge of #9662 : vadimcn/rust/package-runtime-deps, r=brson
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 4, 2013
2 parents 6811f50 + 721574d commit 76a1fcc
Show file tree
Hide file tree
Showing 8 changed files with 1,288 additions and 3 deletions.
1 change: 1 addition & 0 deletions mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT

$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
$(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py i686-pc-mingw32/stage3/bin
@$(call E, ISCC: $@)
$(Q)"$(CFG_ISCC)" $<
endif
Expand Down
16 changes: 16 additions & 0 deletions src/etc/copy-runtime-deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# xfail-license

# Copies Rust runtime dependencies to the specified directory

import snapshot, sys, os, shutil

def copy_runtime_deps(dest_dir):
for path in snapshot.get_winnt_runtime_deps():
shutil.copy(path, dest_dir)

lic_dest = os.path.join(dest_dir, "third-party")
shutil.rmtree(lic_dest) # copytree() won't overwrite existing files
shutil.copytree(os.path.join(os.path.dirname(__file__), "third-party"), lic_dest)

copy_runtime_deps(sys.argv[1])
2 changes: 1 addition & 1 deletion src/etc/pkg/rust.iss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DisableStartupPrompt=true

OutputDir=.\
SourceDir=.\
OutputBaseFilename=rust-{#CFG_VERSION}-install
OutputBaseFilename=rust-{#CFG_VERSION_WIN}-install
DefaultDirName={pf32}\Rust

Compression=lzma2/ultra
Expand Down
29 changes: 27 additions & 2 deletions src/etc/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def scrub(b):
"lib/librustllvm.so"]
}

winnt_runtime_deps = ["libgcc_s_dw2-1.dll",
"libstdc++-6.dll",
"libpthread-2.dll"]

def parse_line(n, line):
global snapshotfile

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

# Returns a list of paths of Rust's system runtime dependencies
def get_winnt_runtime_deps():
runtime_deps = []
path_dirs = os.environ["PATH"].split(';')
for name in winnt_runtime_deps:
for dir in path_dirs:
matches = glob.glob(os.path.join(dir, name))
if matches:
runtime_deps.append(matches[0])
break
else:
raise Exception("Could not find runtime dependency: %s" % name)
return runtime_deps

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

tar = tarfile.open(file0, "w:bz2")

for name in snapshot_files[kernel]:
dir = stage
if stage == "stage1" and re.match(r"^lib/(lib)?std.*", name):
Expand All @@ -181,8 +199,15 @@ def in_tar_name(fn):
if len(matches) == 1:
tar.add(matches[0], "rust-stage0/" + in_tar_name(matches[0]))
else:
raise Exception("Found stale files: \n %s\n\
Please make a clean build." % "\n ".join(matches))
raise Exception("Found stale files: \n %s\n"
"Please make a clean build." % "\n ".join(matches))

if kernel=="winnt":
for path in get_winnt_runtime_deps():
tar.add(path, "rust-stage0/bin/" + os.path.basename(path))
tar.add(os.path.join(os.path.dirname(__file__), "third-party"),
"rust-stage0/bin/third-party")

tar.close()

h = hash_file(file0)
Expand Down
482 changes: 482 additions & 0 deletions src/etc/third-party/COPYING.LIB

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions src/etc/third-party/COPYING.RUNTIME
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
GCC RUNTIME LIBRARY EXCEPTION

Version 3.1, 31 March 2009

Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

This GCC Runtime Library Exception ("Exception") is an additional
permission under section 7 of the GNU General Public License, version
3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
bears a notice placed by the copyright holder of the file stating that
the file is governed by GPLv3 along with this Exception.

When you use GCC to compile a program, GCC may combine portions of
certain GCC header files and runtime libraries with the compiled
program. The purpose of this Exception is to allow compilation of
non-GPL (including proprietary) programs to use, in this way, the
header files and runtime libraries covered by this Exception.

0. Definitions.

A file is an "Independent Module" if it either requires the Runtime
Library for execution after a Compilation Process, or makes use of an
interface provided by the Runtime Library, but is not otherwise based
on the Runtime Library.

"GCC" means a version of the GNU Compiler Collection, with or without
modifications, governed by version 3 (or a specified later version) of
the GNU General Public License (GPL) with the option of using any
subsequent versions published by the FSF.

"GPL-compatible Software" is software whose conditions of propagation,
modification and use would permit combination with GCC in accord with
the license of GCC.

"Target Code" refers to output from any compiler for a real or virtual
target processor architecture, in executable form or suitable for
input to an assembler, loader, linker and/or execution
phase. Notwithstanding that, Target Code does not include data in any
format that is used as a compiler intermediate representation, or used
for producing a compiler intermediate representation.

The "Compilation Process" transforms code entirely represented in
non-intermediate languages designed for human-written code, and/or in
Java Virtual Machine byte code, into Target Code. Thus, for example,
use of source code generators and preprocessors need not be considered
part of the Compilation Process, since the Compilation Process can be
understood as starting with the output of the generators or
preprocessors.

A Compilation Process is "Eligible" if it is done using GCC, alone or
with other GPL-compatible software, or if it is done without using any
work based on GCC. For example, using non-GPL-compatible Software to
optimize any GCC intermediate representations would not qualify as an
Eligible Compilation Process.

1. Grant of Additional Permission.

You have permission to propagate a work of Target Code formed by
combining the Runtime Library with Independent Modules, even if such
propagation would otherwise violate the terms of GPLv3, provided that
all Target Code was generated by Eligible Compilation Processes. You
may then convey such a combination under terms of your choice,
consistent with the licensing of the Independent Modules.

2. No Weakening of GCC Copyleft.

The availability of this Exception does not imply any general
presumption that third-party software is unaffected by the copyleft
requirements of the license of GCC.

Loading

0 comments on commit 76a1fcc

Please sign in to comment.