Skip to content

Commit ecc080e

Browse files
committed
Use "" in the native_name as an indication that no extra options have to
be passed to the "linker". Use that for libc.
1 parent 663aa76 commit ecc080e

File tree

10 files changed

+16
-19
lines changed

10 files changed

+16
-19
lines changed

src/comp/driver/session.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ obj session(ast::crate_num cnum,
125125
}
126126
fn has_external_crate(int num) -> bool { ret crates.contains_key(num); }
127127
fn add_used_library(&str lib) {
128+
if (lib == "") {
129+
ret;
130+
}
128131
// A program has a small number of libraries, so a vector is probably
129132
// a good data structure in here.
130133
for (str l in used_libraries) {

src/comp/front/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
19201920
expect(p, token::EQ);
19211921
native_name = parse_str(p);
19221922
} else {
1923-
native_name = "";
1923+
native_name = id;
19241924
}
19251925
expect(p, token::LBRACE);
19261926
auto m = parse_native_mod_items(p, native_name, abi);

src/comp/metadata/creader.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,12 @@ fn visit_view_item(env e, &@ast::view_item i) {
203203
fn visit_item(env e, &@ast::item i) {
204204
alt (i.node) {
205205
case (ast::item_native_mod(?m)) {
206-
auto name;
207-
if (m.native_name == "" ) {
208-
name = i.ident;
209-
} else {
210-
name = m.native_name;
211-
}
212206
alt (m.abi) {
213207
case (ast::native_abi_rust) {
214-
e.sess.add_used_library(name);
208+
e.sess.add_used_library(m.native_name);
215209
}
216210
case (ast::native_abi_cdecl) {
217-
e.sess.add_used_library(name);
211+
e.sess.add_used_library(m.native_name);
218212
}
219213
case (ast::native_abi_llvm) {
220214
}

src/lib/linux_os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import vec::vbuf;
55

66
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
77
// by https://github.com/graydon/rust/issues#issue/268
8-
native "cdecl" mod libc = "c" {
8+
native "cdecl" mod libc = "" {
99
fn open(sbuf s, int flags, uint mode) -> int;
1010
fn read(int fd, vbuf buf, uint count) -> int;
1111
fn write(int fd, vbuf buf, uint count) -> int;

src/lib/macos_os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import str::sbuf;
33
import vec::vbuf;
44

5-
native "cdecl" mod libc = "c" {
5+
native "cdecl" mod libc = "" {
66
fn open(sbuf s, int flags, uint mode) -> int;
77
fn read(int fd, vbuf buf, uint count) -> int;
88
fn write(int fd, vbuf buf, uint count) -> int;

src/lib/win32_os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import str::sbuf;
33
import vec::vbuf;
44

5-
native "cdecl" mod libc = "c" {
5+
native "cdecl" mod libc = "" {
66
fn open(sbuf s, int flags, uint mode) -> int = "_open";
77
fn read(int fd, vbuf buf, uint count) -> int = "_read";
88
fn write(int fd, vbuf buf, uint count) -> int = "_write";

src/test/run-pass/binops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn test_fn() {
112112
assert (h1 >= h2);
113113
}
114114

115-
native "rust" mod native_mod = "c" {
115+
native "rust" mod native_mod = "" {
116116
fn str_byte_len(str s) -> vec[u8];
117117
fn str_alloc(uint n_bytes) -> str;
118118
}

src/test/run-pass/import-glob-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod a1 { //
1212
} // | | |
1313
// | | |
1414
mod a2 { // | | |
15-
native mod b1 = "c" { // | | |
15+
native mod b1 = "" { // | | |
1616
import a1::b2::*; // | <-/ -/
1717
export word_traveler; // |
1818
} // |

src/test/run-pass/native-opaque-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
native "cdecl" mod libc = "c" {
3+
native "cdecl" mod libc = "" {
44
type file_handle;
55
}
66

src/test/run-pass/native2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ native "rust" mod rustrt {
55
fn vec_buf[T](vec[T] v, uint offset) -> vbuf;
66
}
77

8-
native "rust" mod bar = "c" { }
8+
native "rust" mod bar = "" { }
99

10-
native "cdecl" mod zed = "c" { }
10+
native "cdecl" mod zed = "" { }
1111

12-
native "cdecl" mod libc = "c" {
12+
native "cdecl" mod libc = "" {
1313
fn write(int fd, rustrt::vbuf buf, uint count) -> int;
1414
}
1515

16-
native "cdecl" mod baz = "c" { }
16+
native "cdecl" mod baz = "" { }
1717

1818
fn main(vec[str] args) { }

0 commit comments

Comments
 (0)