Skip to content

Commit f5946aa

Browse files
committed
---
yaml --- r: 150001 b: refs/heads/try2 c: 0b3df19 h: refs/heads/master i: 149999: f0cf737 v: v3
1 parent b64cd2f commit f5946aa

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: a921dc487319e926467f8e6afd9900ed2f03aaa9
8+
refs/heads/try2: 0b3df19c6a02a743dae904245c6f98424e75af8c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/back/link.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,23 @@ fn link_args(sess: Session,
10851085
~"-o", out_filename.as_str().unwrap().to_owned(),
10861086
obj_filename.as_str().unwrap().to_owned()]);
10871087

1088+
// Stack growth requires statically linking a __morestack function. Note
1089+
// that this is listed *before* all other libraries, even though it may be
1090+
// used to resolve symbols in other libraries. The only case that this
1091+
// wouldn't be pulled in by the object file is if the object file had no
1092+
// functions.
1093+
//
1094+
// If we're building an executable, there must be at least one function (the
1095+
// main function), and if we're building a dylib then we don't need it for
1096+
// later libraries because they're all dylibs (not rlibs).
1097+
//
1098+
// I'm honestly not entirely sure why this needs to come first. Apparently
1099+
// the --as-needed flag above sometimes strips out libstd from the command
1100+
// line, but inserting this farther to the left makes the
1101+
// "rust_stack_exhausted" symbol an outstanding undefined symbol, which
1102+
// flags libstd as a required library (or whatever provides the symbol).
1103+
args.push(~"-lmorestack");
1104+
10881105
// When linking a dynamic library, we put the metadata into a section of the
10891106
// executable. This metadata is in a separate object file from the main
10901107
// object file, so we link that in here.
@@ -1200,11 +1217,13 @@ fn link_args(sess: Session,
12001217
args.push_all(rpath::get_rpath_flags(sess, out_filename).as_slice());
12011218
}
12021219

1203-
// Stack growth requires statically linking a __morestack function
1204-
args.push(~"-lmorestack");
1205-
// compiler-rt contains implementations of low-level LLVM helpers
1206-
// It should go before platform and user libraries, so it has first dibs
1207-
// at resolving symbols that also appear in libgcc.
1220+
// compiler-rt contains implementations of low-level LLVM helpers. This is
1221+
// used to resolve symbols from the object file we just created, as well as
1222+
// any system static libraries that may be expecting gcc instead. Most
1223+
// symbols in libgcc also appear in compiler-rt.
1224+
//
1225+
// This is the end of the command line, so this library is used to resolve
1226+
// *all* undefined symbols in all other libraries, and this is intentional.
12081227
args.push(~"-lcompiler-rt");
12091228

12101229
// Finally add all the linker arguments provided on the command line along

0 commit comments

Comments
 (0)