From 3d9a346aa3ed6fc30e34bd7124e20e77c66cbcb0 Mon Sep 17 00:00:00 2001 From: Vadim Chugunov Date: Sat, 8 Nov 2014 18:32:15 -0800 Subject: [PATCH 1/4] As of 4.9.2, gcc started passing -fno-lto to collect2, or to ld if collect2 cannot be found. The latter is the case for our bundles, because we don't include collect2. Unfortunately, ld does not understand this option and errors out. On the bright side, -fno-use-linker-plugin still works to suppress gcc's LTO, so we can drop -fno-lto. --- src/librustc/back/link.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 58266f2ea32..f88feb94580 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -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 From 5cd4862c69fe6c27010c792aef6cfa053e56c137 Mon Sep 17 00:00:00 2001 From: Vadim Chugunov Date: Sat, 8 Nov 2014 18:24:45 -0800 Subject: [PATCH 2/4] Move gcc back to rustlib\\bin --- src/etc/make-win-dist.py | 6 +++--- src/librustc/metadata/filesearch.rs | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/etc/make-win-dist.py b/src/etc/make-win-dist.py index 9d883dec968..0c3357fa85e 100644 --- a/src/etc/make-win-dist.py +++ b/src/etc/make-win-dist.py @@ -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 = [] @@ -59,14 +59,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: diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 6d938b56303..99e9deb4637 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -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] } } From ad777778d4074a48dbd9fcbcbf6eecce7344db1a Mon Sep 17 00:00:00 2001 From: Vadim Chugunov Date: Sat, 8 Nov 2014 18:26:28 -0800 Subject: [PATCH 3/4] Prefer bundled linker. --- src/librustc/driver/driver.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index d347f113af3..e8a7575f01a 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -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", (), |_| From cb2328f839d3338629ea25e9585074ca2fe2e856 Mon Sep 17 00:00:00 2001 From: Vadim Chugunov Date: Sat, 8 Nov 2014 18:25:57 -0800 Subject: [PATCH 4/4] Include some of the more popular Windows import libs into the bundle. --- src/etc/make-win-dist.py | 47 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/etc/make-win-dist.py b/src/etc/make-win-dist.py index 0c3357fa85e..c4b2d20719f 100644 --- a/src/etc/make-win-dist.py +++ b/src/etc/make-win-dist.py @@ -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)