Commit Graph

326 Commits

Author SHA1 Message Date
Daniel Micay
4deb4bcba5 optimize position independent code in executables
Position independent code has fewer requirements in executables, so pass
the appropriate flag to LLVM in order to allow more optimization. At the
moment this means faster thread-local storage.
2014-10-12 09:18:14 -04:00
bors
f9fc49c06e auto merge of #17853 : alexcrichton/rust/issue-17718, r=pcwalton
This change is an implementation of [RFC 69][rfc] which adds a third kind of
global to the language, `const`. This global is most similar to what the old
`static` was, and if you're unsure about what to use then you should use a
`const`.

The semantics of these three kinds of globals are:

* A `const` does not represent a memory location, but only a value. Constants
  are translated as rvalues, which means that their values are directly inlined
  at usage location (similar to a #define in C/C++). Constant values are, well,
  constant, and can not be modified. Any "modification" is actually a
  modification to a local value on the stack rather than the actual constant
  itself.

  Almost all values are allowed inside constants, whether they have interior
  mutability or not. There are a few minor restrictions listed in the RFC, but
  they should in general not come up too often.

* A `static` now always represents a memory location (unconditionally). Any
  references to the same `static` are actually a reference to the same memory
  location. Only values whose types ascribe to `Sync` are allowed in a `static`.
  This restriction is in place because many threads may access a `static`
  concurrently. Lifting this restriction (and allowing unsafe access) is a
  future extension not implemented at this time.

* A `static mut` continues to always represent a memory location. All references
  to a `static mut` continue to be `unsafe`.

This is a large breaking change, and many programs will need to be updated
accordingly. A summary of the breaking changes is:

* Statics may no longer be used in patterns. Statics now always represent a
  memory location, which can sometimes be modified. To fix code, repurpose the
  matched-on-`static` to a `const`.

      static FOO: uint = 4;
      match n {
          FOO => { /* ... */ }
          _ => { /* ... */ }
      }

  change this code to:

      const FOO: uint = 4;
      match n {
          FOO => { /* ... */ }
          _ => { /* ... */ }
      }

* Statics may no longer refer to other statics by value. Due to statics being
  able to change at runtime, allowing them to reference one another could
  possibly lead to confusing semantics. If you are in this situation, use a
  constant initializer instead. Note, however, that statics may reference other
  statics by address, however.

* Statics may no longer be used in constant expressions, such as array lengths.
  This is due to the same restrictions as listed above. Use a `const` instead.

[breaking-change]
Closes #17718 

[rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-10 00:07:08 +00:00
Brian Anderson
5c92a8e054 Use the same html_root_url for all docs 2014-10-09 10:50:13 -07:00
Alex Crichton
831f909484 rustc: Convert statics to constants 2014-10-09 09:44:51 -07:00
Luqman Aden
4b22178d32 Update LLVM. 2014-10-04 13:28:57 -04:00
Keegan McAllister
9d60de93e2 Translate inline assembly errors back to source locations
Fixes #17552.
2014-09-27 11:10:37 -07:00
Patrick Walton
e9ad12c0ca librustc: Forbid private types in public APIs.
This breaks code like:

    struct Foo {
        ...
    }

    pub fn make_foo() -> Foo {
        ...
    }

Change this code to:

    pub struct Foo {    // note `pub`
        ...
    }

    pub fn make_foo() -> Foo {
        ...
    }

The `visible_private_types` lint has been removed, since it is now an
error to attempt to expose a private type in a public API. In its place
a `#[feature(visible_private_types)]` gate has been added.

Closes #16463.

RFC #48.

[breaking-change]
2014-09-22 20:05:45 -07:00
Alex Crichton
f082416bec Test fixes from the rollup 2014-09-19 19:58:14 -07:00
Alex Crichton
04f5fe5a08 rollup merge of #17338 : nick29581/variants-namespace 2014-09-19 10:00:29 -07:00
Ahmed Charles
0f6cbcaa88 Move uses of enum to bitflags!.
There are still others, but this is the first batch.
2014-09-18 20:35:24 -07:00
Nick Cameron
ce0907e46e Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses.

[breaking-change]

Enum variants are now in both the value and type namespaces. This means that
if you have a variant with the same name as a type in scope in a module, you
will get a name clash and thus an error. The solution is to either rename the
type or the variant.
2014-09-19 15:11:00 +12:00
Keegan McAllister
ad9a1daa81 Add -C remark for LLVM optimization remarks
Fixes #17116.
2014-09-12 11:46:38 -07:00
Keegan McAllister
225353d8bb Add a Rust string ostream for LLVM 2014-09-12 11:46:38 -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
bors
c8e86e977f auto merge of #16322 : michaelwoerister/rust/gdb-pretty, r=alexcrichton
Also extends the autotest framework to let a test case choose if pretty printing should be enabled.
2014-08-30 04:01:24 +00:00
P1start
de7abd8824 Unify non-snake-case lints and non-uppercase statics lints
This unifies the `non_snake_case_functions` and `uppercase_variables` lints
into one lint, `non_snake_case`. It also now checks for non-snake-case modules.
This also extends the non-camel-case types lint to check type parameters, and
merges the `non_uppercase_pattern_statics` lint into the
`non_uppercase_statics` lint.

Because the `uppercase_variables` lint is now part of the `non_snake_case`
lint, all non-snake-case variables that start with lowercase characters (such
as `fooBar`) will now trigger the `non_snake_case` lint.

New code should be updated to use the new `non_snake_case` lint instead of the
previous `non_snake_case_functions` and `uppercase_variables` lints. All use of
the `non_uppercase_pattern_statics` should be replaced with the
`non_uppercase_statics` lint. Any code that previously contained non-snake-case
module or variable names should be updated to use snake case names or disable
the `non_snake_case` lint. Any code with non-camel-case type parameters should
be changed to use camel case or disable the `non_camel_case_types` lint.

[breaking-change]
2014-08-30 09:10:05 +12:00
Niko Matsakis
1b487a8906 Implement generalized object and type parameter bounds (Fixes #16462) 2014-08-27 21:46:52 -04:00
Michael Woerister
6974b4f1b5 debuginfo: Add GDB pretty printers for structs and enums. 2014-08-27 15:19:14 +02:00
Luqman Aden
17256197a9 librustc: Use builder for llvm attributes. 2014-07-25 16:06:44 -07:00
Alex Crichton
707cf47ac8 Register new snapshots 2014-07-19 20:38:00 -07:00
Patrick Walton
02adaca4dc librustc: Implement unboxed closures with mutable receivers 2014-07-18 09:01:37 -07:00
Brian Anderson
a008fc84aa Fix rebase fallout. Sorry. 2014-07-14 12:27:56 -07:00
Brian Anderson
3096d9bf94 rustc_llvm: Remove the inner llvm module
This makes it much saner for clients to use the library since
they don't have to worry about shadowing one llvm with another.
2014-07-14 12:27:08 -07:00
Brian Anderson
8e2e15f163 rustc_llvm: Remove an unnecessary workaround
Just some leftover junk from extracting llvm.
2014-07-14 12:27:08 -07:00
Brian Anderson
55393493e1 rustc: Move ArchiveRO to rustc_llvm
It is a wrapper around LLVM.
2014-07-14 12:27:07 -07:00
Brian Anderson
d3096c2348 Move llvm bindings to their own crate 2014-07-14 12:27:07 -07:00