about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-05-29Skip timeout upper bound check on windowsSteven Fackler-4/+12
2015-05-28Implement RFC 1047 - socket timeoutsSteven Fackler-7/+324
Closes #25619
2015-05-29Auto merge of #25816 - sfackler:io-error-delegation, r=alexcrichtonbors-5/+87
The first commit simply forwards `io::Error`'s `cause` implementation to the inner error. The second commit adds accessor methods for the inner error. Method names mirror those used elsewhere like `BufReader`. r? @alexcrichton
2015-05-28Mention UFCS sadness in instability messagesSteven Fackler-3/+6
2015-05-28std: Add an option to disable ELF based TLSAlex Crichton-27/+75
This commit adds a ./configure option called `--disable-elf-tls` which disables ELF based TLS (that which is communicated to LLVM) on platforms which already support it. OSX 10.6 does not support this form of TLS, and some users of Rust need to target 10.6 and are unable to do so due to the usage of TLS. The standard library will continue to use ELF based TLS on OSX by default (as the officially supported platform is 10.7+), but this adds an option to compile the standard library in a way that is compatible with 10.6.
2015-05-28remove references to IoResultSteve Klabnik-1/+1
This is now std::io::Result
2015-05-28Auto merge of #25843 - shepmaster:remove-public-int-and-uint, r=huonwbors-8/+0
2015-05-27Add a test for downcastingSteven Fackler-2/+38
Ergonomics are a bit crappy right now because method resolution isn't smart enough to drop bounds, unfortunately.
2015-05-27Add accessors for io::Error's inner error.Steven Fackler-6/+42
error::Error itself has downcasting methods, so there's no need to duplicate those here.
2015-05-27Delegate io::Error::cause to inner errorSteven Fackler-0/+7
2015-05-27Remove mentions of int / uint from the isize / usize docsJake Goulding-8/+0
2015-05-28Rollup merge of #25668 - steveklabnik:doc_const, r=alexcrichtonManish Goregaokar-0/+54
2015-05-28Rollup merge of #25128 - steveklabnik:gh24816, r=alexcrichtonManish Goregaokar-0/+2
Fixes #24816 r? @alexcrichton
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-424/+320
2015-05-26Add note about filesystems to fs::renameSteve Klabnik-0/+2
Fixes #24816
2015-05-26Document std::env::const valuesSteve Klabnik-0/+54
2015-05-25Auto merge of #25767 - mystor:patch-1, r=Gankrobors-6/+4
By the same logic that `mem::forget` is safe, `boxed::into_raw` is actually a safe function. Fixes #25755.
2015-05-25Remove unsafe block around boxed::into_raw() as it is now safeMichael Layzell-6/+4
2015-05-25Auto merge of #25764 - tshepang:typo, r=steveklabnikbors-1/+1
2015-05-25Auto merge of #25736 - tshepang:path-nits, r=steveklabnikbors-3/+3
2015-05-25doc: fix io::Write::write typoTshepang Lekhonkhobe-1/+1
2015-05-23Auto merge of #25666 - tshepang:better-path-docs, r=steveklabnikbors-40/+42
2015-05-23doc: fix Windows test failureTshepang Lekhonkhobe-2/+2
2015-05-23path: make this bit follow idiomTshepang Lekhonkhobe-1/+1
2015-05-23doc: missing wordsTshepang Lekhonkhobe-2/+2
2015-05-23Auto merge of #25735 - oli-obk:rollup, r=steveklabnikbors-1/+1
- Successful merges: #25681, #25687, #25695, #25697, #25702, #25703, #25709, #25710, #25714, #25715, #25716, #25722 - Failed merges:
2015-05-23Rollup merge of #25709 - MatejLach:stdlib_style, r=steveklabnikOliver Schneider-1/+1
Sounds better to me this way. r @steveklabnik ?
2015-05-23Auto merge of #25667 - lambda:rename-soft_link-to-symlink-landed-in-1.1, ↵bors-4/+4
r=aturon The change to split up soft_link to OS-specific symlink, symlink_file, and symlink_dir didn't actually land in 1.0.0. Update the stability and deprecation attributes to correctly indicate that these changes happend in 1.1.0.
2015-05-23Auto merge of #25416 - kballard:ffi-cstr-to-str-convenience, r=alexcrichtonbors-0/+72
This was motivated by http://www.evanmiller.org/a-taste-of-rust.html. A common problem when working with FFI right now is converting from raw C strings into `&str` or `String`. Right now you're required to say something like let cstr = unsafe { CStr::from_ptr(ptr) }; let result = str::from_utf8(cstr.to_bytes()); This is slightly awkward, and is not particularly intuitive for people who haven't used the ffi module before. We can do a bit better by providing some convenience methods on CStr: fn to_str(&self) -> Result<&str, str::Utf8Error> fn to_string_lossy(&self) -> Cow<str> This will make it immediately apparent to new users of CStr how to get a string from a raw C string, so they can say: let s = unsafe { CStr::from_ptr(ptr).to_string_lossy() };
2015-05-23Auto merge of #24847 - sfackler:debug-builders-stability, r=aturonbors-1/+0
The `debug_builders` feature is up for 1.1 stabilization in #24028. This commit stabilizes the API as-is with no changes. Some nits that @alexcrichton mentioned that may be worth discussing now if anyone cares: * Should `debug_tuple_struct` and `DebugTupleStruct` be used instead of `debug_tuple` and `DebugTuple`? It's more typing but is a technically more correct name. * `DebugStruct` and `DebugTuple` have `field` methods while `DebugSet`, `DebugMap` and `DebugList` have `entry` methods. Should we switch those to something else for consistency? cc @alexcrichton @aturon
2015-05-22Add some convenience methods to go from CStr -> strKevin Ballard-0/+72
A common problem when working with FFI right now is converting from raw C strings into `&str` or `String`. Right now you're required to say something like let cstr = unsafe { CStr::from_ptr(ptr) }; let result = str::from_utf8(cstr.to_bytes()); This is slightly awkward, and is not particularly intuitive for people who haven't used the ffi module before. We can do a bit better by providing some convenience methods on CStr: fn to_str(&self) -> Result<&str, str::Utf8Error> fn to_string_lossy(&self) -> Cow<str> This will make it immediately apparent to new users of CStr how to get a string from a raw C string, so they can say: let s = unsafe { CStr::from_ptr(ptr).to_string_lossy() };
2015-05-22better describe the stdlibMatej Ľach-1/+1
2015-05-21doc: miscellaneous improvements to std::path::Path examplesTshepang Lekhonkhobe-38/+40
2015-05-20Fix stability and deprecation markers on soft_link and symlinkBrian Campbell-4/+4
The change to split up soft_link to OS-specific symlink, symlink_file, and symlink_dir didn't actually land in 1.0.0. Update the stability and deprecation attributes to correctly indicate that these changes happend in 1.1.0.
2015-05-20doc: 'reader' and 'writer' are nicer to read than 'r' and 'w'Tshepang Lekhonkhobe-7/+8
2015-05-20Auto merge of #25610 - mbrubeck:bufread-docs, r=alexcrichtonbors-1/+22
r? @steveklabnik
2015-05-19Stabilize debug builders for 1.2.0Steven Fackler-1/+0
2015-05-20Auto merge of #25350 - alexcrichton:msvc, r=brsonbors-628/+715
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-19Auto merge of #25495 - alexcrichton:process-pid, r=aturonbors-0/+17
This commits adds a method to the `std::process` module to get the process identifier of the child as a `u32`. On Windows the underlying identifier is already a `u32`, and on Unix the type is typically defined as `c_int` (`i32` for almost all our supported platforms), but the actually pid is normally a small positive number. Eventually we may add functions to load information about a process based on its identifier or the ability to terminate a process based on its identifier, but for now this function should enable this sort of functionality to exist outside the standard library.
2015-05-19std: Don't require rust_try as an exported symbolAlex Crichton-9/+24
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`
2015-05-19std: Implement aborting stubs for MSVC unwindingAlex Crichton-328/+389
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.
2015-05-19Add example code and cross-link to BufReader docsMatt Brubeck-1/+22
2015-05-19Rollup merge of #25576 - mbrubeck:pathext-doc, r=steveklabnikManish Goregaokar-2/+3
This has been a frequently-asked question on IRC, and it isn't obvious where to look for the fix. r? @steveklabnik
2015-05-18[doc] Add a reference from PathExt to fs::metadataMatt Brubeck-2/+3
2015-05-17Make debug builders take &mut self, add entries methodSteven Fackler-15/+16
[breaking-change]
2015-05-17Rollup merge of #25522 - alexcrichton:reexport-incoming, r=sfacklerManish Goregaokar-1/+1
This iterator was mistakenly not reexported at the top level, preventing actually naming the type! Closes #25519
2015-05-17Rollup merge of #25516 - bstrie:cstrdoc, r=alexcrichtonManish Goregaokar-2/+1
No need for `&b"foo"[..]` to make a CString, `"foo"` will do.
2015-05-17Rollup merge of #25508 - johshoff:visit_dirs_example, r=alexcrichtonManish Goregaokar-6/+5
The current version of the example won't compile due to unstable features. This is an attempt to fix that, at the cost of slightly more verbose code. Using rust 1.0.0 (a59de37e9). It might be obvious, but I'm not well versed with rust, so feedback is very welcome.
2015-05-17Rollup merge of #25469 - ecoal95:patch-1, r=alexcrichtonManish Goregaokar-1/+1
Just detected it while reading.
2015-05-17Rollup merge of #25465 - Ryman:patch-2, r=alexcrichtonManish Goregaokar-2/+2
r? @steveklabnik