1
Fork 0

Use "" in the native_name as an indication that no extra options have to

be passed to the "linker". Use that for libc.
This commit is contained in:
Rafael Ávila de Espíndola 2011-06-28 08:21:13 -04:00
parent 663aa76635
commit ecc080ed0b
10 changed files with 16 additions and 19 deletions

View file

@ -125,6 +125,9 @@ obj session(ast::crate_num cnum,
} }
fn has_external_crate(int num) -> bool { ret crates.contains_key(num); } fn has_external_crate(int num) -> bool { ret crates.contains_key(num); }
fn add_used_library(&str lib) { fn add_used_library(&str lib) {
if (lib == "") {
ret;
}
// A program has a small number of libraries, so a vector is probably // A program has a small number of libraries, so a vector is probably
// a good data structure in here. // a good data structure in here.
for (str l in used_libraries) { for (str l in used_libraries) {

View file

@ -1920,7 +1920,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
expect(p, token::EQ); expect(p, token::EQ);
native_name = parse_str(p); native_name = parse_str(p);
} else { } else {
native_name = ""; native_name = id;
} }
expect(p, token::LBRACE); expect(p, token::LBRACE);
auto m = parse_native_mod_items(p, native_name, abi); auto m = parse_native_mod_items(p, native_name, abi);

View file

@ -203,18 +203,12 @@ fn visit_view_item(env e, &@ast::view_item i) {
fn visit_item(env e, &@ast::item i) { fn visit_item(env e, &@ast::item i) {
alt (i.node) { alt (i.node) {
case (ast::item_native_mod(?m)) { case (ast::item_native_mod(?m)) {
auto name;
if (m.native_name == "" ) {
name = i.ident;
} else {
name = m.native_name;
}
alt (m.abi) { alt (m.abi) {
case (ast::native_abi_rust) { case (ast::native_abi_rust) {
e.sess.add_used_library(name); e.sess.add_used_library(m.native_name);
} }
case (ast::native_abi_cdecl) { case (ast::native_abi_cdecl) {
e.sess.add_used_library(name); e.sess.add_used_library(m.native_name);
} }
case (ast::native_abi_llvm) { case (ast::native_abi_llvm) {
} }

View file

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

View file

@ -2,7 +2,7 @@
import str::sbuf; import str::sbuf;
import vec::vbuf; import vec::vbuf;
native "cdecl" mod libc = "c" { native "cdecl" mod libc = "" {
fn open(sbuf s, int flags, uint mode) -> int; fn open(sbuf s, int flags, uint mode) -> int;
fn read(int fd, vbuf buf, uint count) -> int; fn read(int fd, vbuf buf, uint count) -> int;
fn write(int fd, vbuf buf, uint count) -> int; fn write(int fd, vbuf buf, uint count) -> int;

View file

@ -2,7 +2,7 @@
import str::sbuf; import str::sbuf;
import vec::vbuf; import vec::vbuf;
native "cdecl" mod libc = "c" { native "cdecl" mod libc = "" {
fn open(sbuf s, int flags, uint mode) -> int = "_open"; fn open(sbuf s, int flags, uint mode) -> int = "_open";
fn read(int fd, vbuf buf, uint count) -> int = "_read"; fn read(int fd, vbuf buf, uint count) -> int = "_read";
fn write(int fd, vbuf buf, uint count) -> int = "_write"; fn write(int fd, vbuf buf, uint count) -> int = "_write";

View file

@ -112,7 +112,7 @@ fn test_fn() {
assert (h1 >= h2); assert (h1 >= h2);
} }
native "rust" mod native_mod = "c" { native "rust" mod native_mod = "" {
fn str_byte_len(str s) -> vec[u8]; fn str_byte_len(str s) -> vec[u8];
fn str_alloc(uint n_bytes) -> str; fn str_alloc(uint n_bytes) -> str;
} }

View file

@ -12,7 +12,7 @@ mod a1 { //
} // | | | } // | | |
// | | | // | | |
mod a2 { // | | | mod a2 { // | | |
native mod b1 = "c" { // | | | native mod b1 = "" { // | | |
import a1::b2::*; // | <-/ -/ import a1::b2::*; // | <-/ -/
export word_traveler; // | export word_traveler; // |
} // | } // |

View file

@ -1,6 +1,6 @@
native "cdecl" mod libc = "c" { native "cdecl" mod libc = "" {
type file_handle; type file_handle;
} }

View file

@ -5,14 +5,14 @@ native "rust" mod rustrt {
fn vec_buf[T](vec[T] v, uint offset) -> vbuf; fn vec_buf[T](vec[T] v, uint offset) -> vbuf;
} }
native "rust" mod bar = "c" { } native "rust" mod bar = "" { }
native "cdecl" mod zed = "c" { } native "cdecl" mod zed = "" { }
native "cdecl" mod libc = "c" { native "cdecl" mod libc = "" {
fn write(int fd, rustrt::vbuf buf, uint count) -> int; fn write(int fd, rustrt::vbuf buf, uint count) -> int;
} }
native "cdecl" mod baz = "c" { } native "cdecl" mod baz = "" { }
fn main(vec[str] args) { } fn main(vec[str] args) { }