Skip to content

Commit 0c131dd

Browse files
committed
---
yaml --- r: 6782 b: refs/heads/master c: f8d06a2 h: refs/heads/master v: v3
1 parent 4af51d2 commit 0c131dd

32 files changed

+212
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 648b69d69229a0a82f09a494a81444a38ba87333
2+
refs/heads/master: f8d06a2a84bd92ff5b32eb5182f48a33fd348bc6

trunk/LICENSE.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,32 @@ included:
223223
details.
224224

225225

226+
* Additional copyright may be retained by contributors other
227+
than Mozilla or the parties enumerated in this file. Such
228+
copyright can be determined on a case-by-case basis by
229+
examining the author of each portion of a file in the
230+
revision-control commit records of the project, or by
231+
consulting representative comments claiming copyright
232+
ownership for a file.
233+
234+
For example, the text:
235+
236+
"Copyright (c) 2011 Google Inc."
237+
238+
appears in some files, and these files thereby denote
239+
that their author and copyright-holder is Google Inc.
240+
241+
In all such cases, the absence of explicit licensing text
242+
indicates that the contributor chose to license their
243+
work for distribution under identical terms to those
244+
Mozilla has chosen for the collective work, enumerated
245+
below. The only difference is the retention of copyright
246+
itself, held by the contributor.
247+
248+
226249
The remaining code and documentation in the collective work
227250
presented here, as well as the collective work itslf, is
228-
distributed under the following terms:
251+
distributed under the following terms ("The Rust License"):
229252

230253
Copyright (c) 2006-2011 Graydon Hoare
231254
Copyright (c) 2009-2011 Mozilla Foundation

trunk/Makefile.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,19 +289,31 @@ ifdef CFG_DISABLE_SHAREDSTD
289289
$$(HLIB$(1)_H_$(3))/libcore.rlib
290290
TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
291291
$$(TLIB$(1)_T_$(2)_H_$(3))/libcore.rlib
292+
292293
HSTDLIB_DEFAULT$(1)_H_$(3) = \
293294
$$(HLIB$(1)_H_$(3))/libstd.rlib
294295
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
295296
$$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
297+
298+
HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
299+
$$(HLIB$(1)_H_$(3))/librustc.rlib
300+
TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
301+
$$(TLIB$(1)_T_$(2)_H_$(3))/librustc.rlib
296302
else
297303
HCORELIB_DEFAULT$(1)_H_$(3) = \
298304
$$(HLIB$(1)_H_$(3))/$(CFG_CORELIB)
299305
TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
300306
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB)
307+
301308
HSTDLIB_DEFAULT$(1)_H_$(3) = \
302309
$$(HLIB$(1)_H_$(3))/$(CFG_STDLIB)
303310
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
304311
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB)
312+
313+
HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
314+
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC)
315+
TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
316+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC)
305317
endif
306318

307319
# Preqrequisites for using the stageN compiler
@@ -311,6 +323,7 @@ HSREQ$(1)_H_$(3) = \
311323
$$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLLVM) \
312324
$$(HCORELIB_DEFAULT$(1)_H_$(3)) \
313325
$$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
326+
$$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \
314327
$$(MKFILE_DEPS)
315328

316329
# Prerequisites for using the stageN compiler to build target artifacts
@@ -324,7 +337,8 @@ TSREQ$(1)_T_$(2)_H_$(3) = \
324337
SREQ$(1)_T_$(2)_H_$(3) = \
325338
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
326339
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
327-
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB)
340+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) \
341+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC)
328342

329343
ifeq ($(1),0)
330344
# Don't run the the stage0 compiler under valgrind - that ship has sailed

trunk/doc/tutorial/ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ microsecond-resolution timer.
189189
use std;
190190
type timeval = {mutable tv_sec: u32,
191191
mutable tv_usec: u32};
192-
#[link_name = ""]
192+
#[nolink]
193193
native mod libc {
194194
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
195195
}
@@ -199,7 +199,7 @@ microsecond-resolution timer.
199199
ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
200200
}
201201

202-
The `#[link_name = ""]` sets the name of the native module to the
202+
The `#[nolink]` sets the name of the native module to the
203203
empty string to prevent the rust compiler from trying to link it.
204204
The standard C library is already linked with Rust programs.
205205

trunk/mk/host.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ $$(HLIB$(2)_H_$(4))/libstd.rlib: \
6868
@$$(call E, cp: $$@)
6969
$$(Q)cp $$< $$@
7070

71+
$$(HLIB$(2)_H_$(4))/librustc.rlib: \
72+
$$(TLIB$(1)_T_$(4)_H_$(3))/librustc.rlib \
73+
$$(HLIB$(2)_H_$(4))/libcore.rlib \
74+
$$(HLIB$(2)_H_$(4))/libstd.rlib \
75+
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME)
76+
@$$(call E, cp: $$@)
77+
$$(Q)cp $$< $$@
78+
7179
$$(HLIB$(2)_H_$(4))/$$(CFG_RUSTLLVM): \
7280
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_RUSTLLVM)
7381
@$$(call E, cp: $$@)

trunk/mk/install.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ install-target-$(1)-host-$(2): $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
4040
$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CORELIB_GLOB))
4141
$$(Q)$$(call INSTALL_LIB, \
4242
$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(STDLIB_GLOB))
43+
$$(Q)$$(call INSTALL_LIB, \
44+
$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(LIBRUSTC_GLOB))
4345
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),intrinsics.bc)
4446
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a)
4547
endef
@@ -66,9 +68,11 @@ install-host: $(SREQ$(ISTAGE)_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE))
6668
$(Q)mkdir -p $(PREFIX_LIB)
6769
$(Q)mkdir -p $(PREFIX_ROOT)/share/man/man1
6870
$(Q)$(call INSTALL,$(HB),$(PHB),rustc$(X))
71+
$(Q)$(call INSTALL,$(HB),$(PHB),cargo$(X))
6972
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME))
7073
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(CORELIB_GLOB))
7174
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(STDLIB_GLOB))
75+
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBRUSTC_GLOB))
7276
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM))
7377
$(Q)$(call INSTALL,$(S)/man, \
7478
$(PREFIX_ROOT)/share/man/man1,rustc.1)

trunk/mk/stage0.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ $(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_STDLIB): \
2121
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
2222
$(Q)touch $@
2323

24+
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_LIBRUSTC): \
25+
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
26+
$(Q)touch $@
27+
2428
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_RUSTLLVM): \
2529
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
2630
$(Q)touch $@
@@ -52,6 +56,11 @@ $$(HLIB0_H_$(1))/$(CFG_STDLIB): \
5256
@$$(call E, cp: $$@)
5357
$$(Q)cp $$(TLIB$(2)_T_$(1)_H_$(3))/$$(STDLIB_GLOB) $$@
5458

59+
$$(HLIB0_H_$(1))/$(CFG_LIBRUSTC): \
60+
$$(TLIB$(2)_T_$(1)_H_$(3))/$$(CFG_LIBRUSTC)
61+
@$$(call E, cp: $$@)
62+
$$(Q)cp $$(TLIB$(2)_T_$(1)_H_$(3))/$$(LIBRUSTC_GLOB) $$@
63+
5564
$$(HLIB0_H_$(1))/$(CFG_RUSTLLVM): \
5665
$$(TLIB$(2)_T_$(1)_H_$(3))/$$(CFG_RUSTLLVM)
5766
@$$(call E, cp: $$@)

trunk/mk/target.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,17 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X): \
4949
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
5050
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
5151
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM) \
52-
$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
52+
$$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
53+
$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
54+
$$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
5355
@$$(call E, compile_and_link: $$@)
5456
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$<
5557

5658
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
5759
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
5860
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
5961
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM) \
62+
$$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
6063
$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
6164
@$$(call E, compile_and_link: $$@)
6265
$$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$< && touch $$@

trunk/src/comp/metadata/creader.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,31 @@ fn visit_item(e: env, i: @ast::item) {
5757
}
5858
either::left(msg) { e.sess.span_fatal(i.span, msg); }
5959
}
60+
6061
let cstore = e.sess.get_cstore();
6162
let native_name = i.ident;
62-
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
63-
some(nn) { native_name = nn; }
64-
none. { }
63+
let already_added = false;
64+
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u {
65+
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
66+
some(nn) { native_name = nn; }
67+
none. { }
68+
}
69+
if native_name == "" {
70+
e.sess.span_fatal(i.span,
71+
"empty #[link_name] not allowed; use #[nolink].");
72+
}
73+
already_added = !cstore::add_used_library(cstore, native_name);
6574
}
66-
if !cstore::add_used_library(cstore, native_name) { ret; }
67-
for a: ast::attribute in
68-
attr::find_attrs_by_name(i.attrs, "link_args") {
69-
75+
let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
76+
if vec::len(link_args) > 0u && already_added {
77+
e.sess.span_fatal(i.span, "library '" + native_name +
78+
"' already added: can't specify link_args.");
79+
}
80+
for a: ast::attribute in link_args {
7081
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
71-
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
82+
some(linkarg) {
83+
cstore::add_used_link_args(cstore, linkarg);
84+
}
7285
none. {/* fallthrough */ }
7386
}
7487
}

trunk/src/comp/metadata/cstore.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ fn get_used_crate_files(cstore: cstore) -> [str] {
9090
}
9191

9292
fn add_used_library(cstore: cstore, lib: str) -> bool {
93-
if lib == "" { ret false; }
93+
assert lib != "";
9494

9595
if vec::member(lib, p(cstore).used_libraries) { ret false; }
96-
9796
p(cstore).used_libraries += [lib];
9897
ret true;
9998
}

trunk/src/etc/snapshot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,24 @@ def scrub(b):
1717

1818
snapshot_files = {
1919
"linux": ["bin/rustc",
20+
"bin/cargo",
2021
"lib/libcore-*.so",
2122
"lib/libstd-*.so",
23+
"lib/librustc-*.so",
2224
"lib/librustrt.so",
2325
"lib/librustllvm.so"],
2426
"macos": ["bin/rustc",
27+
"bin/cargo",
2528
"lib/libcore-*.dylib",
2629
"lib/libstd-*.dylib",
30+
"lib/librustc-*.dylib",
2731
"lib/librustrt.dylib",
2832
"lib/librustllvm.dylib"],
2933
"winnt": ["bin/rustc.exe",
34+
"bin/cargo.exe",
3035
"lib/core-*.dll",
3136
"lib/std-*.dll",
37+
"lib/rustc-*.dll",
3238
"lib/rustrt.dll",
3339
"lib/rustllvm.dll"]
3440
}

trunk/src/libstd/linux_os.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export fsync_fd;
2424
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
2525
// by https://github.com/graydon/rust/issues#issue/268
2626

27-
#[link_name = ""]
27+
#[link_name = ""] // FIXME remove after #[nolink] is snapshotted
28+
#[nolink]
2829
#[abi = "cdecl"]
2930
native mod libc {
3031
fn read(fd: fd_t, buf: *u8, count: size_t) -> ssize_t;

trunk/src/libstd/macos_os.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export fsync_fd;
1818
// FIXME Refactor into unix_os module or some such. Doesn't
1919
// seem to work right now.
2020

21-
#[link_name = ""]
21+
#[link_name = ""] // FIXME: Remove after snapshotting
22+
#[nolink]
2223
#[abi = "cdecl"]
2324
native mod libc {
2425
fn read(fd: fd_t, buf: *u8, count: size_t) -> ssize_t;
@@ -118,7 +119,8 @@ native mod rustrt {
118119

119120
fn getcwd() -> str { ret rustrt::rust_getcwd(); }
120121

121-
#[link_name = ""]
122+
#[link_name = ""] // FIXME remove after #[nolink] is snapshotted
123+
#[nolink]
122124
#[abi = "cdecl"]
123125
native mod mac_libc {
124126
fn _NSGetExecutablePath(buf: str::sbuf,

trunk/src/libstd/win32_os.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import core::option;
22
import ctypes::*;
33

44
#[abi = "cdecl"]
5-
#[link_name = ""]
5+
#[link_name = ""] // FIXME remove after #[nolink] is snapshotted
6+
#[nolink]
67
native mod libc {
78
fn read(fd: fd_t, buf: *u8, count: size_t) -> ssize_t;
89
fn write(fd: fd_t, buf: *u8, count: size_t) -> ssize_t;

trunk/src/rt/arch/i386/morestack.S

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,19 @@ MORESTACK:
6262
#endif
6363

6464
// NB: This can be called with the fastcc convention so we
65-
// have to preserve any argument registers we want to use
65+
// have to preserve any argument registers
66+
67+
// NB: __morestack is called misaligned by 4 bytes, i.e.
68+
// subl $4, %esp would get us to a normal alignment
69+
70+
subl $44,%esp
71+
72+
// Save fastcc arguments
73+
movl %ecx, 28(%esp)
74+
movl %edx, 24(%esp)
6675

6776
// FIXME (1226): main is compiled with the split-stack prologue,
6877
// causing it to call __morestack, so we have to jump back out
69-
subl $28,%esp
7078
calll RUST_GET_TASK
7179
testl %eax,%eax
7280
jz .L$bail
@@ -85,13 +93,13 @@ MORESTACK:
8593
// for the unwinder
8694
leal 20(%ebp), %eax
8795
movl %eax, -4(%ebp)
88-
96+
8997
// The arguments to rust_new_stack2
90-
movl 40(%esp),%eax // Size of stack arguments
98+
movl 56(%esp),%eax // Size of stack arguments
9199
movl %eax,20(%esp)
92-
leal 48(%esp),%eax // Address of stack arguments
100+
leal 64(%esp),%eax // Address of stack arguments
93101
movl %eax,16(%esp)
94-
movl 36(%esp),%eax // The amount of stack needed
102+
movl 52(%esp),%eax // The amount of stack needed
95103
movl %eax,12(%esp)
96104
movl $0, 8(%esp) // Out pointer
97105

@@ -108,19 +116,25 @@ MORESTACK:
108116
movl %eax,(%esp)
109117
call UPCALL_CALL_C
110118

111-
movl 32(%esp),%eax // Grab the return pointer.
119+
movl 48(%esp),%eax // Grab the return pointer.
112120
inc %eax // Skip past the ret instruction in the parent fn
113121

122+
// Restore fastcc arguments
123+
movl 28(%esp), %ecx
124+
movl 24(%esp), %edx
125+
114126
movl 8(%esp),%esp // Switch stacks.
115-
call *%eax // Re-enter the function that called us.
127+
call *%eax // Re-enter the function that called us.
116128

117129
// Now the function that called us has returned, so we need to delete the
118130
// old stack space.
119131

120132
// Switch back to the rust stack
121133
movl %ebp, %esp
122134

123-
subl $8, %esp // Alignment
135+
// Remember that __morestack is called misaligned so %ebp
136+
// is not aligned to a 16-byte boundary, these 4 bytes realign.
137+
subl $4, %esp
124138

125139
// Now that we're on the return path we want to avoid
126140
// stomping on %eax. FIXME: Need to save and restore
@@ -137,7 +151,7 @@ MORESTACK:
137151
pushl $0
138152
call UPCALL_CALL_C
139153

140-
addl $16,%esp
154+
addl $12,%esp
141155

142156
popl %ebp
143157
#if defined(__linux__) || defined(__APPLE__)
@@ -150,7 +164,7 @@ MORESTACK:
150164
movl 32(%esp),%eax
151165
inc %eax
152166

153-
addl $28, %esp
167+
addl $44, %esp
154168
popl %ebp
155169
addl $4+8,%esp
156170

0 commit comments

Comments
 (0)