Skip to content

Prefer bundled linker redux #18797

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

Merged
merged 4 commits into from
Nov 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions src/etc/make-win-dist.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ def find_files(files, path):
return found

def make_win_dist(dist_root, target_triple):
# Ask gcc where it keeps its' stuff
# 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 = []
@@ -42,11 +42,48 @@ def make_win_dist(dist_root, target_triple):
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"]
target_libs = [ # MinGW libs
"crtbegin.o",
"crtend.o",
"crt2.o",
"dllcrt2.o",
"libgcc.a",
"libgcc_eh.a",
"libgcc_s.a",
"libm.a",
"libmingw32.a",
"libmingwex.a",
"libstdc++.a",
"libiconv.a",
"libmoldname.a",
# Windows import libs
"libadvapi32.a",
"libbcrypt.a",
"libcomctl32.a",
"libcomdlg32.a",
"libcrypt32.a",
"libctl3d32.a",
"libgdi32.a",
"libimagehlp.a",
"libiphlpapi.a",
"libkernel32.a",
"libmsvcrt.a",
"libodbc32.a",
"libole32.a",
"liboleaut32.a",
"libopengl32.a",
"libpsapi.a",
"librpcrt4.a",
"libsetupapi.a",
"libshell32.a",
"libuser32.a",
"libuuid.a",
"libwinhttp.a",
"libwinmm.a",
"libwinspool.a",
"libws2_32.a",
"libwsock32.a",
]

# Find mingw artifacts we want to bundle
target_tools = find_files(target_tools, bin_path)
@@ -59,14 +96,14 @@ def make_win_dist(dist_root, target_triple):
shutil.copy(src, dist_bin_dir)

# Copy platform tools to platform-specific bin directory
target_bin_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "gcc", "bin")
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, "gcc", "lib")
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:
3 changes: 0 additions & 3 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
@@ -890,9 +890,6 @@ fn link_args(cmd: &mut Command,
cmd.arg(obj_filename.with_extension("metadata.o"));
}

// Rust does its' own LTO
cmd.arg("-fno-lto");

if t.options.is_like_osx {
// The dead_strip option to the linker specifies that functions and data
// unreachable by the entry point will be removed. This is quite useful
4 changes: 2 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
@@ -568,8 +568,8 @@ pub fn phase_6_link_output(sess: &Session,
trans: &CrateTranslation,
outputs: &OutputFilenames) {
let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
let mut new_path = os::split_paths(old_path.as_slice());
new_path.extend(sess.host_filesearch().get_tools_search_paths().into_iter());
let mut new_path = sess.host_filesearch().get_tools_search_paths();
new_path.extend(os::split_paths(old_path.as_slice()).into_iter());
os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap());

time(sess.time_passes(), "linking", (), |_|
8 changes: 2 additions & 6 deletions src/librustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
@@ -150,12 +150,8 @@ impl<'a> FileSearch<'a> {
p.push(find_libdir(self.sysroot));
p.push(rustlibdir());
p.push(self.triple);
let mut p1 = p.clone();
p1.push("bin");
let mut p2 = p.clone();
p2.push("gcc");
p2.push("bin");
vec![p1, p2]
p.push("bin");
vec![p]
}
}