Skip to content

Commit

Permalink
Fix various places that were affected by adding core as dep of libc
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Sep 25, 2014
1 parent ca8e563 commit 6473909
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
28 changes: 12 additions & 16 deletions src/doc/guide-unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ fn start(_argc: int, _argv: *const *const u8) -> int {
// provided by libstd.
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "sized"] trait Sized { }
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
# // fn main() {} tricked you, rustdoc!
```

Expand All @@ -489,32 +489,28 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int {
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "sized"] trait Sized { }
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
# // fn main() {} tricked you, rustdoc!
```


The compiler currently makes a few assumptions about symbols which are available
in the executable to call. Normally these functions are provided by the standard
xlibrary, but without it you must define your own.
library, but without it you must define your own.

The first of these two functions, `stack_exhausted`, is invoked whenever stack
The first of these three functions, `stack_exhausted`, is invoked whenever stack
overflow is detected. This function has a number of restrictions about how it
can be called and what it must do, but if the stack limit register is not being
maintained then a task always has an "infinite stack" and this function
shouldn't get triggered.

The second of these two functions, `eh_personality`, is used by the failure
mechanisms of the compiler. This is often mapped to GCC's personality function
(see the [libstd implementation](std/rt/unwind/index.html) for more
information), but crates which do not trigger failure can be assured that this
function is never called.

The final item in the example is a trait called `Sized`. This a trait
that represents data of a known static size: it is integral to the
Rust type system, and so the compiler expects the standard library to
provide it. Since you are not using the standard library, you have to
provide it yourself.
The second of these three functions, `eh_personality`, is used by the
failure mechanisms of the compiler. This is often mapped to GCC's
personality function (see the
[libstd implementation](std/rt/unwind/index.html) for more
information), but crates which do not trigger failure can be assured
that this function is never called. The final function, `fail_fmt`, is
also used by the failure mechanisms of the compiler.

## Using libcore

Expand Down Expand Up @@ -694,7 +690,7 @@ fn main(argc: int, argv: *const *const u8) -> int {
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "sized"] trait Sized {}
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
```

Note the use of `abort`: the `exchange_malloc` lang item is assumed to
Expand Down
1 change: 1 addition & 0 deletions src/test/run-make/no-duplicate-libs/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pub extern fn bar() {}

#[lang = "stack_exhausted"] fn stack_exhausted() {}
#[lang = "eh_personality"] fn eh_personality() {}
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
1 change: 1 addition & 0 deletions src/test/run-make/no-duplicate-libs/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pub extern fn foo() {}

#[lang = "stack_exhausted"] fn stack_exhausted() {}
#[lang = "eh_personality"] fn eh_personality() {}
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
2 changes: 1 addition & 1 deletion src/test/run-pass/smallest-hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }

#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "sized"] pub trait Sized {}
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }

#[start]
#[no_split_stack]
Expand Down

5 comments on commit 6473909

@bors
Copy link
Contributor

@bors bors commented on 6473909 Sep 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@6473909

@bors
Copy link
Contributor

@bors bors commented on 6473909 Sep 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/oibt = 6473909 into auto

@bors
Copy link
Contributor

@bors bors commented on 6473909 Sep 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/oibt = 6473909 merged ok, testing candidate = 2550243

@bors
Copy link
Contributor

@bors bors commented on 6473909 Sep 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 6473909 Sep 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 2550243

Please sign in to comment.