summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2017-11-19std: Add a new wasm32-unknown-unknown targetAlex Crichton-9/+2067
This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". --- Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is still getting LLVM bugs fixed to get that working and will take some time. Relatively simple programs all seem to work though! --- It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-14Auto merge of #45981 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-2/+2
Rollup of 7 pull requests - Successful merges: #45815, #45941, #45950, #45961, #45967, #45970, #45977 - Failed merges:
2017-11-14Auto merge of #45896 - malbarbo:use-libc-const, r=alexcrichtonbors-50/+5
Use getrandom syscall for all Linux and Android targets. I suppose we can use it in all Linux and Android targets. In function `is_getrandom_available` is checked if the syscall is available (getrandom syscall was add in version 3.17 of Linux kernel), if the syscall is not available `fill_bytes` fallback to reading from `/dev/urandom`. Update libc to include getrandom related constants.
2017-11-14Fixed several pulldown warnings when documenting libstd.kennytm-2/+2
2017-11-13Rollup merge of #45893 - redox-os:futex_timeout, r=alexcrichtonkennytm-22/+38
Redox: Use futex timeout to implement CondVar::wait_timeout `CondVar::wait_timeout` is implemented by supplying a `TimeSpec` pointer to `futex`. In addition, all calls to `unimplemented!()` have been removed from the Redox `sys` module. Related to https://github.com/rust-lang/rust/pull/45892
2017-11-13Rollup merge of #45892 - redox-os:is_absolute_fix, r=alexcrichtonkennytm-4/+4
Redox: Return true from Path::is_absolute if a Path contains root or a scheme In Redox, different subsystems have different filesystem paths. However, the majority of applications using the `Path::is_absolute` function really only want to know if a path is absolute from the perspective of the scheme it is currently running in, usually `file:`. This makes both `file:/` and `/` return `true` from `Path::is_absolute`, meaning that most code does not have to check if it is running on Redox. Code that wants to know if a path contains a scheme can implement such a check on its own. Related to https://github.com/rust-lang/rust/pull/45893
2017-11-11Auto merge of #45152 - Binero:master, r=dtolnaybors-11/+43
Addressed issues raised in #44286. (`OccupiedEntry::replace_entry`) This commit renames the `replace` function to `replace_entry`, and creates a seperate `replace_key` function for `OccupiedEntry`. The original `replace` function did not solve the use-case where the key needed to be replaced, but not the value. Documentation and naming has also been updated to better reflect what the original replace function does.
2017-11-11Improvided map_entry_replace examplesJeroen Bollen-12/+22
The current examples should be more realistic.
2017-11-11Changed tabs back into spaces to fix formatting.Jeroen Bollen-2/+2
2017-11-11Addressed issues raised in #44286.Jeroen Bollen-5/+27
This commit renames the `replace` function to `replace_entry`, and creates a seperate `replace_key` function for `OccupiedEntry`. The original `replace` function did not solve the use-case where the key needed to be replaced, but not the value. Documentation and naming has also been updated to better reflect what the original replace function does.
2017-11-11Add missing links and examples for FileExtGuillaume Gomez-2/+40
2017-11-09Use getrandom syscall for all Linux and Android targets.Marco A L Barbosa-50/+5
2017-11-09Add futex timeoutJeremy Soller-22/+38
2017-11-09std: Avoid use of `libc` in portable modulesAlex Crichton-31/+33
This commit removes usage of the `libc` crate in "portable" modules like those at the top level and `sys_common`. Instead common types like `*mut u8` or `u32` are used instead of `*mut c_void` or `c_int` as well as switching to platform-specific functions like `sys::strlen` instead of `libc::strlen`.
2017-11-08std: Move the `cmath` module into the `sys` moduleAlex Crichton-133/+196
This commit moves the `f32::cmath` and `f64::cmath` modules into the `sys` module. Note that these are not publicly exported modules, simply implementation details. These modules are already platform-specific with shims on MSVC and this is mostly just a reflection of that reality. This should also help cut down on `#[cfg]` traffic if platforms are brought on which don't directly support these functions.
2017-11-08std: Change how EBADF is handled in `sys`Alex Crichton-6/+13
This commit removes the reexport of `EBADF_ERR` as a constant from libstd's portability facade, instead opting for a platform-specific function that specifically queries an `io::Error`. Not all platforms may have a constant for this, so it makes the intent a little more clear that a code need not be supplied, just an answer to a query.
2017-11-08std: Remove `rand` crate and moduleAlex Crichton-610/+114
This commit removes the `rand` crate from the standard library facade as well as the `__rand` module in the standard library. Neither of these were used in any meaningful way in the standard library itself. The only need for randomness in libstd is to initialize the thread-local keys of a `HashMap`, and that unconditionally used `OsRng` defined in the standard library anyway. The cruft of the `rand` crate and the extra `rand` support in the standard library makes libstd slightly more difficult to port to new platforms, namely WebAssembly which doesn't have any randomness at all (without interfacing with JS). The purpose of this commit is to clarify and streamline randomness in libstd, focusing on how it's only required in one location, hashmap seeds. Note that the `rand` crate out of tree has almost always been a drop-in replacement for the `rand` crate in-tree, so any usage (accidental or purposeful) of the crate in-tree should switch to the `rand` crate on crates.io. This then also has the further benefit of avoiding duplication (mostly) between the two crates!
2017-11-08Rollup merge of #45830 - pornel:dosglobs, r=dtolnayGuillaume Gomez-0/+4
Warn about lack of args glob expansion in Windows shell Because all shells on Linux/macOS expand globs, and even MinGW on Windows emulates this behavior, it's easy to forget that Windows by itself doesn't support glob expansion. This PR documents this cross-platform difference.
2017-11-08Rollup merge of #45582 - GuillaumeGomez:doc-unix-missing-links, r=frewsxcvGuillaume Gomez-4/+70
Add missing links and examples r? @rust-lang/docs
2017-11-07Add missing links and examplesGuillaume Gomez-4/+70
2017-11-07Warn about non-portability of glob patternsKornel-0/+4
2017-11-07Rollup merge of #45714 - sdroege:thread-panic-docs, r=dtolnaykennytm-5/+9
Update the std::thread docs and clarify that panics can nowadays be caught
2017-11-07Rollup merge of #45682 - RalfJung:rwlock-guards, r=alexcrichtonkennytm-3/+8
RwLock guards are Sync if T is Currently, the compiler requires `T` to also be `Send`. There is no reason for that. `&Rw{Read,Write}LockGuard` only provides a shared referenced to `T`, sending that across threads is safe if `T` is `Sync`. Cc @oconnor663
2017-11-07Rollup merge of #45470 - GuillaumeGomez:unix-metadata-ext, r=QuietMisdreavuskennytm-0/+246
add missing docs for MetadataExt r? @rust-lang/docs
2017-11-06Auto merge of #45369 - fintelia:patch-1, r=BurntSushibors-0/+25
Implement is_empty() for BufReader Simple implementation of `is_empty` method for BufReader so it is possible to tell whether there is any data in its buffer. I didn't know correct stability annotation to place on the function. Presumably there is no reason to place this feature behind a feature flag, but I wasn't sure how to tag it as an unstable feature without that. CC: #45323
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-604/+114
r=alexcrichton Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later **EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled. --- This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹. ~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~ 1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes 2. ~~Are my changes OK so far? Did I do something wrong?~~ 3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~ 4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly. ¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible. /cc @SimonSapin @zackw
2017-11-04rustc: Handle some libstd symbole exports betterAlex Crichton-0/+11
Right now symbol exports, particularly in a cdylib, are handled by assuming that `pub extern` combined with `#[no_mangle]` means "export this". This isn't actually what we want for some symbols that the standard library uses to implement itself, for example symbols related to allocation. Additionally other special symbols like `rust_eh_personallity` have no need to be exported from cdylib crate types (only needed in dylib crate types). This commit updates how rustc handles these special symbols by adding to the hardcoded logic of symbols like `rust_eh_personallity` but also adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the export level to be considered the same as all other Rust functions instead of looking like a C function. The eventual goal here is to prevent functions like `__rdl_alloc` from showing up as part of a Rust cdylib as it's just an internal implementation detail. This then further allows such symbols to get gc'd by the linker when creating a cdylib.
2017-11-04Allow absolute if either contains root or a schemeJeremy Soller-4/+4
2017-11-04Remove import of now unused AsciiExtLukas Kalbertodt-3/+1
I also replaced a wildcard import with a specific one, while I was at it.
2017-11-04Rollup merge of #45739 - rkarp:master, r=petrochenkovkennytm-2/+2
Fix libstd compile error for windows-gnu targets without `backtrace` This is basically an addition to #44979. Compiling `libstd` still fails when targeting `windows-gnu` with `panic = "abort"` because the items in the `...c::gnu` module are not used. They are only referenced from `backtrace_gnu.rs`, which is indirectly feature gated behind `backtrace` [here](https://github.com/rust-lang/rust/blob/9f3b09116b742b2606dc5f36f9145e0c89e4010b/src/libstd/sys/windows/mod.rs#L23).
2017-11-04Rollup merge of #45669 - cardoe:metadata, r=kennytmkennytm-0/+3
add Cargo metadata to libstd Add license and repository metadata to libstd
2017-11-03Mark several ascii methods as unstable againLukas Kalbertodt-0/+1
We don't want to stabilize them now already. The goal of this set of commits is just to add inherent methods to the four types. Stabilizing all of those methods can be done later.
2017-11-03Remove unused AsciiExt imports and fix tests related to ascii methodsLukas Kalbertodt-3/+5
Many AsciiExt imports have become useless thanks to the inherent ascii methods added in the last commits. These were removed. In some places, I fully specified the ascii method being called to enforce usage of the AsciiExt trait. Note that some imports are not removed but tagged with a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii methods are not yet available in stage0. All those imports will be removed later. Additionally, failing tests were fixed. The test suite should exit successfully now.
2017-11-03Copy `AsciiExt` methods to `str` directlyLukas Kalbertodt-3/+13
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature this commit depends on: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-03Copy `AsciiExt` methods to `[u8]` directlyLukas Kalbertodt-0/+10
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature I am using: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-03Remove examples in doc-comments of `AsciiExt` methodsLukas Kalbertodt-319/+48
The doc comments were incorrect before: since the inherent ascii methods shadow the `AsciiExt` methods, the examples didn't use the `AsciiExt` at all. Since the trait will be deprecated soon anyway, the easiest solution was to remove the examples and already mention that the methods will be deprecated in the near future.
2017-11-03Use direct implementation on u8/char to implement AsciiExtLukas Kalbertodt-280/+41
The methods were copied to u8/char, so we can just use it in AsciiExt impls to avoid duplicate code.
2017-11-03Copy `AsciiExt` methods to `char` directlyLukas Kalbertodt-1/+0
This is done in order to deprecate AsciiExt eventually.
2017-11-03Revert signature of eq_ignore_ascii_case() to originalLukas Kalbertodt-1/+1
Since the methods on u8 directly will shadow the AsciiExt methods, we cannot change the signature without breaking everything. It would have been nice to take `u8` as argument instead of `&u8`, but we cannot break stuff! So this commit reverts it to the original `&u8` version.
2017-11-03Add all methods of AsciiExt to u8 directlyLukas Kalbertodt-1/+1
This is the first step in order to deprecate AsciiExt. Since this is a WIP commit, there is still some code duplication (notably the static arrays) that will be removed later.
2017-11-03auto trait future compatibility lintleonardo.yvens-0/+4
2017-11-03Fix std compile error for windows-gnu targets without `backtrace` featureRolf Karp-2/+2
2017-11-02Make join a link to the function's documentationSebastian Dröge-1/+1
2017-11-02Mention that panics can't possibly be caught when compiling with panic=abortSebastian Dröge-1/+1
2017-11-02Use ` instead of ' for function namesSebastian Dröge-2/+2
2017-11-02Update the std::thread docs and clarify that panics can nowadays be caughtSebastian Dröge-5/+9
2017-11-01RwLock guards are Sync if T isRalf Jung-3/+8
Currently, the compiler requires `T` to also be `Send`. There is no reason for that. `&Rw{Read,Write}LockGuard` only provides a shared referenced to `T`, sending that across threads is safe if `T` is `Sync`.
2017-11-01Auto merge of #45674 - kennytm:rollup, r=kennytmbors-7/+20
Rollup of 14 pull requests - Successful merges: #45450, #45579, #45602, #45619, #45624, #45644, #45646, #45648, #45649, #45650, #45652, #45660, #45664, #45671 - Failed merges:
2017-11-01Rollup merge of #45664 - mbrubeck:docs, r=estebankkennytm-4/+5
Fix incorrect error type in Read::byte docs None
2017-11-01Rollup merge of #45652 - malbarbo:x32-2, r=alexcrichtonkennytm-1/+3
More fixes for x86_64-unknown-linux-gnux32 This update libc (all libc testing are passing) and fixes NR_GETRANDOM. Fix all but one run-pass test (lto-unwind.rs, see https://github.com/rust-lang/rust/issues/45416)