@@ -1127,6 +1127,33 @@ fn link_args(sess: &Session,
1127
1127
// DWARF stack unwinding will not work.
1128
1128
// This behavior may be overridden by --link-args "-static-libgcc"
1129
1129
args. push ( ~"-shared-libgcc") ;
1130
+
1131
+ // And here, we see obscure linker flags #45. On windows, it has been
1132
+ // found to be necessary to have this flag to compile liblibc.
1133
+ //
1134
+ // First a bit of background. On Windows, the file format is not ELF,
1135
+ // but COFF (at least according to LLVM). COFF doesn't officially allow
1136
+ // for section names over 8 characters, apparently. Our metadata
1137
+ // section, ".note.rustc", you'll note is over 8 characters.
1138
+ //
1139
+ // On more recent versions of gcc on mingw, apparently the section name
1140
+ // is *not* truncated, but rather stored elsewhere in a separate lookup
1141
+ // table. On older versions of gcc, they apparently always truncated the
1142
+ // section names (at least in some cases). Truncating the section name
1143
+ // actually creates "invalid" objects [1] [2], but only for some
1144
+ // introspection tools, not in terms of whether it can be loaded.
1145
+ //
1146
+ // Long story shory, passing this flag forces the linker to *not*
1147
+ // truncate section names (so we can find the metadata section after
1148
+ // it's compiled). The real kicker is that rust compiled just fine on
1149
+ // windows for quite a long time *without* this flag, so I have no idea
1150
+ // why it suddenly started failing for liblibc. Regardless, we
1151
+ // definitely don't want section name truncation, so we're keeping this
1152
+ // flag for windows.
1153
+ //
1154
+ // [1] - https://sourceware.org/bugzilla/show_bug.cgi?id=13130
1155
+ // [2] - https://code.google.com/p/go/issues/detail?id=2139
1156
+ args. push ( ~"-Wl , --enable-long-section-names") ;
1130
1157
}
1131
1158
1132
1159
if sess. targ_cfg . os == abi:: OsAndroid {
0 commit comments