Commit Graph

32093 Commits

Author SHA1 Message Date
Stuart Pernsteiner
1b676fb760 don't leave unwanted temporary files with --emit=ir/asm 2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
b5a0b700c6 use target-specific linker args when combining compilation units 2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
4b70269854 add tests for separate compilation 2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
73f8adcbc8 make separate compilation respect #[inline] attributes
Adjust the handling of `#[inline]` items so that they get translated into every
compilation unit that uses them.  This is necessary to preserve the semantics
of `#[inline(always)]`.

Crate-local `#[inline]` functions and statics are blindly translated into every
compilation unit.  Cross-crate inlined items and monomorphizations of
`#[inline]` functions are translated the first time a reference is seen in each
compilation unit.  When using multiple compilation units, inlined items are
given `available_externally` linkage whenever possible to avoid duplicating
object code.
2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
edc5cdcba2 make symbols internal when possible
Add a post-processing pass to `trans` that converts symbols from external to
internal when possible.  Translation with multiple compilation units initially
makes most symbols external, since it is not clear when translating a
definition whether that symbol will need to be accessed from another
compilation unit.  This final pass internalizes symbols that are not reachable
from other crates and not referenced from other compilation units, so that LLVM
can perform more aggressive optimizations on those symbols.
2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
e09bef810a avoid duplicate translation of monomorphizations, drop glue, and visit glue
Use a shared lookup table of previously-translated monomorphizations/glue
functions to avoid translating those functions in every compilation unit where
they're used.  Instead, the function will be translated in whichever
compilation unit uses it first, and the remaining compilation units will link
against that original definition.
2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
da9606247d translate into multiple llvm contexts
Rotate between compilation units while translating.  The "worker threads"
commit added support for multiple compilation units, but only translated into
one, leaving the rest empty.  With this commit, `trans` rotates between various
compilation units while translating, using a simple stragtegy: upon entering a
module, switch to translating into whichever compilation unit currently
contains the fewest LLVM instructions.

Most of the actual changes here involve getting symbol linkage right, so that
items translated into different compilation units will link together properly
at the end.
2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
2e7bc0f808 reuse original symbols for inlined items
When inlining an item from another crate, use the original symbol from that
crate's metadata instead of generating a new symbol using the `ast::NodeId` of
the inlined copy.  This requires exporting symbols in the crate metadata in a
few additional cases.  Having predictable symbols for inlined items will be
useful later to avoid generating duplicate object code for inlined items.
2014-09-05 09:18:57 -07:00
Stuart Pernsteiner
cf672850df run optimization and codegen on worker threads
Refactor the code in `llvm::back` that invokes LLVM optimization and codegen
passes so that it can be called from worker threads.  (Previously, it used
`&Session` extensively, and `Session` is not `Share`.)  The new code can handle
multiple compilation units, by compiling each unit to `crate.0.o`, `crate.1.o`,
etc., and linking together all the `crate.N.o` files into a single `crate.o`
using `ld -r`.  The later linking steps can then be run unchanged.

The new code preserves the behavior of `--emit`/`-o` when building a single
compilation unit.  With multiple compilation units, the `--emit=asm/ir/bc`
options produce multiple files, so combinations like `--emit=ir -o foo.ll` will
not actually produce `foo.ll` (they instead produce several `foo.N.ll` files).

The new code supports `-Z lto` only when using a single compilation unit.
Compiling with multiple compilation units and `-Z lto` will produce an error.
(I can't think of any good reason to do such a thing.)  Linking with `-Z lto`
against a library that was built as multiple compilation units will also fail,
because the rlib does not contain a `crate.bytecode.deflate` file.  This could
be supported in the future by linking together the `crate.N.bc` files produced
when compiling the library into a single `crate.bc`, or by making the LTO code
support multiple `crate.N.bytecode.deflate` files.
2014-09-05 09:18:55 -07:00
Stuart Pernsteiner
e29aa1430b move back:🔗:write into a separate file 2014-09-05 09:18:55 -07:00
Stuart Pernsteiner
0ab27b1d5b split CrateContext into shared and local pieces
Break up `CrateContext` into `SharedCrateContext` and `LocalCrateContext`.  The
local piece corresponds to a single compilation unit, and contains all
LLVM-related components.  (LLVM data structures are tied to a specific
`LLVMContext`, and we will need separate `LLVMContext`s to safely run
multithreaded optimization.)  The shared piece contains data structures that
need to be shared across all compilation units, such as the `ty::ctxt` and some
tables related to crate metadata.
2014-09-05 09:18:55 -07:00
Stuart Pernsteiner
cf35cb365a make CrateContext fields private 2014-09-05 09:18:53 -07:00
bors
074d3da7b0 auto merge of #16775 : jbcrail/rust/fix-rational-docs, r=pcwalton
Minor corrections to Rational documentation.
2014-09-05 15:46:29 +00:00
Steve Klabnik
d929d83eec don't say compromise
@dherman doesn't like it 😄
2014-09-05 06:38:53 -04:00
Steve Klabnik
12d66e6ac3 Fix formatting in the guide.
Thanks @dherman.
2014-09-05 06:37:22 -04:00
Steve Klabnik
1b9c5e69ba Remove unused diagnostic codes.
Fixes #16449.
2014-09-05 06:08:19 -04:00
NODA, Kai
9e82fc7ef9 rustdoc/html: emphasize the crate part of the full path. 2014-09-05 13:53:22 +08:00
Brendan Zabarauskas
88bd646be0 Make integer bit count methods return uints
Fixes rust-lang/rfcs#224
2014-09-05 14:01:41 +10:00
bors
67b97ab6d2 auto merge of #16843 : bkoropoff/rust/reader-writer-box, r=alexcrichton
Cargo needs this to be able to instantiate `TerminfoTerminal<Box<Writer+'a>>` for 'a other than 'static.
2014-09-05 03:31:07 +00:00
Nick Cameron
2df3a5b0d1 Check concrete type in impls with no trait
closes #16955
2014-09-05 14:38:37 +12:00
Brian Anderson
fc3b6383ba Update fannkuchredux benchmark
From the discussion on reddit:
http://www.reddit.com/r/rust/comments/2fenlg/benchmark_improvement_fannkuchredux/

This adds two variants: the primary, that uses an unsafe block, and a secondary
that is completely safe.

The one with the unsafe block matches clang's performance and beats gcc's.
2014-09-04 18:49:59 -07:00
bors
5248b1187d auto merge of #16990 : DiamondLovesYou/rust/level-derive-clone, r=alexcrichton 2014-09-05 01:21:03 +00:00
Piotr Czarnecki
0ad4644ae1 Work around inability to link lifetime of ref bindings (#16994) 2014-09-05 01:24:04 +01:00
Felix Raimundo
d0f1c7dfb0 Update language item from 'share' to 'sync' #16988 2014-09-05 02:03:26 +02:00
Peter Marheine
0b53cc54e1 collections/slice: Reexport mut_ref_slice in addition to ref_slice. 2014-09-04 17:22:58 -06:00
Piotr Czarnecki
27f87c611f std: Fix overflow of HashMap's capacity 2014-09-04 23:22:32 +01:00
Piotr Czarnecki
ae7342a56a std: Refine and document HashMap's code
* branchless `bucket.next()`
* robin_hood is a free function
* fixed the resize policy that was off by one
* documented the growth algorithm
* updated documentation after interface changes
* removed old fixmes
2014-09-04 23:22:32 +01:00
bors
e024017f60 auto merge of #16986 : bjz/rust/bitflags, r=alexcrichton
Closes #16469
2014-09-04 20:21:02 +00:00
Richard Diamond
0dadd3c3ad Auto-derive Clone for syntax::diagnostic::Level. 2014-09-04 13:31:00 -05:00
bors
d3e7922ddd auto merge of #16982 : jbcrail/rust/comment-and-string-corrections, r=alexcrichton
I corrected spelling and capitalization errors in comments and strings.
2014-09-04 18:30:59 +00:00
Brendan Zabarauskas
ef354d850e Use {} for bitflags! definition and invocations
This looks nicer because it reflects Rust's other syntactic structures.
2014-09-05 03:33:00 +10:00
Brendan Zabarauskas
ff72583891 Attach documentation to the bitflags! macro itself
This is in consistent with the style demonstrated in the std::macros module.
2014-09-05 03:31:45 +10:00
Brendan Zabarauskas
ca60b743d7 Test attributes 2014-09-05 03:31:45 +10:00
Brendan Zabarauskas
f3f038c856 Allow trailing commas in bitflags! macro 2014-09-05 03:31:45 +10:00
bors
bef51ba234 auto merge of #16923 : wickerwaka/rust/crate-as-fixup, r=alexcrichton
Changed occurances of:
extern crate foo = "bar";
to:
extern crate "bar" as foo;

Added warning for old deprecated syntax
2014-09-04 16:40:59 +00:00
bors
4a5a9c5631 auto merge of #16885 : wickerwaka/rust/fmt-center, r=alexcrichton
Use '^' to specify center alignment in format strings.

```
fmt!( "[{:^5s}]", "Hi" ) -> "[ Hi  ]"
fmt!( "[{:^5s}]", "H" )  -> "[  H  ]"
fmt!( "[{:^5d}]", 1i )   -> "[  1  ]"
fmt!( "[{:^5d}]", -1i )  -> "[ -1  ]"
fmt!( "[{:^6d}]", 1i )   -> "[  1   ]"
fmt!( "[{:^6d}]", -1i )  -> "[  -1  ]"
```

If the padding is odd then the padding on the right will be one
character longer than the padding on the left.
2014-09-04 14:50:59 +00:00
wickerwaka
2bc4a5e92a Center alignment for fmt
Use '^' to specify center alignment in format strings.

fmt!( "[{:^5s}]", "Hi" ) -> "[ Hi  ]"
fmt!( "[{:^5s}]", "H" )  -> "[  H  ]"
fmt!( "[{:^5d}]", 1i )   -> "[  1  ]"
fmt!( "[{:^5d}]", -1i )  -> "[ -1  ]"
fmt!( "[{:^6d}]", 1i )   -> "[  1   ]"
fmt!( "[{:^6d}]", -1i )  -> "[  -1  ]"

If the padding is odd then the padding on the right will be one
character longer than the padding on the left.

Tuples squashed
2014-09-04 07:38:53 -07:00
bors
8d5e64f3bc auto merge of #16981 : kmcallister/rust/ctypes-warning, r=alexcrichton 2014-09-04 13:01:00 +00:00
bors
6d8b5c9f7d auto merge of #16976 : treeman/rust/issue-16943, r=kballard
Closes #16943.
2014-09-04 11:11:08 +00:00
bors
85e2e5a900 auto merge of #16964 : nodakai/rust/libnative-superfluous-retry, r=alexcrichton
Those syscalls listed below don't return `EINTR`, so wrapping them with `retry()` is superfluous.

But I admit the current code is better from the viewpoint of difensive programming, given that the overhead of `retry()` is really cheap...

http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatat.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html
2014-09-04 09:21:04 +00:00
Jonas Hietala
38bf999f4a Print file permissions with 4 digits. 2014-09-04 09:01:51 +02:00
bors
5924937a5a auto merge of #16883 : jakub-/rust/issue-16648, r=pcwalton
They were only correct in the simplest case. Some of the optimisations
are certainly possible but should be introduced carefully and only
when the whole pattern codegen infrastructure is in a better shape.

Fixes #16648.
2014-09-04 06:41:04 +00:00
bors
1f49e02d1d auto merge of #16909 : carols10cents/rust/docs-links, r=alexcrichton
This has the primary advantage of not interfering with browser default behavior for links like being able to cmd/ctrl+click on a result to open the result in a new tab but leave the current page as-is (previous behavior both opened a new tab and changed the current tab's location to the result's).

I've done my best to keep the rest of the behavior and the appearance the same-- the whole row still highlights, still has a hand cursor, still moves to the result page with a normal click, arrows+enter still work. If the result is on the current page, the search is simply hidden.

The biggest difference in behavior is that people using tab to navigate through the links will have to hit tab twice for each row, since each cell has its own `a` tag.. I could fix this by switching to `div`s and `span`s instead of a table, but that's potentially more CSS finicky?

The biggest difference in appearance is probably that all the text in the search results is Fira Sans now, instead of just the method name with the rest of the text in Source Serif Pro. I can put this appearance back, but it looks like all links anywhere on the page are Fira Sans. Only the name was in an `a` tag before, but the whole row was ACTING like a link, so I think this is actually more consistent.

[I've pushed these changes to a gh-pages repo](https://carols10cents.github.io/rustdoc-playground/std/index.html?search=t) if you'd like to take a look at the effects; note that I also have my changes for PR #16735 there too so the search results will be sorted differently than on master.
2014-09-04 04:51:05 +00:00
Joseph Crail
b7bfe04b2d Fix spelling errors and capitalization. 2014-09-03 23:10:38 -04:00
bors
c95aa9950f auto merge of #16972 : ruud-v-a/rust/timespec-arithmetic, r=alexcrichton
Changing from `Timespec` to `Duration` introduced a bug for negative durations. This fixes that.
2014-09-04 03:01:03 +00:00
Keegan McAllister
f422de1e85 Use a visitor to look for non-FFI-safe types
Fixes #16250.
2014-09-03 19:28:37 -07:00
Keegan McAllister
7f676b8699 Fix some non-FFI-safe types in externs 2014-09-03 19:01:15 -07:00
bors
d59d97cbec auto merge of #16961 : huonw/rust/bitv-twiddle, r=alexcrichton
bitv: add larger tests, better benchmarks & remove dead code.

There were no tests for iteration etc. with more than 5 elements,
i.e. not even going beyond a single word. This situation is rectified.

Also, the only benchmarks for `set` were with a constant bit value,
which was not indicative of every situation, due to inlining & branch
removal. This adds a benchmark at the other end of the spectrum: random
input.
2014-09-04 01:11:04 +00:00
bors
a4d257b150 auto merge of #16954 : nick29581/rust/dst-bug-deref, r=nikomatsakis
Closes #16930 

r?
2014-09-03 23:21:05 +00:00
Jonas Hietala
fca8a1d151 Print file permissions in octal form.
Closes #16943.
2014-09-03 23:59:22 +02:00