about summary refs log tree commit diff
path: root/src/librustc_driver
AgeCommit message (Collapse)AuthorLines
2015-07-16Fixup #27046 with pattern bindingsManish Goregaokar-12/+12
2015-07-16Rollup merge of #27046 - nrc:driver-defaults, r=alexcrichtonManish Goregaokar-3/+9
2015-07-15Some more default implementations for the compiler driver callbacks.Nick Cameron-3/+9
2015-07-10Change some instances of .connect() to .join()Wesley Wiser-4/+4
2015-07-08Auto merge of #26869 - alexcrichton:fix-msvc-sepcomp, r=nrcbors-6/+4
This commit alters the implementation of multiple codegen units slightly to be compatible with the MSVC linker. Currently the implementation will take the N object files created by each codegen unit and will run `ld -r` to create a new object file which is then passed along. The MSVC linker, however, is not able to do this operation. The compiler will now no longer attempt to assemble object files together but will instead just pass through all the object files as usual. This implies that rlibs may not contain more than one object file (if the library is compiled with more than one codegen unit) and the output of `-C save-temps` will have changed slightly as object files with the extension `0.o` will not be renamed to `o` unless requested otherwise.
2015-07-08trans: Link rlibs to dylibs with --whole-archiveAlex Crichton-6/+4
This commit starts passing the `--whole-archive` flag (`-force_load` on OSX) to the linker when linking rlibs into dylibs. The primary purpose of this commit is to ensure that the linker doesn't strip out objects from an archive when creating a dynamic library. Information on how this can go wrong can be found in issues #14344 and #25185. The unfortunate part about passing this flag to the linker is that we have to preprocess the rlib to remove the metadata and compressed bytecode found within. This means that creating a dylib will now take longer to link as we've got to copy around the input rlibs to a temporary location, modify them, and then invoke the linker. This isn't done for executables, however, so the "hello world" compile time is not affected. This fix was instigated because of the previous commit where rlibs may not contain multiple object files instead of one due to codegen units being greater than one. That change prevented the main distribution from being compiled with more than one codegen-unit and this commit fixes that. Closes #14344 Closes #25185
2015-07-07Revert "rustc_driver: Print stage info in --version --verbose"Brian Anderson-16/+0
This reverts commit 555b021c6e531fc375c62160a176dcc4fe77b798.
2015-07-07Revert "rustc_driver: Omit stage info for stage2+"Brian Anderson-3/+5
This reverts commit e66ac43ea4ca489486c5c5dc59974577449fad44.
2015-07-07Auto merge of #26699 - eddyb:unstable-prelude_import, r=huonwbors-1/+1
Closes #26690.
2015-07-06rustc_driver: Omit stage info for stage2+Richo Healey-5/+3
2015-07-06rustc_driver: Print stage info in --version --verboseRicho Healey-0/+16
2015-07-05Feature-gate #[prelude_import].Eduard Burtescu-1/+1
2015-07-01Update librustc_driver/test.rsJared Roesch-1/+1
2015-06-29Auto merge of #26582 - jroesch:infer-ctxt-refactor, r=nikomatsakisbors-2/+2
This branch begins the work of unifying our type checking contexts into a single piece of state. The goal is to eventually have a single context that we can pass around instead of the fractured situation we currently have. There are still several things that must be done before beginning to make tables item local: - [ ] move FulfillmentContext into InferCtxt - [ ] modify SelectionContext to only take a single context argument - [ ] remove remaining typer impls - [ ] remove the ClosureTyper + Typer trait - [ ] do some renaming to make these things more applicable to their new roles r? @nikomatsakis As a side note there are a couple oddities that are temporary refactors that will be quickly cleaned up in a follow-up PR. cc @eddyb @Aatch @arielb1 @nrc
2015-06-28Fix librustc_driver/test.rsJared Roesch-1/+1
2015-06-27Address nitsJared Roesch-1/+1
2015-06-27rustc_driver: Fix incorrect commentRicho Healey-2/+1
2015-06-26rustc: switch most remaining middle::ty functions to methods.Eduard Burtescu-21/+21
2015-06-26rustc: make ty::mk_* constructors into methods on ty::ctxt.Eduard Burtescu-37/+31
2015-06-26rustc: combine type-flag-checking traits and fns and into one trait.Eduard Burtescu-7/+7
2015-06-20Auto merge of #26417 - brson:feature-err, r=steveklabnikbors-2/+6
It now says '#[feature] may not be used on the stable release channel'. I had to convert this error from a lint to a normal compiler error. I left the lint previously-used for this in place since removing it is a breaking change. It will just go unused until the end of time. Fixes #24125
2015-06-20Auto merge of #26382 - alexcrichton:less-racy-path, r=brsonbors-7/+0
Environment variables are global state so this can lead to surprising results if the driver is called in a multithreaded environment (e.g. doctests). There shouldn't be any memory corruption that's possible, but a lot of the bots have been failing because they can't find `cc` or `gcc` in the path during doctests, and I highly suspect that it is due to the compiler modifying `PATH` in a multithreaded fashion. This commit moves the logic for appending to `PATH` to only affect the child process instead of also affecting the parent, at least for the linking stage. When loading dynamic libraries the compiler still modifies `PATH` on Windows, but this may be more difficult to fix than spawning off a new process.
2015-06-18Make a better error message for using #[feature] on stable rustBrian Anderson-2/+6
It now says '#[feature] may not be used on the stable release channel'. I had to convert this error from a lint to a normal compiler error. I left the lint previously-used for this in place since removing it is a breaking change. It will just go unused until the end of time. Fixes #24125
2015-06-19rustc: remove Repr and UserString.Eduard Burtescu-37/+26
2015-06-19rustc: replace Repr/UserString impls with Debug/Display ones.Eduard Burtescu-7/+4
2015-06-19rustc: use the TLS type context in Repr and UserString.Eduard Burtescu-20/+20
2015-06-19rustc: use Repr and UserString instead of ppaux::ty_to_string.Eduard Burtescu-6/+4
2015-06-19rustc: enforce stack discipline on ty::ctxt.Eduard Burtescu-145/+172
2015-06-19rustc_resolve: don't require redundant arguments to resolve_crate.Eduard Burtescu-6/+2
2015-06-19rustc: remove ownership of tcx from trans' context.Eduard Burtescu-46/+41
2015-06-17rustc_driver: Frob the global PATH lessAlex Crichton-7/+0
Environment variables are global state so this can lead to surprising results if the driver is called in a multithreaded environment (e.g. doctests). There shouldn't be any memory corruption that's possible, but a lot of the bots have been failing because they can't find `cc` or `gcc` in the path during doctests, and I highly suspect that it is due to the compiler modifying `PATH` in a multithreaded fashion. This commit moves the logic for appending to `PATH` to only affect the child process instead of also affecting the parent, at least for the linking stage. When loading dynamic libraries the compiler still modifies `PATH` on Windows, but this may be more difficult to fix than spawning off a new process.
2015-06-17More test fixes and fallout of stability changesAlex Crichton-2/+2
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-1/+0
2015-06-17collections: Split the `collections` featureAlex Crichton-3/+4
This commit also deprecates the `as_string` and `as_slice` free functions in the `string` and `vec` modules.
2015-06-12Cleanup: rename middle::ty::sty and its variants.Eli Friedman-1/+1
Use camel-case naming, and use names which actually make sense in modern Rust.
2015-06-11Auto merge of #26199 - swgillespie:issue-26092, r=alexcrichtonbors-2/+2
`driver::build_output_filenames` calls `file_stem` on a PathBuf obtained from the output file compiler flag. It's possible to pass the empty string to this compiler flag. When file_stem is called on an empty Path, it returns None, which is unwrapped and the compiler panics. This change modifies the `unwrap` to an `unwrap_or` so that the empty string is passed through the compilation pipeline until it reaches `trans::back::write_output_file`, which will emit an appropriate error. Instead of panicking, the error that is emitted now is: ``` $ rustc -o "" thing.rs error: could not write output to : No such file or directory ``` The `:` is a little strange, but it /is/ reporting the filename (the empty string) correctly, I suppose. Both gcc and clang hand the output file to ld, which emits a similar error message when faced with the empty string as an output file: ``` $ clang -o "" thing.c ld: can't open output file for writing: , errno=2 for architecture x86_64 ``` This PR also adds a test for this, in `run-make`. This fixes issue #26092.
2015-06-11Conver reborrows to .iter() calls where appropriateJoshua Landau-1/+1
2015-06-10fix #26092 by returning an empty OS string when the output file path has no ↵swgillespie-2/+2
file_stem
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-5/+5
2015-06-10syntax: move ast_map to librustc.Eduard Burtescu-3/+4
2015-05-27Remove build date from the output of --versionJohannes Oertel-5/+0
Closes #25812.
2015-05-27Auto merge of #25741 - richo:backtrace-message, r=alexcrichtonbors-1/+4
The second commit seems reasonable to me but I can remove if it's contentious. The first is purely cosmetic but has been irking me for ages.
2015-05-26Make caching in stability work. This improves stability check performanceAriel Ben-Yehuda-1/+1
by 90%.
2015-05-24Auto merge of #25168 - Manishearth:register_attr, r=eddybbors-3/+5
This lets plugin authors opt attributes out of the `custom_attribute` and `unused_attribute` checks. cc @thepowersgang
2015-05-23driver: Only emit the RUST_BACKTRACE message if not presentRicho Healey-1/+4
2015-05-20Auto merge of #25350 - alexcrichton:msvc, r=brsonbors-1/+1
Special thanks to @retep998 for the [excellent writeup](https://github.com/rust-lang/rfcs/issues/1061) of tasks to be done and @ricky26 for initially blazing the trail here! # MSVC Support This goal of this series of commits is to add MSVC support to the Rust compiler and build system, allowing it more easily interoperate with Visual Studio installations and native libraries compiled outside of MinGW. The tl;dr; of this change is that there is a new target of the compiler, `x86_64-pc-windows-msvc`, which will not interact with the MinGW toolchain at all and will instead use `link.exe` to assemble output artifacts. ## Why try to use MSVC? With today's Rust distribution, when you install a compiler on Windows you also install `gcc.exe` and a number of supporting libraries by default (this can be opted out of). This allows installations to remain independent of MinGW installations, but it still generally requires native code to be linked with MinGW instead of MSVC. Some more background can also be found in #1768 about the incompatibilities between MinGW and MSVC. Overall the current installation strategy is quite nice so long as you don't interact with native code, but once you do the usage of a MinGW-based `gcc.exe` starts to get quite painful. Relying on a nonstandard Windows toolchain has also been a long-standing "code smell" of Rust and has been slated for remedy for quite some time now. Using a standard toolchain is a great motivational factor for improving the interoperability of Rust code with the native system. ## What does it mean to use MSVC? "Using MSVC" can be a bit of a nebulous concept, but this PR defines it as: * The build system for Rust will build as much code as possible with the MSVC compiler, `cl.exe`. * The build system will use native MSVC tools for managing archives. * The compiler will link all output with `link.exe` instead of `gcc.exe`. None of these are currently implemented today, but all are required for the compiler to fluently interoperate with MSVC. ## How does this all work? At the highest level, this PR adds a new target triple to the Rust compiler: x86_64-pc-windows-msvc All logic for using MSVC or not is scoped within this triple and code can conditionally build for MSVC or MinGW via: #[cfg(target_env = "msvc")] It is expected that auto builders will be set up for MSVC-based compiles in addition to the existing MinGW-based compiles, and we will likely soon start shipping MSVC nightlies where `x86_64-pc-windows-msvc` is the host target triple of the compiler. # Summary of changes Here I'll explain at a high level what many of the changes made were targeted at, but many more details can be found in the commits themselves. Many thanks to @retep998 for the excellent writeup in rust-lang/rfcs#1061 and @rick26 for a lot of the initial proof-of-concept work! ## Build system changes As is probably expected, a large chunk of this PR is changes to Rust's build system to build with MSVC. At a high level **it is an explicit non goal** to enable building outside of a MinGW shell, instead all Makefile infrastructure we have today is retrofitted with support to use MSVC instead of the standard MSVC toolchain. Some of the high-level changes are: * The configure script now detects when MSVC is being targeted and adds a number of additional requirements about the build environment: * The `--msvc-root` option must be specified or `cl.exe` must be in PATH to discover where MSVC is installed. The compiler in use is also required to target x86_64. * Once the MSVC root is known, the INCLUDE/LIB environment variables are scraped so they can be reexported by the build system. * CMake is required to build LLVM with MSVC (and LLVM is also configured with CMake instead of the normal configure script). * jemalloc is currently unconditionally disabled for MSVC targets as jemalloc isn't a hard requirement and I don't know how to build it with MSVC. * Invocations of a C and/or C++ compiler are now abstracted behind macros to appropriately call the underlying compiler with the correct format of arguments, for example there is now a macro for "assemble an archive from objects" instead of hard-coded invocations of `$(AR) crus liboutput.a ...` * The output filenames for standard libraries such as morestack/compiler-rt are now "more correct" on windows as they are shipped as `foo.lib` instead of `libfoo.a`. * Rust targets can now depend on native tools provided by LLVM, and as you'll see in the commits the entire MSVC target depends on `llvm-ar.exe`. * Support for custom arbitrary makefile dependencies of Rust targets has been added. The MSVC target for `rustc_llvm` currently requires a custom `.DEF` file to be passed to the linker to get further linkages to complete. ## Compiler changes The modifications made to the compiler have so far largely been minor tweaks here and there, mostly just adding a layer of abstraction over whether MSVC or a GNU-like linker is being used. At a high-level these changes are: * The section name for metadata storage in dynamic libraries is called `.rustc` for MSVC-based platorms as section names cannot contain more than 8 characters. * The implementation of `rustc_back::Archive` was refactored, but the functionality has remained the same. * Targets can now specify the default `ar` utility to use, and for MSVC this defaults to `llvm-ar.exe` * The building of the linker command in `rustc_trans::back::link` has been abstracted behind a trait for the same code path to be used between GNU and MSVC linkers. ## Standard library changes Only a few small changes were required to the stadnard library itself, and only for minor differences between the C runtime of msvcrt.dll and MinGW's libc.a * Some function names for floating point functions have leading underscores, and some are not present at all. * Linkage to the `advapi32` library for crypto-related functions is now explicit. * Some small bits of C code here and there were fixed for compatibility with MSVC's cl.exe compiler. # Future Work This commit is not yet a 100% complete port to using MSVC as there are still some key components missing as well as some unimplemented optimizations. This PR is already getting large enough that I wanted to draw the line here, but here's a list of what is not implemented in this PR, on purpose: ## Unwinding The revision of our LLVM submodule [does not seem to implement][llvm] does not support lowering SEH exception handling on the Windows MSVC targets, so unwinding support is not currently implemented for the standard library (it's lowered to an abort). [llvm]: https://github.com/rust-lang/llvm/blob/rust-llvm-2015-02-19/lib/CodeGen/Passes.cpp#L454-L461 It looks like, however, that upstream LLVM has quite a bit more support for SEH unwinding and landing pads than the current revision we have, so adding support will likely just involve updating LLVM and then adding some shims of our own here and there. ## dllimport and dllexport An interesting part of Windows which MSVC forces our hand on (and apparently MinGW didn't) is the usage of `dllimport` and `dllexport` attributes in LLVM IR as well as native dependencies (in C these correspond to `__declspec(dllimport)`). Whenever a dynamic library is built by MSVC it must have its public interface specified by functions tagged with `dllexport` or otherwise they're not available to be linked against. This poses a few problems for the compiler, some of which are somewhat fundamental, but this commit alters the compiler to attach the `dllexport` attribute to all LLVM functions that are reachable (e.g. they're already tagged with external linkage). This is suboptimal for a few reasons: * If an object file will never be included in a dynamic library, there's no need to attach the dllexport attribute. Most object files in Rust are not destined to become part of a dll as binaries are statically linked by default. * If the compiler is emitting both an rlib and a dylib, the same source object file is currently used but with MSVC this may be less feasible. The compiler may be able to get around this, but it may involve some invasive changes to deal with this. The flipside of this situation is that whenever you link to a dll and you import a function from it, the import should be tagged with `dllimport`. At this time, however, the compiler does not emit `dllimport` for any declarations other than constants (where it is required), which is again suboptimal for even more reasons! * Calling a function imported from another dll without using `dllimport` causes the linker/compiler to have extra overhead (one `jmp` instruction on x86) when calling the function. * The same object file may be used in different circumstances, so a function may be imported from a dll if the object is linked into a dll, but it may be just linked against if linked into an rlib. * The compiler has no knowledge about whether native functions should be tagged dllimport or not. For now the compiler takes the perf hit (I do not have any numbers to this effect) by marking very little as `dllimport` and praying the linker will take care of everything. Fixing this problem will likely require adding a few attributes to Rust itself (feature gated at the start) and then strongly recommending static linkage on Windows! This may also involve shipping a statically linked compiler on Windows instead of a dynamically linked compiler, but these sorts of changes are pretty invasive and aren't part of this PR. ## CI integration Thankfully we don't need to set up a new snapshot bot for the changes made here as our snapshots are freestanding already, we should be able to use the same snapshot to bootstrap both MinGW and MSVC compilers (once a new snapshot is made from these changes). I plan on setting up a new suite of auto bots which are testing MSVC configurations for now as well, for now they'll just be bootstrapping and not running tests, but once unwinding is implemented they'll start running all tests as well and we'll eventually start gating on them as well. --- I'd love as many eyes on this as we've got as this was one of my first interactions with MSVC and Visual Studio, so there may be glaring holes that I'm missing here and there! cc @retep998, @ricky26, @vadimcn, @klutzy r? @brson
2015-05-19rustc: Shorten MSVC metadata section nameAlex Crichton-1/+1
It looks like section names in objects generated by `link.exe` are limited to at most 8 characters in length, so shorten `.note.rustc` to just `.rustc`
2015-05-17Auto merge of #25387 - eddyb:syn-file-loader, r=nikomatsakisbors-2/+2
This allows compiling entire crates from memory or preprocessing source files before they are tokenized. Minor API refactoring included, which is a [breaking-change] for libsyntax users: * `ParseSess::{next_node_id, reserve_node_ids}` moved to rustc's `Session` * `new_parse_sess` -> `ParseSess::new` * `new_parse_sess_special_handler` -> `ParseSess::with_span_handler` * `mk_span_handler` -> `SpanHandler::new` * `default_handler` -> `Handler::new` * `mk_handler` -> `Handler::with_emitter` * `string_to_filemap(sess source, path)` -> `sess.codemap().new_filemap(path, source)`
2015-05-15libs: Move favicon URLs to HTTPSAlex Crichton-1/+1
Helps prevent mixed content warnings if accessing docs over HTTPS. Closes #25459
2015-05-14Move configuration 1 phase before crate metadata collectionKevin Ballard-11/+11
Stripping unconfigured items prior to collecting crate metadata means we can say things like `#![cfg_attr(foo, crate_type="lib")]`. Fixes #25347.