Skip to content

Commit 5c05841

Browse files
committed
auto merge of #18797 : vadimcn/rust/prefer-bundled2, r=alexcrichton
Based on Windows bundle feedback we got to date, - We *do* want to prefer the bundled linker: The external one might be for the wrong architecture (e.g. 32 bit vs 64 bit). On the other hand, binutils don't add many new features these days, so using an older bundled linker is not likely to be a problem. - We *do* want to prefer bundled libraries: The external ones might not have the symbols we expect (e.g. what's needed for DWARF exceptions vs SjLj). Since `-L rustlib/<triple>/lib` appears first on the linker command line, it's a good place to keep our platform libs that we want to be found first. Closes #18325, closes #17726.
2 parents d962fb0 + cb2328f commit 5c05841

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

src/etc/make-win-dist.py

+45-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def find_files(files, path):
2323
return found
2424

2525
def make_win_dist(dist_root, target_triple):
26-
# Ask gcc where it keeps its' stuff
26+
# Ask gcc where it keeps its stuff
2727
gcc_out = subprocess.check_output(["gcc.exe", "-print-search-dirs"])
2828
bin_path = os.environ["PATH"].split(os.pathsep)
2929
lib_path = []
@@ -42,11 +42,48 @@ def make_win_dist(dist_root, target_triple):
4242
else:
4343
rustc_dlls.append("libgcc_s_seh-1.dll")
4444

45-
target_libs = ["crtbegin.o", "crtend.o", "crt2.o", "dllcrt2.o",
46-
"libadvapi32.a", "libcrypt32.a", "libgcc.a", "libgcc_eh.a", "libgcc_s.a",
47-
"libimagehlp.a", "libiphlpapi.a", "libkernel32.a", "libm.a", "libmingw32.a",
48-
"libmingwex.a", "libmsvcrt.a", "libpsapi.a", "libshell32.a", "libstdc++.a",
49-
"libuser32.a", "libws2_32.a", "libiconv.a", "libmoldname.a"]
45+
target_libs = [ # MinGW libs
46+
"crtbegin.o",
47+
"crtend.o",
48+
"crt2.o",
49+
"dllcrt2.o",
50+
"libgcc.a",
51+
"libgcc_eh.a",
52+
"libgcc_s.a",
53+
"libm.a",
54+
"libmingw32.a",
55+
"libmingwex.a",
56+
"libstdc++.a",
57+
"libiconv.a",
58+
"libmoldname.a",
59+
# Windows import libs
60+
"libadvapi32.a",
61+
"libbcrypt.a",
62+
"libcomctl32.a",
63+
"libcomdlg32.a",
64+
"libcrypt32.a",
65+
"libctl3d32.a",
66+
"libgdi32.a",
67+
"libimagehlp.a",
68+
"libiphlpapi.a",
69+
"libkernel32.a",
70+
"libmsvcrt.a",
71+
"libodbc32.a",
72+
"libole32.a",
73+
"liboleaut32.a",
74+
"libopengl32.a",
75+
"libpsapi.a",
76+
"librpcrt4.a",
77+
"libsetupapi.a",
78+
"libshell32.a",
79+
"libuser32.a",
80+
"libuuid.a",
81+
"libwinhttp.a",
82+
"libwinmm.a",
83+
"libwinspool.a",
84+
"libws2_32.a",
85+
"libwsock32.a",
86+
]
5087

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

6198
# Copy platform tools to platform-specific bin directory
62-
target_bin_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "gcc", "bin")
99+
target_bin_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "bin")
63100
if not os.path.exists(target_bin_dir):
64101
os.makedirs(target_bin_dir)
65102
for src in target_tools:
66103
shutil.copy(src, target_bin_dir)
67104

68105
# Copy platform libs to platform-spcific lib directory
69-
target_lib_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "gcc", "lib")
106+
target_lib_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "lib")
70107
if not os.path.exists(target_lib_dir):
71108
os.makedirs(target_lib_dir)
72109
for src in target_libs:

src/librustc/back/link.rs

-3
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,6 @@ fn link_args(cmd: &mut Command,
890890
cmd.arg(obj_filename.with_extension("metadata.o"));
891891
}
892892

893-
// Rust does its' own LTO
894-
cmd.arg("-fno-lto");
895-
896893
if t.options.is_like_osx {
897894
// The dead_strip option to the linker specifies that functions and data
898895
// unreachable by the entry point will be removed. This is quite useful

src/librustc/driver/driver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ pub fn phase_6_link_output(sess: &Session,
568568
trans: &CrateTranslation,
569569
outputs: &OutputFilenames) {
570570
let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
571-
let mut new_path = os::split_paths(old_path.as_slice());
572-
new_path.extend(sess.host_filesearch().get_tools_search_paths().into_iter());
571+
let mut new_path = sess.host_filesearch().get_tools_search_paths();
572+
new_path.extend(os::split_paths(old_path.as_slice()).into_iter());
573573
os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap());
574574

575575
time(sess.time_passes(), "linking", (), |_|

src/librustc/metadata/filesearch.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,8 @@ impl<'a> FileSearch<'a> {
150150
p.push(find_libdir(self.sysroot));
151151
p.push(rustlibdir());
152152
p.push(self.triple);
153-
let mut p1 = p.clone();
154-
p1.push("bin");
155-
let mut p2 = p.clone();
156-
p2.push("gcc");
157-
p2.push("bin");
158-
vec![p1, p2]
153+
p.push("bin");
154+
vec![p]
159155
}
160156
}
161157

0 commit comments

Comments
 (0)