Skip to content

Commit d2f41bd

Browse files
committed
Auto merge of #29151 - wthrowe:linker-output-ICE, r=alexcrichton
I suspect this won't work on Windows, but let's be optimistic and try it before disabling.
2 parents 8d86d1a + a1c8431 commit d2f41bd

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-include ../tools.mk
2+
3+
# Make sure we don't ICE if the linker prints a non-UTF-8 error message.
4+
5+
ifdef IS_WINDOWS
6+
# ignore windows
7+
8+
# This does not work in its current form on windows, possibly due to
9+
# gcc bugs or something about valid Windows paths. See issue #29151
10+
# for more information.
11+
all:
12+
13+
else
14+
15+
# The zzz it to allow humans to tab complete or glob this thing.
16+
bad_dir := $(TMPDIR)/zzz$$'\xff'
17+
18+
all:
19+
$(RUSTC) library.rs
20+
mkdir $(bad_dir)
21+
mv $(TMPDIR)/liblibrary.a $(bad_dir)
22+
LIBRARY_PATH=$(bad_dir) $(RUSTC) exec.rs 2>&1 | grep this_symbol_not_defined
23+
24+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[link(name="library")]
12+
extern "C" {
13+
fn foo();
14+
}
15+
16+
fn main() { unsafe { foo(); } }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "staticlib"]
12+
13+
extern "C" {
14+
fn this_symbol_not_defined();
15+
}
16+
17+
#[no_mangle]
18+
pub extern "C" fn foo() {
19+
unsafe { this_symbol_not_defined(); }
20+
}

0 commit comments

Comments
 (0)