-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial MSVC support for the compiler #25350
Commits on May 12, 2015
-
Conflicts: mk/platform.mk src/librustc/session/config.rs src/librustc_back/target/aarch64_apple_ios.rs src/librustc_back/target/aarch64_linux_android.rs src/librustc_back/target/arm_linux_androideabi.rs src/librustc_back/target/arm_unknown_linux_gnueabi.rs src/librustc_back/target/arm_unknown_linux_gnueabihf.rs src/librustc_back/target/armv7_apple_ios.rs src/librustc_back/target/armv7s_apple_ios.rs src/librustc_back/target/i386_apple_ios.rs src/librustc_back/target/i686_apple_darwin.rs src/librustc_back/target/i686_pc_windows_gnu.rs src/librustc_back/target/i686_unknown_dragonfly.rs src/librustc_back/target/i686_unknown_linux_gnu.rs src/librustc_back/target/mips_unknown_linux_gnu.rs src/librustc_back/target/mipsel_unknown_linux_gnu.rs src/librustc_back/target/mod.rs src/librustc_back/target/powerpc_unknown_linux_gnu.rs src/librustc_back/target/x86_64_apple_darwin.rs src/librustc_back/target/x86_64_apple_ios.rs src/librustc_back/target/x86_64_pc_windows_gnu.rs src/librustc_back/target/x86_64_unknown_dragonfly.rs src/librustc_back/target/x86_64_unknown_freebsd.rs src/librustc_back/target/x86_64_unknown_linux_gnu.rs src/librustc_back/target/x86_64_unknown_openbsd.rs src/librustc_llvm/lib.rs src/librustc_trans/back/link.rs src/librustc_trans/trans/base.rs src/libstd/os.rs src/rustllvm/RustWrapper.cpp
Configuration menu - View commit details
-
Copy full SHA for 315750a - Browse repository at this point
Copy the full SHA 315750aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4cc025d - Browse repository at this point
Copy the full SHA 4cc025dView commit details -
rustc_trans: Abstract linker support behind a trait
This trait will be used to correctly build a command line for link.exe with MSVC and may perhaps one day be used to generate a command line for `lld`, but this commit currently just refactors the bindings used to call `ld`.
Configuration menu - View commit details
-
Copy full SHA for 2d5e577 - Browse repository at this point
Copy the full SHA 2d5e577View commit details -
rustc_llvm: Expose setting more DLL storage classes
Currently only `dllexport` is used, but more integration will require using `dllimport` as well.
Configuration menu - View commit details
-
Copy full SHA for 40570eb - Browse repository at this point
Copy the full SHA 40570ebView commit details
Commits on May 19, 2015
-
rt: Clean up to build with cl.exe
* Detect the #define _MSC_VER in addition to __WIN32__ * Don't include valgrind.h for windows * Remove unused `rust_valgrind_stack_{un,}register` functions * Add stub definition for `rust_running_on_valgrind` for windows * Conditionally define `rust_dbg_extern_empty_struct` as empty structures are not allowed by cl.exe apparently.
Configuration menu - View commit details
-
Copy full SHA for cb513c7 - Browse repository at this point
Copy the full SHA cb513c7View commit details -
mk: Remove generation of .d files
Looks like cl.exe doesn't support this and we're also barely using them anyway as we have very few header files and C code in general.
Configuration menu - View commit details
-
Copy full SHA for eb5bf15 - Browse repository at this point
Copy the full SHA eb5bf15View commit details -
mk: Correct names of installed libs on windows
Previously libmorestack.a and libcompiler-rt.a were installed, but link.exe looks for morestack.lib and compiler-rt.lib by default, so we need to install these with the correct name
Configuration menu - View commit details
-
Copy full SHA for 150663c - Browse repository at this point
Copy the full SHA 150663cView commit details -
mk: Fix native LLVM deps for cross-host builds
We use a script called `mklldeps.py` to run `llvm-config` to generate a list of LLVM libraries and native dependencies needed by LLVM, but all cross-compiled LLVM builds were using the *host triple's* `llvm-config` instead of the *target's* `llvm-config`. This commit alters this to require the right `llvmdeps.rs` to be generated which will run the correct `llvm-config`.
Configuration menu - View commit details
-
Copy full SHA for ee258c5 - Browse repository at this point
Copy the full SHA ee258c5View commit details -
configure: Start adding MSVC support
This commit starts to add MSVC support to the ./configure script to enable the build system to detect and build an MSVC target with the cl.exe compiler and toolchain. The primary change here is a large sanity check when an MSVC target is requested (and currently only `x86_64-pc-windows-msvc` is recognized). When building an MSVC target, the configure script either requires the `--msvc-root` argument or for `cl.exe` to be in `PATH`. It also requires that if in the path `cl.exe` is the 64-bit version of the compiler. Once detected the configure script will run the `vcvarsall.bat` script provided by Visual Studio to learn about the `INCLUDE` and `LIB` variables needed by the `cl.exe` compiler to run (the default include/lib paths for the compiler/linker). These variables are then reexported when running `make` to ensure that our own compiles are running the same toolchain. The purpose of this detection and environment variable scraping is to avoid requiring the build itself to be run inside of a `cmd.exe` shell but rather allow it to run in the currently expected MinGW/MSYS shell.
8Configuration menu - View commit details
-
Copy full SHA for 7cf0b17 - Browse repository at this point
Copy the full SHA 7cf0b17View commit details -
mk: Enable building LLVM targeting MSVC
This commit modifies the makefiles to enable building LLVM with cmake and Visual Studio to generate an LLVM that targets MSVC. Rust's configure script requires cmake to be installed when targeting MSVC and will configure LLVM with cmake instead of the normal `./configure` script LLVM provides. The build will then run cmake to execute the build instead of the normal `make`. Currently `make clean-llvm` isn't supported on MSVC as I can't figure out how to run a "clean" target for the Visual Studio files.
Configuration menu - View commit details
-
Copy full SHA for b56d47c - Browse repository at this point
Copy the full SHA b56d47cView commit details -
mk: Add build system support for cl.exe
We have a number of support C/C++ files in Rust that we link into the standard library and other various locations, and these all need to be built with cl.exe instead of gcc.exe when targeting MSVC. This commit adds helper macros for this functionality to use different sets of programs/flags/invocations on MSVC than on GNU-like platforms.
Configuration menu - View commit details
-
Copy full SHA for fcf7ecd - Browse repository at this point
Copy the full SHA fcf7ecdView commit details -
mk: Don't add cross prefixes for MSVC
Currently the MSVC compilers don't have any cross prefixes and we're only able to make an MSVC compiler with a cross compile, so just avoid this logic on msvc for now.
Configuration menu - View commit details
-
Copy full SHA for ee64bab - Browse repository at this point
Copy the full SHA ee64babView commit details -
mk: Fix building compiler-rt on MSVC
It looks like compiler-rt has a cmake build sytem inside its source, but I have been unable to figure out how to use it and actually build the right library. For now this commit hard-wires MSVC-targeting builds of libcompiler-rt to continue using `make` as the primary bulid system, but some frobbing of the flags are necessary to ensure that the right compiler is used.
Configuration menu - View commit details
-
Copy full SHA for 64412a4 - Browse repository at this point
Copy the full SHA 64412a4View commit details -
mk: Fix MSVC build for rustllvm.lib
This commit updates the rustllvm.mk file with the necessary flags and such to build rustllvm.lib with cl.exe instead of gcc. Some comments can be found in the commit itself.
Configuration menu - View commit details
-
Copy full SHA for 6122a5f - Browse repository at this point
Copy the full SHA 6122a5fView commit details -
mk: Add the ability to depend on native LLVM tools
The compiler will require that `llvm-ar.exe` be available for MSVC-targeting builds (more comments on this soon), so this commit adds support for targets to depend on LLVM tools. The `core` library for MSVC depends on `llvm-ar.exe` which will be copied into place for the target before the compiler starts to run. Note that these targets all depend on `llvm-config.exe` to ensure that they're built before they're attempted to be copied.
Configuration menu - View commit details
-
Copy full SHA for a4ef308 - Browse repository at this point
Copy the full SHA a4ef308View commit details -
rustc: Shorten MSVC metadata section name
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`
Configuration menu - View commit details
-
Copy full SHA for f9846e9 - Browse repository at this point
Copy the full SHA f9846e9View commit details -
rustc_back: Refactor Archive to better express intent
This commit was initially written to target either `ar` or `lib.exe` for MSVC, but it ended up not needing `lib.exe` support after all. I would personally like to refactor this to one day not invoke processes at all (but rather use the `llvm-ar.cpp` file in LLVM as alibrary) so I chose to preserve this refactoring to allow it to be easily done in the future.
Configuration menu - View commit details
-
Copy full SHA for 839dcfd - Browse repository at this point
Copy the full SHA 839dcfdView commit details -
rustc_back: Remove unneeded explicit variable
This value is the default anyway
Configuration menu - View commit details
-
Copy full SHA for 37659a1 - Browse repository at this point
Copy the full SHA 37659a1View commit details -
rustc_back: Tweak the MSVC target spec
This change primarily changes the default ar utility used by MSVC-targeting compilers as `llvm-ar`, adding comments along the way as to why.
Configuration menu - View commit details
-
Copy full SHA for af56e2e - Browse repository at this point
Copy the full SHA af56e2eView commit details -
mklldeps: Don't link stdc++/c++ on MSVC
These libraries don't exist! The linker for MSVC is highly likely to not pass `/NODEFAULTLIB` in which case the right standard library will automatically be selected.
Configuration menu - View commit details
-
Copy full SHA for d97b4af - Browse repository at this point
Copy the full SHA d97b4afView commit details -
libc: Add necessary libraries for MSVC
These libs seem to be required by the standard library at least to link successfully!
Configuration menu - View commit details
-
Copy full SHA for e2854b3 - Browse repository at this point
Copy the full SHA e2854b3View commit details -
rustc_trans: Clean up some style in back::link
* Add some logging here and there * Move some `err` + `abort_if_errors` to just using `fatal` * Clean up some line-lengths
Configuration menu - View commit details
-
Copy full SHA for eb50ffd - Browse repository at this point
Copy the full SHA eb50ffdView commit details -
rustc_trans: Add MSVC linker support
This commit adds an implementation of the `Linker` trait which is used to drive MSVC's `link.exe` support. Nothing too surprising here as it's mostly just filling out the necessary tidbits here and there.
Configuration menu - View commit details
-
Copy full SHA for 181dbd7 - Browse repository at this point
Copy the full SHA 181dbd7View commit details -
rustc_trans: Tidy up some style and line lengths
Match the surrounding style in the rest of the `rustc_trans::trans` module.
Configuration menu - View commit details
-
Copy full SHA for ce8b317 - Browse repository at this point
Copy the full SHA ce8b317View commit details -
mk: Generate a .def file for rustc_llvm on MSVC
Windows needs explicit exports of functions from DLLs but LLVM does not mention any of its symbols as being export-able from a DLL. The compiler, however, relies on being able to use LLVM symbols across DLL boundaries so we need to force many of LLVM's symbols to be exported from `rustc_llvm.dll`. This commit adds support for generation of a `rustc_llvm.def` file which is passed along to the linker when generating `rustc_llvm.dll` which should keep all these symbols exportable and usable.
Configuration menu - View commit details
-
Copy full SHA for b538189 - Browse repository at this point
Copy the full SHA b538189View commit details -
rustc_llvm: Don't export constants across dlls
For imports of constants across DLLs to work on Windows it *requires* that the import be marked with `dllimport` (unlike functions where the marker is optional, but strongly recommended). This currently isn't working for importing FFI constants across boundaries, however, so the one constant exported from `rustc_llvm.dll` is now a function to be called instead.
Configuration menu - View commit details
-
Copy full SHA for 847c852 - Browse repository at this point
Copy the full SHA 847c852View commit details -
std: Implement aborting stubs for MSVC unwinding
At this time unwinding support is not implemented for MSVC as `libgcc_s_seh-1.dll` is not available by default (and this is used on MinGW), but this should be investigated soon. For now this change is just aimed at getting the compiler far enough to bootstrap everything instead of successfully running tests. This commit refactors the `std::rt::unwind` module a bit to prepare for SEH support eventually by moving all GCC-specific functionality to its own submodule and defining the interface needed.
Configuration menu - View commit details
-
Copy full SHA for f5222fb - Browse repository at this point
Copy the full SHA f5222fbView commit details -
std: Mark rust_get_num_cpus as dllexport
This function is imported across the DLL boundary by the libtest dynamic library, so it has to be marked as dllexport somehow, and for now this is done with an attribute on the function specifically.
Configuration menu - View commit details
-
Copy full SHA for 9a2415b - Browse repository at this point
Copy the full SHA 9a2415bView commit details -
rustc_trans: Apply dllexport attributes for MSVC
This commit modifies the compiler to emit `dllexport` for all reachable functions and data on MSVC targets, regardless of whether a dynamic library is being created or not. More details can be found in the commit itself.
Configuration menu - View commit details
-
Copy full SHA for 3d32cf5 - Browse repository at this point
Copy the full SHA 3d32cf5View commit details -
std: Don't require rust_try as an exported symbol
This commit adds a small non-generic non-inlineable shim function to `rt::unwind::try` which the compiler can take care of for managing the exported symbol instead of having to edit `src/rt/rust_try.ll`
Configuration menu - View commit details
-
Copy full SHA for 74f4f39 - Browse repository at this point
Copy the full SHA 74f4f39View commit details -
mk: Update
make dist
for MSVC targetsThis commit updates the `dist` target for MSVC to not build the mingw components and to also ensure that the `llvm-ar.exe` binary is ferried along into the right location for installs.
Configuration menu - View commit details
-
Copy full SHA for cb3071b - Browse repository at this point
Copy the full SHA cb3071bView commit details