about summary refs log tree commit diff
path: root/src/librustc/back
AgeCommit message (Collapse)AuthorLines
2013-12-26auto merge of #10965 : alexcrichton/rust/libgreen, r=brsonbors-1/+11
This pull request extracts all scheduling functionality from libstd, moving it into its own separate crates. The new libnative and libgreen will be the new way in which 1:1 and M:N scheduling is implemented. The standard library still requires an interface to the runtime, however, (think of things like `std::comm` and `io::println`). The interface is now defined by the `Runtime` trait inside of `std::rt`. The booting process is now that libgreen defines the start lang-item and that's it. I want to extend this soon to have libnative also have a "start lang item" but also allow libgreen and libnative to be linked together in the same process. For now though, only libgreen can be used to start a program (unless you define the start lang item yourself). Again though, I want to change this soon, I just figured that this pull request is large enough as-is. This certainly wasn't a smooth transition, certain functionality has no equivalent in this new separation, and some functionality is now better enabled through this new system. I did my best to separate all of the commits by topic and keep things fairly bite-sized, although are indeed larger than others. As a note, this is currently rebased on top of my `std::comm` rewrite (or at least an old copy of it), but none of those commits need reviewing (that will all happen in another pull request).
2013-12-25Test fixes and rebase conflictsAlex Crichton-1/+11
* vec::raw::to_ptr is gone * Pausible => Pausable * Removing @ * Calling the main task "<main>" * Removing unused imports * Removing unused mut * Bringing some libextra tests up to date * Allowing compiletest to work at stage0 * Fixing the bootstrap-from-c rmake tests * assert => rtassert in a few cases * printing to stderr instead of stdout in fail!()
2013-12-25Method-ify CStoreSteven Fackler-13/+13
2013-12-24Stop using C++ exceptions for stack unwinding.Vadim Chugunov-40/+9
2013-12-21auto merge of #10997 : ↵bors-5/+14
cadencemarseille/rust/issue-10755-ICE-for-missing-linker, r=alexcrichton Trap the io_error condition so that a more informative error message is displayed when the linker program cannot be started, such as when the name of the linker binary is accidentally mistyped. closes #10755
2013-12-20auto merge of #11077 : alexcrichton/rust/crate-id, r=cmrbors-2/+2
Right now the --crate-id and related flags are all process *after* the entire crate is parsed. This is less than desirable when used with makefiles because it means that just to learn the output name of the crate you have to parse the entire crate (unnecessary). This commit changes the behavior to lift the handling of these flags much sooner in the compilation process. This allows us to not have to parse the entire crate and only have to worry about parsing the crate attributes themselves. The related methods have all been updated to take an array of attributes rather than a crate. Additionally, this ceases duplication of the "what output are we producing" logic in order to correctly handle things in the case of --test. Finally, this adds tests for all of this functionality to ensure that it does not regress.
2013-12-20rustc: Improve crate id extractionAlex Crichton-2/+2
Right now the --crate-id and related flags are all process *after* the entire crate is parsed. This is less than desirable when used with makefiles because it means that just to learn the output name of the crate you have to parse the entire crate (unnecessary). This commit changes the behavior to lift the handling of these flags much sooner in the compilation process. This allows us to not have to parse the entire crate and only have to worry about parsing the crate attributes themselves. The related methods have all been updated to take an array of attributes rather than a crate. Additionally, this ceases duplication of the "what output are we producing" logic in order to correctly handle things in the case of --test. Finally, this adds tests for all of this functionality to ensure that it does not regress.
2013-12-19rustc: Optimize reading metadata by 4xAlex Crichton-3/+59
We were previously reading metadata via `ar p`, but as learned from rustdoc awhile back, spawning a process to do something is pretty slow. Turns out LLVM has an Archive class to read archives, but it cannot write archives. This commits adds bindings to the read-only version of the LLVM archive class (with a new type that only has a read() method), and then it uses this class when reading the metadata out of rlibs. When you put this in tandem of not compressing the metadata, reading the metadata is 4x faster than it used to be The timings I got for reading metadata from the respective libraries was: libstd-04ff901e-0.9-pre.dylib => 100ms libstd-04ff901e-0.9-pre.rlib => 23ms librustuv-7945354c-0.9-pre.dylib => 4ms librustuv-7945354c-0.9-pre.rlib => 1ms librustc-5b94a16f-0.9-pre.dylib => 87ms librustc-5b94a16f-0.9-pre.rlib => 35ms libextra-a6ebb16f-0.9-pre.dylib => 63ms libextra-a6ebb16f-0.9-pre.rlib => 15ms libsyntax-2e4c0458-0.9-pre.dylib => 86ms libsyntax-2e4c0458-0.9-pre.rlib => 22ms In order to always take advantage of these faster metadata read-times, I sort the files in filesearch based on whether they have an rlib extension or not (prefer all rlib files first). Overall, this halved the compile time for a `fn main() {}` crate from 0.185s to 0.095s on my system (when preferring dynamic linking). Reading metadata is still the slowest pass of the compiler at 0.035s, but it's getting pretty close to linking at 0.021s! The next best optimization is to just not copy the metadata from LLVM because that's the most expensive part of reading metadata right now.
2013-12-19auto merge of #11041 : cmr/rust/pkgid_changes, r=cmr,metajackbors-8/+14
2013-12-19Add some things to inspect crate-id'sCorey Richardson-8/+14
2013-12-18Fix #10755 - ICE: `--linker=`Cadence Marseille-5/+14
Trap the io_error condition so that a more informative error message is displayed when the linker program cannot be started, such as when the name of the linker binary is accidentally mistyped. closes #10755
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-12/+8
There's no need for the restrictions of a closure with the above methods.
2013-12-17auto merge of #10979 : alexcrichton/rust/less-bc, r=cmrbors-10/+3
By performing this logic very late in the build process, it ended up leading to bugs like those found in #10973 where certain stages of the build process expected a particular output format which didn't end up being the case. In order to fix this, the build output generation is moved very early in the build process to the absolute first thing in phase 2. Closes #10973
2013-12-15Move logic for test output generation forwardAlex Crichton-10/+3
By performing this logic very late in the build process, it ended up leading to bugs like those found in #10973 where certain stages of the build process expected a particular output format which didn't end up being the case. In order to fix this, the build output generation is moved very early in the build process to the absolute first thing in phase 2. Closes #10973
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-3/+2
2013-12-14Fix #10754 - `std::run` functions fail after io_errorCadence Marseille-23/+47
The problem was that std::run::Process::new() was unwrap()ing the result of std::io::process::Process::new(), which returns None in the case where the io_error condition is raised to signal failure to start the process. Have std::run::Process::new() similarly return an Option<run::Process> to reflect the fact that a subprocess might have failed to start. Update utility functions run::process_status() and run::process_output() to return Option<ProcessExit> and Option<ProcessOutput>, respectively. Various parts of librustc and librustpkg needed to be updated to reflect these API changes. closes #10754
2013-12-13auto merge of #10916 : alexcrichton/rust/nounwind, r=pcwaltonbors-0/+6
When performing LTO, the rust compiler has an opportunity to completely strip all landing pads in all dependent libraries. I've modified the LTO pass to recognize the -Z no-landing-pads option when also running an LTO pass to flag everything in LLVM as nothrow. I've verified that this prevents any and all invoke instructions from being emitted. I believe that this is one of our best options for moving forward with accomodating use-cases where unwinding doesn't really make sense. This will allow libraries to be built with landing pads by default but allow usage of them in contexts where landing pads aren't necessary.
2013-12-13auto merge of #10908 : alexcrichton/rust/issue-10907, r=cmrbors-4/+16
Turns out that one some platforms the ar/ranlib tool will die with an assertion if the file being added doesn't actually have any symbols (or if it's just not an object file presumably). This functionality is already all exercised on the bots, it just turns out that the bots don't have an ar tool which dies in this situation, so it's difficult for me to add a test. Closes #10907
2013-12-13auto merge of #10698 : metajack/rust/dep-info, r=alexcrichtonbors-3/+9
This isn't super useful for libraries yet without #10593. Fixes #7633.
2013-12-12Add --dep-info to write Makefile-compatible dependency info.Jack Moffitt-3/+9
When --dep-info is given, rustc will write out a `$input_base.d` file in the output directory that contains Makefile compatible dependency information for use with tools like make and ninja.
2013-12-11Fixed "unused variable" errors and trailing whitespace.Vadim Chugunov-2/+2
2013-12-11Don't always modify the symbol table in rlibsAlex Crichton-4/+16
Turns out that one some platforms the ar/ranlib tool will die with an assertion if the file being added doesn't actually have any symbols (or if it's just not an object file presumably). This functionality is already all exercised on the bots, it just turns out that the bots don't have an ar tool which dies in this situation, so it's difficult for me to add a test. Closes #10907
2013-12-11Embed Windows application manifest.Vadim Chugunov-0/+115
2013-12-11Disable all unwinding on -Z no-landing-pads LTOAlex Crichton-0/+6
When performing LTO, the rust compiler has an opportunity to completely strip all landing pads in all dependent libraries. I've modified the LTO pass to recognize the -Z no-landing-pads option when also running an LTO pass to flag everything in LLVM as nothrow. I've verified that this prevents any and all invoke instructions from being emitted. I believe that this is one of our best options for moving forward with accomodating use-cases where unwinding doesn't really make sense. This will allow libraries to be built with landing pads by default but allow usage of them in contexts where landing pads aren't necessary. cc #10780
2013-12-10Make crate hash stable and externally computable.Jack Moffitt-182/+55
This replaces the link meta attributes with a pkgid attribute and uses a hash of this as the crate hash. This makes the crate hash computable by things other than the Rust compiler. It also switches the hash function ot SHA1 since that is much more likely to be available in shell, Python, etc than SipHash. Fixes #10188, #8523.
2013-12-09auto merge of #10812 : alexcrichton/rust/lto, r=pcwaltonbors-77/+348
The first commit was approved from another pull request, but I wanted to rebase LTO on top of it. LTO is not turned on by default at all, and it's hidden behind a `-Z` flag. I have added a few small tests for it, however.
2013-12-09Implement LTOAlex Crichton-95/+289
This commit implements LTO for rust leveraging LLVM's passes. What this means is: * When compiling an rlib, in addition to insdering foo.o into the archive, also insert foo.bc (the LLVM bytecode) of the optimized module. * When the compiler detects the -Z lto option, it will attempt to perform LTO on a staticlib or binary output. The compiler will emit an error if a dylib or rlib output is being generated. * The actual act of performing LTO is as follows: 1. Force all upstream libraries to have an rlib version available. 2. Load the bytecode of each upstream library from the rlib. 3. Link all this bytecode into the current LLVM module (just using llvm apis) 4. Run an internalization pass which internalizes all symbols except those found reachable for the local crate of compilation. 5. Run the LLVM LTO pass manager over this entire module 6a. If assembling an archive, then add all upstream rlibs into the output archive. This ignores all of the object/bitcode/metadata files rust generated and placed inside the rlibs. 6b. If linking a binary, create copies of all upstream rlibs, remove the rust-generated object-file, and then link everything as usual. As I have explained in #10741, this process is excruciatingly slow, so this is *not* turned on by default, and it is also why I have decided to hide it behind a -Z flag for now. The good news is that the binary sizes are about as small as they can be as a result of LTO, so it's definitely working. Closes #10741 Closes #10740
2013-12-09Store metadata separately in rlib filesAlex Crichton-30/+107
Right now whenever an rlib file is linked against, all of the metadata from the rlib is pulled in to the final staticlib or binary. The reason for this is that the metadata is currently stored in a section of the object file. Note that this is intentional for dynamic libraries in order to distribute metadata bundled with static libraries. This commit alters the situation for rlib libraries to instead store the metadata in a separate file in the archive. In doing so, when the archive is passed to the linker, none of the metadata will get pulled into the result executable. Furthermore, the metadata file is skipped when assembling rlibs into an archive. The snag in this implementation comes with multiple output formats. When generating a dylib, the metadata needs to be in the object file, but when generating an rlib this needs to be separate. In order to accomplish this, the metadata variable is inserted into an entirely separate LLVM Module which is then codegen'd into a different location (foo.metadata.o). This is then linked into dynamic libraries and silently ignored for rlib files. While changing how metadata is inserted into archives, I have also stopped compressing metadata when inserted into rlib files. We have wanted to stop compressing metadata, but the sections it creates in object file sections are apparently too large. Thankfully if it's just an arbitrary file it doesn't matter how large it is. I have seen massive reductions in executable sizes, as well as staticlib output sizes (to confirm that this is all working).
2013-12-10Extend allocation lint for boxing expressionsSeo Sanghyeon-1/+1
2013-12-05Remove unused upcallsAlex Crichton-20/+4
The main one removed is rust_upcall_reset_stack_limit (continuation of #10156), and this also removes the upcall_trace function. The was hidden behind a `-Z trace` flag, but if you attempt to use this now you'll get a linker error because there is no implementation of the 'upcall_trace' function. Due to this no longer working, I decided to remove it entirely from the compiler (I'm also a little unsure on what it did in the first place).
2013-12-05Update LLVM and jettison jit supportAlex Crichton-141/+28
LLVM's JIT has been updated numerous times, and we haven't been tracking it at all. The existing LLVM glue code no longer compiles, and the JIT isn't used for anything currently. This also rebases out the FixedStackSegment support which we have added to LLVM. None of this is still in use by the compiler, and there's no need to keep this functionality around inside of LLVM. This is needed to unblock #10708 (where we're tripping an LLVM assertion).
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-11/+11
This reverts commit c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b. Leave the #[ignores] in that were added to rustpkg tests. Conflicts: src/librustc/driver/driver.rs src/librustc/metadata/creader.rs
2013-12-04std::str: s/from_utf8_slice/from_utf8/, to make the basic case shorter.Huon Wilson-2/+2
2013-12-04std::str: remove from_utf8.Huon Wilson-4/+4
This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances.
2013-12-03auto merge of #10785 : alexcrichton/rust/omg-i-hate-windows, r=pcwaltonbors-3/+10
Turns out LLVM only builds libfoo.a libraries, so we're going to need this logic to statically link librustc
2013-12-03Search for libfoo.a on windows as well as foo.libAlex Crichton-3/+10
Turns out LLVM only builds libfoo.a libraries, so we're going to need this logic to statically link librustc
2013-12-03Resume propagation of linking to native dylibsAlex Crichton-54/+73
The reasons for this are outlined in issue #10743 as well as the comment I have now placed in the code. Closes #10743
2013-12-02auto merge of #10742 : alexcrichton/rust/frameworks, r=cmrbors-7/+29
Commits have the fun details, and scrutiny on the new documentation would be appreciated!
2013-12-01rustc: filter out empty linker argsPhilipp Brüschweiler-4/+4
This is inspired by a mystifying linker failure when using `pkg-config` to generate the linker args: `pkg-config` produces output that ends in a space, thus resulting in an empty linker argument. Also added some updates to the concerning error messages that helped spotting this bug.
2013-11-30Support OSX frameworksAlex Crichton-7/+29
This adds support to link to OSX frameworks via the new link attribute when using `kind = "framework"`. It is a compiler error to request linkage to a framework when the target is not macos because other platforms don't support frameworks. Closes #2023
2013-11-30Test fixes and merge conflictsAlex Crichton-6/+17
2013-11-29Add generation of static libraries to rustcAlex Crichton-219/+482
This commit implements the support necessary for generating both intermediate and result static rust libraries. This is an implementation of my thoughts in https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html. When compiling a library, we still retain the "lib" option, although now there are "rlib", "staticlib", and "dylib" as options for crate_type (and these are stackable). The idea of "lib" is to generate the "compiler default" instead of having too choose (although all are interchangeable). For now I have left the "complier default" to be a dynamic library for size reasons. Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a dynamic object. I chose this for size reasons, but also because you're probably not going to be embedding the rustc compiler anywhere any time soon. Other than the options outlined above, there are a few defaults/preferences that are now opinionated in the compiler: * If both a .dylib and .rlib are found for a rust library, the compiler will prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option * If generating a "lib", the compiler will generate a dynamic library. This is overridable by explicitly saying what flavor you'd like (rlib, staticlib, dylib). * If no options are passed to the command line, and no crate_type is found in the destination crate, then an executable is generated With this change, you can successfully build a rust program with 0 dynamic dependencies on rust libraries. There is still a dynamic dependency on librustrt, but I plan on removing that in a subsequent commit. This change includes no tests just yet. Our current testing infrastructure/harnesses aren't very amenable to doing flavorful things with linking, so I'm planning on adding a new mode of testing which I believe belongs as a separate commit. Closes #552
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-9/+9
2013-11-28Register new snapshotsAlex Crichton-1/+1
2013-11-26librustc: Remove non-procedure uses of `do` from librustc, librustdoc,Patrick Walton-26/+26
and librustpkg.
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-2/+1
2013-11-24Use -O1 for non-GNU linkersCorey Richardson-2/+3
2013-11-23Use linker optimizations on LinuxCorey Richardson-0/+13
2013-11-12auto merge of #10423 : alexcrichton/rust/move-io, r=pcwaltonbors-2/+2
I still plan on reorganizing the internals of the IO module a bit, but this is the major move which has been on the horizon for awhile.
2013-11-11auto merge of #10198 : alexcrichton/rust/darwin-quiet, r=jdmbors-2/+3
Instead of running dsymutil for all builds, this changes it to only run the program for debug builds. Closes #3495