Commit graph

5398 commits

Author SHA1 Message Date
David Carlier 114b0c799d std: enabling new netbsd (10) calls.
Introducing a new config for this purpose as NetBSD 9 or 8 will be still around
for a good while. For now, we re finally enabling sys::unix::rand::getrandom.
2024-02-11 08:48:02 +00:00
bors 0cbef48150 Auto merge of #120232 - c272:json-buildstd, r=Mark-Simulacrum
Add support for custom JSON targets when using build-std.

Currently, when building with `build-std`, some library build scripts check properties of the target by inspecting the target triple at `env::TARGET`, which is simply set to the filename of the JSON file when using JSON target files.

This patch alters these build scripts to use `env::CARGO_CFG_*` to fetch target information instead, allowing JSON target files describing platforms without `restricted_std` to build correctly when using `-Z build-std`. There are some weak assertions here (for example, `nintendo && newlib`), however this seems at least a marginal improvement on the existing solution.

Fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/60.
2024-02-11 02:10:17 +00:00
bors d44e3b95cb Auto merge of #120852 - matthiaskrgr:rollup-01pr8gj, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #120351 (Implement SystemTime for UEFI)
 - #120354 (improve normalization of `Pointee::Metadata`)
 - #120776 (Move path implementations into `sys`)
 - #120790 (better error message on download CI LLVM failure)
 - #120806 (Clippy subtree update)
 - #120815 (Improve `Option::inspect` docs)
 - #120822 (Emit more specific diagnostics when enums fail to cast with `as`)
 - #120827 (Print image input file and checksum in CI only)
 - #120836 (hide impls if trait bound is proven from env)
 - #120844 (Build DebugInfo for async closures)
 - #120851 (Remove duplicate release note)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-09 21:06:12 +00:00
Matthias Krüger 434f080895
Rollup merge of #120776 - joboet:move_pal_path, r=ChrisDenton
Move path implementations into `sys`

Part of #117276.

r? `@ChrisDenton`
2024-02-09 19:21:16 +01:00
Matthias Krüger 1e3d2fb417
Rollup merge of #120351 - Ayush1325:uefi-time, r=m-ou-se
Implement SystemTime for UEFI

- Uses SystemTable->RuntimeServices->GetTime()
- Uses the algorithm described [here](https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html) for conversion to UNIX time
2024-02-09 19:21:15 +01:00
bors f4cfd87202 Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789
Bump bootstrap compiler to just-built 1.77 beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-02-09 18:09:02 +00:00
bors 972452c447 Auto merge of #120238 - joboet:always_confirm_lock_success, r=Mark-Simulacrum
Always check the result of `pthread_mutex_lock`

Fixes #120147.

Instead of manually adding a list of "good" platforms, I've simply made the check unconditional. pthread's mutex is already quite slow on most platforms, so one single well-predictable branch shouldn't hurt performance too much.
2024-02-09 10:27:16 +00:00
Ayush Singh 92d4060176
Implement SystemTime for UEFI
- Uses SystemTable->RuntimeServices->GetTime()

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-02-09 00:21:36 +05:30
Mark Rousskov 9a5034a20e Step all bootstrap cfgs forward
This also takes care of other bootstrap-related changes.
2024-02-08 07:44:34 -05:00
Mark Rousskov 8043821b3a Bump version placeholders 2024-02-08 07:43:38 -05:00
joboet c0d9776562
std: move path into sys 2024-02-08 12:51:35 +01:00
r0cky c7519d42c2 Update tests 2024-02-07 10:42:01 +08:00
bors ea37e8091f Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrum
Update stdarch submodule

Splits up #27731 into multiple tracking issues.

Closes #27731
2024-02-05 15:41:40 +00:00
Lawrence Tang 1ecb08409d Add support for custom JSON targets when using build-std.
Currently, when building with `build-std`, some library build scripts
check properties of the target by inspecting the target triple at
`env::TARGET`, which is simply set to the filename of the JSON file
when using JSON target files.

This patch alters these build scripts to use `env::CARGO_CFG_*` to
fetch target information instead, allowing JSON target files
describing platforms without `restricted_std` to build correctly when
using `-Z build-std`.

Fixes wg-cargo-std-aware/#60.
2024-02-05 10:20:42 +00:00
Matthias Krüger 13ea09b22f
Rollup merge of #120657 - mu001999:clean, r=Nilstrieb
Remove unused struct

Detected by #118257
2024-02-05 11:07:28 +01:00
Matthias Krüger d8e9ddc843
Rollup merge of #120607 - conradludgate:fix-120603, r=dtolnay
fix #120603 by adding a check in default_read_buf

Fixes #120603 by checking the returned read n is in-bounds of the cursor.

Interestingly, I noticed that `BorrowedBuf` side-steps this issue by using checked accesses. Maybe this can be switched to unchecked to mirror what BufReader does bf3c6c5bed/library/core/src/io/borrowed_buf.rs (L95)
2024-02-05 06:37:16 +01:00
Matthias Krüger 16200db7aa
Rollup merge of #120572 - pheki:update-libc, r=Mark-Simulacrum
Update libc to 0.2.153

Bumps libc dependency to 0.2.153, which includes this fix, required for building std for the vita: https://github.com/rust-lang/libc/pull/3552
2024-02-05 06:37:15 +01:00
r0cky 8266657338 Remove unused struct 2024-02-05 10:04:36 +08:00
Matthias Krüger 3e24351677
Rollup merge of #120528 - GnomedDev:atomicu8-backtrace-style, r=cuviper
Store SHOULD_CAPTURE as AtomicU8

`BacktraceStyle` easily fits into a u8, so `SHOULD_CAPTURE`, which is just `Atomic<Option<BacktraceStyle>>`, should be stored as `AtomicU8`
2024-02-03 22:25:16 +01:00
Matthias Krüger a3ea64719b
Rollup merge of #120523 - a1phyr:improve_read_buf_exact, r=the8472
Improve `io::Read::read_buf_exact` error case

- Use `const_io_error` instead of `Error::new`
- Use the same message as `read_exact`
2024-02-03 22:25:15 +01:00
Conrad Ludgate 4c694db252 add another test to make sure it still works with full reads 2024-02-03 11:46:54 +00:00
Conrad Ludgate a27e45a71b fix #120603 by adding a check in default_read_buf 2024-02-03 11:30:26 +00:00
Aphek ee8703315e Update libc to 0.2.153 2024-02-01 23:58:42 -03:00
GnomedDev 7ea4dbbadb
Store SHOULD_CAPTURE as AtomicU8 2024-01-31 13:58:52 +00:00
Nadrieril a7d5382e5c
Rollup merge of #120430 - devnexen:fix_tls_dtor_fbsd, r=cuviper
std: thread_local::register_dtor fix proposal for FreeBSD.

following-up 5d3d347 commit, rust started to spin
__cxa_thread_call_dtors warnings even without any TLS usage. using instead home made TLS destructor handler `register_dtor_fallback`.

close #120413
2024-01-31 12:10:51 +01:00
Benoît du Garreau a158fb33ef Improve io::Read::read_buf_exact error case
- Use `const_io_error` instead of `Error::new`
- Use the same message as `read_exact`
2024-01-31 11:06:19 +01:00
Guillaume Gomez 27bc496564
Rollup merge of #120485 - chenyukang:yukang-add-query-instability-check, r=michaelwoerister
add missing potential_query_instability for keys and values in hashmap

From https://github.com/rust-lang/rust/pull/120435#discussion_r1468883787,

These API are also returning iterator, so we need add `potential_query_instability` for them?
2024-01-30 16:57:51 +01:00
Guillaume Gomez d10f33a8d1
Rollup merge of #120434 - fmease:revert-speeder, r=petrochenkov
Revert outdated version of "Add the wasm32-wasi-preview2 target"

An outdated version of #119616 was merged in rollup #120309.
This reverts those changes to enable #119616 to “retain the intended diff” after a rebase.
```@rylev``` has agreed that this would be the cleanest approach with respect to the history.
Unblocks #119616.

r? ```@petrochenkov``` or compiler or libs
2024-01-30 16:57:49 +01:00
Guillaume Gomez 4f4ceefe16
Rollup merge of #120295 - reitermarkus:remove-ffi-nonzero, r=dtolnay
Remove `raw_os_nonzero` feature.

This feature is superseded by a generic `NonZero` type: https://github.com/rust-lang/rust/issues/120257

Closes https://github.com/rust-lang/rust/issues/82363.
2024-01-30 16:57:48 +01:00
Guillaume Gomez d5e8d85249
Rollup merge of #120452 - alexcrichton:update-windows-seek-write-docs, r=ChrisDenton
std: Update documentation of seek_write on Windows

Currently the documentation of `FileExt::seek_write` on Windows indicates that writes beyond the end of the file leave intermediate bytes uninitialized. This commentary dates back to the original inclusion of these functions in #35704 (wow blast from the past!). At the time the functionality here was implemented using `WriteFile`, but nowadays the `NtWriteFile` method is used instead. The documentation for `NtWriteFile` explicitly states:

> If Length and ByteOffset specify a write operation past the current
> end-of-file mark, NtWriteFile automatically extends the file and updates
> the end-of-file mark; any bytes that are not explicitly written between
> such old and new end-of-file marks are defined to be zero.

This commentary has had a downstream impact in the `system-interface` crate where it tries to handle this by explicitly writing zeros, but I don't believe that's necessary any more. I'm sending a PR upstream here to avoid future confusion and codify that zeros are written in the intermediate bytes matching what Windows currently provides.
2024-01-30 11:19:18 +01:00
Guillaume Gomez 5db58538cf
Rollup merge of #119991 - kornelski:endless-read, r=the8472
Reject infinitely-sized reads from io::Repeat

These calls would always run out of memory.

Related to #117925
2024-01-30 11:19:12 +01:00
bors 5c9c3c7871 Auto merge of #117925 - kornelski:read-to-oom, r=Amanieu
Handle out of memory errors in io:Read::read_to_end()

#116570 got stuck due to a [procedural confusion](https://github.com/rust-lang/rust/pull/116570#issuecomment-1768271068). Retrying so that it can get FCP with the proper team now. cc `@joshtriplett` `@BurntSushi`

----

I'd like to propose handling of out-of-memory errors in the default implementation of `io::Read::read_to_end()` and `fs::read()`. These methods create/grow a `Vec` with a size that is external to the program, and could be arbitrarily large.

Due to being I/O methods, they can already fail in a variety of ways, in theory even including `ENOMEM` from the OS too, so another failure case should not surprise anyone.

While this may not help much Linux with overcommit, it's useful for other platforms like WASM. [Internals thread](https://internals.rust-lang.org/t/io-read-read-to-end-should-handle-oom/19662).

I've added documentation that makes it explicit that the OOM handling is a nice-to-have, and not a guarantee of the trait.

I haven't changed the implementation of `impl Read for &[u8]` and `VecDeque` out of caution, because in these cases users could assume `read` can't fail.

This code uses `try_reserve()` + `extend_from_slice()` which is optimized since #117503.
2024-01-30 05:10:11 +00:00
yukang ad526d831e add missing potential_query_instability for keys and values in hashmap 2024-01-30 12:43:10 +08:00
Amanieu d'Antras 31007f51ed Add stdarch_wasm_atomic_wait feature in std 2024-01-30 03:34:30 +00:00
Amanieu d'Antras 9a39e41637 Update feature names for new stdarch 2024-01-30 03:33:12 +00:00
Amanieu d'Antras f8d4b2a150 Update stdarch submodule 2024-01-30 03:33:12 +00:00
Kornel 60f46289cf Handle out of memory errors in fs::read/read_to_string 2024-01-29 23:53:45 +00:00
Kornel 03545161e6 Handle out of memory errors in io:Read::read_to_end() 2024-01-29 23:53:09 +00:00
Markus Reiter bf4de3a874
Remove raw_os_nonzero feature. 2024-01-29 22:02:11 +01:00
joboet 1df1ebf6ad
std: always check the result of pthread_mutex_lock 2024-01-29 19:24:26 +01:00
Dylan DPC c70c4cc708
Rollup merge of #120462 - mu001999:clean, r=Nilstrieb
Clean dead code

Detected by #118257
2024-01-29 12:56:55 +00:00
Dylan DPC d04bede047
Rollup merge of #120373 - HTGAzureX1212:HTGAzureX1212/issue-120040, r=ChrisDenton
Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists

This pull request changes the `read_dir` function's and the `ReadDir` structure's internal implementations for the Windows operating system to make its behaviour more accurate.

It should be noted that `ERROR_FILE_NOT_FOUND` is returned by the `FindFirstFileW` function when *no matching files can be found*, not necessarily that the path to search in does not exist in the first place. Therefore, directly returning the "The system cannot find the file specified." may not be accurate.

An extra check for whether the path to search in exists is added, returning a constructed `ReadDir` iterator with its handle being an `INVALID_HANDLE_VALUE` returned by the `FindFirstFileW` function if `ERROR_FILE_NOT_FOUND` is indeed the last OS error. The `ReadDir` implementation for the Windows operating system is correspondingly updated to always return `None` if the handle it has is an `INVALID_HANDLE_VALUE` which can only be the case if and only if specifically constructed by the `read_dir` function in the aforementioned conditions.

It should also be noted that `FindFirstFileW` would have returned `ERROR_PATH_NOT_FOUND` if the path to search in does not exist in the first place.

Presumably fixes #120040.
2024-01-29 12:56:52 +00:00
r0cky d3bf8b717b Clean dead code 2024-01-29 14:04:42 +08:00
Alex Crichton b85b2a783b std: Update documentation of seek_write on Windows
Currently the documentation of `FileExt::seek_write` on Windows
indicates that writes beyond the end of the file leave intermediate
bytes uninitialized. This commentary dates back to the original
inclusion of these functions in #35704 (wow blast from the past!). At
the time the functionality here was implemented using `WriteFile`, but
nowadays the `NtWriteFile` method is used instead. The documentation for
`NtWriteFile` explicitly states:

> If Length and ByteOffset specify a write operation past the current
> end-of-file mark, NtWriteFile automatically extends the file and updates
> the end-of-file mark; any bytes that are not explicitly written between
> such old and new end-of-file marks are defined to be zero.

This commentary has had a downstream impact in the `system-interface`
crate where it tries to handle this by explicitly writing zeros, but I
don't believe that's necessary any more. I'm sending a PR upstream here
to avoid future confusion and codify that zeros are written in the
intermediate bytes matching what Windows currently provides.
2024-01-28 11:24:27 -08:00
León Orell Valerian Liehr 9199742339
Revert "Add the wasm32-wasi-preview2 target"
This reverts commit 31ecf34125.

Co-authored-by: Ryan Levick <me@ryanlevick.com>
2024-01-28 02:02:50 +01:00
David Carlier 4c010259ef std: thread_local::register_dtor fix proposal for FreeBSD.
following-up 5d3d347 commit, rust started to spin
__cxa_thread_call_dtors warnings even without any TLS usage.
using instead home made TLS destructor handler `register_dtor_fallback`.

close #120413
2024-01-27 19:14:31 +00:00
Kornel 2251e9abee Reject infinitely-sized reads from io::Repeat
Related to #117925
2024-01-27 18:52:41 +00:00
Markus Reiter 4f0ce6fca2
Switch NonZero alias direction. 2024-01-27 16:38:57 +01:00
HTGAzureX1212. 018bf305cd
add extra check for invalid handle in ReadDir::next 2024-01-27 12:43:38 +08:00
HTGAzureX1212. e26f213050
make modifications as per reviews 2024-01-27 12:28:28 +08:00