-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Package mingw dependencies #16957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package mingw dependencies #16957
Changes from all commits
76c02af
c05ba8a
0ac9e9b
7085b3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT | ||
# file at the top-level directory of this distribution and at | ||
# http://rust-lang.org/COPYRIGHT. | ||
# | ||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
# option. This file may not be copied, modified, or distributed | ||
# except according to those terms. | ||
|
||
import sys, os, shutil, subprocess | ||
|
||
def find_files(files, path): | ||
found = [] | ||
for fname in files: | ||
for dir in path: | ||
filepath = os.path.normpath(os.path.join(dir, fname)) | ||
if os.path.isfile(filepath): | ||
found.append(filepath) | ||
break | ||
else: | ||
raise Exception("Could not find '%s' in %s" % (fname, path)) | ||
return found | ||
|
||
def make_win_dist(dist_root, target_triple): | ||
# Ask gcc where it keeps its' stuff | ||
gcc_out = subprocess.check_output(["gcc.exe", "-print-search-dirs"]) | ||
bin_path = os.environ["PATH"].split(os.pathsep) | ||
lib_path = [] | ||
for line in gcc_out.splitlines(): | ||
key, val = line.split(':', 1) | ||
if key == "programs": | ||
bin_path.extend(val.lstrip(' =').split(';')) | ||
elif key == "libraries": | ||
lib_path.extend(val.lstrip(' =').split(';')) | ||
|
||
target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "windres.exe"] | ||
|
||
rustc_dlls = ["libstdc++-6.dll"] | ||
if target_triple.startswith("i686-"): | ||
rustc_dlls.append("libgcc_s_dw2-1.dll") | ||
else: | ||
rustc_dlls.append("libgcc_s_seh-1.dll") | ||
|
||
target_libs = ["crtbegin.o", "crtend.o", "crt2.o", "dllcrt2.o", | ||
"libadvapi32.a", "libcrypt32.a", "libgcc.a", "libgcc_eh.a", "libgcc_s.a", | ||
"libimagehlp.a", "libiphlpapi.a", "libkernel32.a", "libm.a", "libmingw32.a", | ||
"libmingwex.a", "libmsvcrt.a", "libpsapi.a", "libshell32.a", "libstdc++.a", | ||
"libuser32.a", "libws2_32.a", "libiconv.a", "libmoldname.a"] | ||
|
||
# Find mingw artifacts we want to bundle | ||
target_tools = find_files(target_tools, bin_path) | ||
rustc_dlls = find_files(rustc_dlls, bin_path) | ||
target_libs = find_files(target_libs, lib_path) | ||
|
||
# Copy runtime dlls next to rustc.exe | ||
dist_bin_dir = os.path.join(dist_root, "bin") | ||
for src in rustc_dlls: | ||
shutil.copy(src, dist_bin_dir) | ||
|
||
# Copy platform tools (and another copy of runtime dlls) to platform-spcific bin directory | ||
target_bin_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "bin") | ||
if not os.path.exists(target_bin_dir): | ||
os.makedirs(target_bin_dir) | ||
for src in target_tools: | ||
shutil.copy(src, target_bin_dir) | ||
|
||
# Copy platform libs to platform-spcific lib directory | ||
target_lib_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "lib") | ||
if not os.path.exists(target_lib_dir): | ||
os.makedirs(target_lib_dir) | ||
for src in target_libs: | ||
shutil.copy(src, target_lib_dir) | ||
|
||
# Copy license files | ||
lic_dir = os.path.join(dist_root, "bin", "third-party") | ||
if os.path.exists(lic_dir): | ||
shutil.rmtree(lic_dir) # copytree() won't overwrite existing files | ||
shutil.copytree(os.path.join(os.path.dirname(__file__), "third-party"), lic_dir) | ||
|
||
if __name__=="__main__": | ||
make_win_dist(sys.argv[1], sys.argv[2]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
Certain files in this distribution are covered by a different license than the rest of the Rust Project. | ||
Specifically: | ||
Certain binaries in this distribution do not originate from the Rust project, but are distributed with it in its binary form. These binaries, including gcc and other parts of the GNU compiler toolchain, are licensed either under the terms of the GNU General Public License, or the GNU General Public License with the GCC Runtime Library Exception, as published by the Free Software Foundation, either version 3, or (at your option) any later version. See the files COPYING3 and COPYING.RUNTIME respectively. | ||
|
||
- libgcc_s_dw2-1.dll and libstdc++6.dll are distributed under the terms of the GNU General Public License | ||
with the GCC Runtime Library Exception as published by the Free Software Foundation; either version 3, | ||
or (at your option) any later version. See the files COPYING3 and COPYING.RUNTIME respectively. | ||
You can obtain a copy of the source of these libraries either here: http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.5.2-1/, | ||
or from the project website at http://gcc.gnu.org | ||
You can obtain a copy of the source of these libraries from the MinGW-w64 project[1]. | ||
|
||
[1]: http://mingw-w64.sourceforge.net/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -929,6 +929,9 @@ fn link_args(cmd: &mut Command, | |
cmd.arg("-nodefaultlibs"); | ||
} | ||
|
||
// Rust does its' own LTO | ||
cmd.arg("-fno-lto").arg("-fno-use-linker-plugin"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we only run these on windows, or is this ok for all invocations of gcc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LTO is off by default, so why does this need to be done? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexcrichton: I think this is ok for all platforms. That'll be one less gcc dependency to worry about if we ever switch to direct linker invocation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This breaks clang builds on OSX since clang doesn't know the argument: -fno-use-linker-plugin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to work around this with Not sure what to do about this in the long term. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can clang vs gcc be detected before the option is passed? If it's known which one is being called, then this can be passed to gcc but not clang. |
||
|
||
// If we're building a dylib, we don't use --gc-sections because LLVM has | ||
// already done the best it can do, and we also don't want to eliminate the | ||
// metadata. If we're building an executable, however, --gc-sections drops | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, I would have thought that some dlls were needed to run these!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, they are all self-contained.