Skip to content

Commit 055e2d5

Browse files
committed
---
yaml --- r: 110188 b: refs/heads/auto c: 38f7a1b h: refs/heads/master v: v3
1 parent d073398 commit 055e2d5

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 0459ee77d0c764cc27950465cb19053e1456cc95
16+
refs/heads/auto: 38f7a1b41b0ff9c1bcaec9a892c8ffb64ad6139f
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/liblibc/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
#![allow(missing_doc)]
7676
#![allow(uppercase_variables)]
7777

78+
#![feature(link_args)] // NOTE: remove after stage0
79+
7880
#[cfg(test)] extern crate std;
7981
#[cfg(test)] extern crate test;
8082
#[cfg(test)] extern crate native;
@@ -197,6 +199,11 @@ pub use funcs::posix88::unistd::{rmdir, unlink, write};
197199
#[link(name = "m")]
198200
extern {}
199201

202+
// NOTE: remove this after a stage0 snap
203+
#[cfg(stage0, windows)]
204+
#[link_args = "-Wl,--enable-long-section-names"]
205+
extern {}
206+
200207
/// A wrapper for a nullable pointer. Don't use this except for interacting
201208
/// with libc. Basically Option, but without the dependance on libstd.
202209
// If/when libprim happens, this can be removed in favor of that

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,33 @@ fn link_args(sess: &Session,
11271127
// DWARF stack unwinding will not work.
11281128
// This behavior may be overridden by --link-args "-static-libgcc"
11291129
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");
11301157
}
11311158

11321159
if sess.targ_cfg.os == abi::OsAndroid {

branches/auto/src/test/run-make/lto-smoke-c/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ifneq ($(shell uname),Darwin)
44
EXTRAFLAGS := -lm -lrt -ldl -lpthread
55
endif
66

7+
# Apparently older versions of GCC segfault if -g is passed...
8+
CC := $(CC:-g=)
9+
710
all:
811
$(RUSTC) foo.rs -Z lto
912
ln -s $(call STATICLIB,foo-*) $(call STATICLIB,foo)

branches/auto/src/test/run-make/lto-smoke-c/foo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[crate_type = "staticlib"];
11+
#![crate_type = "staticlib"]
1212

1313
#[no_mangle]
1414
pub extern "C" fn foo() {}

0 commit comments

Comments
 (0)