Skip to content
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

Rollup of 10 pull requests #120303

Closed
wants to merge 24 commits into from
Closed

Conversation

fmease
Copy link
Member

@fmease fmease commented Jan 24, 2024

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

pitaj and others added 24 commits November 29, 2023 19:43
…ed -Z unstable-options` to shorten symbol names by replacing them with a digest.

Enrich test cases
It looks like none of these are actually needed.
Also add tests for min-system-llvm-version.
Signed-off-by: Ryan Levick <me@ryanlevick.com>
Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
… r=joshtriplett

[style edition 2024] Combine all delimited exprs as last argument

Closes rust-lang/style-team#149

If this is merged, the rustfmt option `overflow_delimited_expr` should be enabled by default in style edition 2024.

[Rendered](https://github.com/pitaj/rust/blob/style-delimited-expressions/src/doc/style-guide/src/expressions.md#combinable-expressions)

r? joshtriplett
…tmcm

Add `NonZero*::count_ones`

This PR adds the following APIs to the standard library:

```rust
impl NonZero* {
    pub const fn count_ones(self) -> NonZeroU32;
}
```

This is potentially interesting, given that `count_ones` can't ever return 0.

r? libs-api
Add the unstable option  to reduce the binary size of dynamic library…

# Motivation

The average length of symbol names in the rust standard library is about 100 bytes, while the average length of symbol names in the C++ standard library is about 65 bytes. In some embedded environments where dynamic library are widely used, rust dynamic library symbol name space hash become one of the key bottlenecks of application, Especially when the existing C/C++ module is reconstructed into the rust module.

The unstable option `-Z symbol_mangling_version=hashed` is added to solve the bottleneck caused by too long dynamic library symbol names.

## Test data

The following is a set of test data on the ubuntu 18.04 LTS environment. With this plug-in, the space saving rate of dynamic libraries can reach about 20%.

The test object is the standard library of rust (built based on Xargo), tokio crate, and hyper crate.

The contents of the Cargo.toml file in the construction project of the three dynamic libraries are as follows:

```txt
# Cargo.toml
[profile.release]
panic = "abort"
opt-leve="z"
codegen-units=1
strip=true
debug=true
```
The built dynamic library also removes the `.rustc` segments that are not needed at run time and then compares the size. The detailed data is as follows:

1. libstd.so
> | symbol_mangling_version | size | saving rate |
> | --- | --- | --- |
> | legacy | 804896 ||
> | hashed | 608288 | 0.244 |
> | v0 | 858144 ||
> | hashed | 608288 | 0.291 |

2. libhyper.so
> | symbol_mangling_version(libhyper.so) | symbol_mangling_version(libstd.so) | size | saving rate |
> | --- | --- | --- | --- |
> | legacy | legacy | 866312 ||
> | hashed | legacy | 645128 |0.255|
> | legacy | hashed | 854024 ||
> | hashed | hashed | 632840 |0.259|
…wiser

coverage: Never emit improperly-ordered coverage regions

If we emit a coverage region that is improperly ordered (end < start), `llvm-cov` will fail with `coveragemap_error::malformed`, which is inconvenient for users and also very hard to debug.

Ideally we would fix the root causes of these situations, but they tend to occur in very obscure edge-case scenarios (often involving nested macros), and we don't always have a good MCVE to work from. So it makes sense to also have a catch-all check that will prevent improperly-ordered regions from ever being emitted.

---

This is mainly aimed at resolving rust-lang#119453. We don't have a specific way to reproduce it, which is why I haven't been able to add a test case in this PR. But based on the information provided in that issue, this change seems likely to avoid the error in `llvm-cov`.

````@rustbot```` label +A-code-coverage
…ochenkov,m-ou-se

Add a new `wasm32-wasi-preview2` target

This is the initial implementation of the MCP rust-lang/compiler-team#694 creating a new tier 3 target `wasm32-wasi-preview2`. That MCP has been seconded and will most likely be approved in a little over a week from now. For more information on the need for this target, please read the [MCP](rust-lang/compiler-team#694).

There is one aspect of this PR that will become insta-stable once these changes reach a stable compiler:
* A new `target_family` named `wasi` is introduced. This target family incorporates all wasi targets including `wasm32-wasi` and its derivative `wasm32-wasi-preview1-threads`. The difference between `target_family = wasi` and `target_os = wasi` will become much clearer when `wasm32-wasi` is renamed to `wasm32-wasi-preview1` and the `target_os` becomes `wasm32-wasi-preview1`. You can read about this target rename in [this MCP](rust-lang/compiler-team#695) which has also been seconded and will hopefully be officially approved soon.

Additional technical details include:
* Both `std::sys::wasi_preview2` and `std::os::wasi_preview2` have been created and mostly use `#[path]` annotations on their submodules to reach into the existing `wasi` (soon to be `wasi_preview1`) modules. Over time the differences between `wasi_preview1` and `wasi_preview2` will grow and most like all `#[path]` based module aliases will fall away.
* Building `wasi-preview2` relies on a [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) in the same way that `wasi-preview1` does (one must include a `wasi-root` path in the `Config.toml` pointing to sysroot included in the wasi-sdk). The target should build against [wasi-sdk v21](https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-21) without modifications. However, the wasi-sdk itself is growing [preview2 support](WebAssembly/wasi-sdk#370) so this might shift rapidly. We will be following along quickly to make sure that building the target remains possible as the wasi-sdk changes.
* This requires a [patch to libc](https://github.com/rylev/rust-libc/tree/wasm32-wasi-preview2) that we'll need to land in conjunction with this change. Until that patch lands the target won't actually build.
coverage: Don't instrument `#[automatically_derived]` functions

This PR makes the coverage instrumentor detect and skip functions that have [`#[automatically_derived]`](https://doc.rust-lang.org/reference/attributes/derive.html#the-automatically_derived-attribute) on their enclosing impl block.

Most notably, this means that methods generated by built-in derives (e.g. `Clone`, `Debug`, `PartialEq`) are now ignored by coverage instrumentation, and won't appear as executed or not-executed in coverage reports.

This is a noticeable change in user-visible behaviour, but overall I think it's a net improvement. For example, we've had a few user requests for this sort of change (e.g. rust-lang#105055, rust-lang#84605 (comment)), and I believe it's the behaviour that most users will expect/prefer by default.

It's possible to imagine situations where users would want to instrument these derived implementations, but I think it's OK to treat that as an opportunity to consider adding more fine-grained option flags to control the details of coverage instrumentation, while leaving this new behaviour as the default.

(Also note that while `-Cinstrument-coverage` is a stable feature, the exact details of coverage instrumentation are allowed to change. So we *can* make this change; the main question is whether we *should*.)

Fixes rust-lang#105055.
Remove no-system-llvm

We currently have a bunch of codegen tests that use no-system-llvm -- however, all of those tests also pass with system LLVM 16.

I've opted to remove `no-system-llvm` entirely, as there's basically no valid use case for it anymore:

 * The only thing this option could have legitimately been used for (testing the target feature support that requires an LLVM patch) doesn't use it, and the need for this will go away with LLVM 18 anyway.
 * In cases where the test depends on optimizations/fixes from newer LLVM versions, `min-llvm-version` should be used instead.
 * In case it depends on optimization/fixes from newer LLVM versions that have been backported into our fork, `min-system-llvm-version` (with the major version larger than the one in our fork) should be used instead.

r? ````@cuviper````
privacy: Refactor top-level visiting in `TypePrivacyVisitor`

Full hierarchical visiting (`nested_filter::All`) is not necessary, visiting all item-likes in isolation is enough.
Tracking current item is not necessary, just keeping the current `mod` item is enough.
`visit_generic_arg` should behave like its default version, including checking types of const arguments.
Some comments, including FIXMEs, are also added.

Noticed while reading code to review rust-lang#113671.
r? `@oli-obk`
Remove extra # from url in suggestion

The suggestion added in rust-lang#119805 contains an unnecessary # hash sign.
…pdate, r=davidtwco

Add mw to review rotation and add some owner assignments

I've also added a `debuginfo` group and fixed the ownership assignment for the `incremental` group. I hope I got the syntax right.

r? `@davidtwco`
@rustbot rustbot added A-meta Area: Issues about the rust-lang/rust repository. A-testsuite Area: The testsuite used to check the correctness of rustc O-wasi Operating system: Wasi, Webassembly System Interface S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 24, 2024
@rustbot rustbot added T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-style Relevant to the style team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Jan 24, 2024
@fmease
Copy link
Member Author

fmease commented Jan 24, 2024

@bors r+ rollup=never p=10

@bors
Copy link
Contributor

bors commented Jan 24, 2024

📌 Commit f79440e has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 24, 2024
@bors
Copy link
Contributor

bors commented Jan 24, 2024

⌛ Testing commit f79440e with merge fe158e6...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 24, 2024
Rollup of 10 pull requests

Successful merges:

 - rust-lang#114764 ([style edition 2024] Combine all delimited exprs as last argument)
 - rust-lang#118326 (Add `NonZero*::count_ones`)
 - rust-lang#118636 (Add the unstable option  to reduce the binary size of dynamic library…)
 - rust-lang#119460 (coverage: Never emit improperly-ordered coverage regions)
 - rust-lang#119616 (Add a new `wasm32-wasi-preview2` target)
 - rust-lang#120185 (coverage: Don't instrument `#[automatically_derived]` functions)
 - rust-lang#120265 (Remove no-system-llvm)
 - rust-lang#120284 (privacy: Refactor top-level visiting in `TypePrivacyVisitor`)
 - rust-lang#120285 (Remove extra # from url in suggestion)
 - rust-lang#120299 (Add mw to review rotation and add some owner assignments)

Failed merges:

 - rust-lang#120124 (Split assembly tests for ELF and MachO)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-apple-1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [run-make] tests/run-make/symbol-mangling-hashed stdout ----

error: make failed
status: exit status: 2
command: cd "/Users/runner/work/rust/rust/tests/run-make/symbol-mangling-hashed" && env -u CARGO_MAKEFLAGS -u MAKEFLAGS -u MFLAGS -u RUSTFLAGS AR="ar" CC="/Users/runner/work/rust/rust/clang+llvm-14.0.5-x86_64-apple-darwin/bin/clang -ffunction-sections -fdata-sections -fPIC --target=x86_64-apple-darwin" CXX="/Users/runner/work/rust/rust/clang+llvm-14.0.5-x86_64-apple-darwin/bin/clang++ -ffunction-sections -fdata-sections -fPIC --target=x86_64-apple-darwin -stdlib=libc++" HOST_RPATH_DIR="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib" LD_LIB_PATH_ENVVAR="DYLD_LIBRARY_PATH" LLVM_BIN_DIR="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/ci-llvm/bin" LLVM_COMPONENTS="aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen codegentypes core coroutines coverage csky cskyasmparser cskycodegen cskydesc cskydisassembler cskyinfo debuginfobtf debuginfocodeview debuginfodwarf debuginfogsym debuginfologicalview debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker dwarflinkerparallel dwp engine executionengine extensions filecheck frontendhlsl frontendopenacc frontendopenmp fuzzercli fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interfacestub interpreter ipo irprinter irreader jitlink libdriver lineeditor linker loongarch loongarchasmparser loongarchcodegen loongarchdesc loongarchdisassembler loongarchinfo lto m68k m68kasmparser m68kcodegen m68kdesc m68kdisassembler m68kinfo mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts objcopy object objectyaml option orcjit orcshared orctargetprocess passes powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvtargetmca runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target targetparser textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsdriver windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86targetmca xray" LLVM_FILECHECK="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/ci-llvm/bin/FileCheck" NODE="/usr/local/bin/node" PYTHON="/usr/bin/python3" RUSTC="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc" RUSTDOC="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustdoc" RUST_BUILD_STAGE="stage2-x86_64-apple-darwin" S="/Users/runner/work/rust/rust" TARGET="x86_64-apple-darwin" TARGET_RPATH_DIR="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib" TMPDIR="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed" "make"
--- stdout -------------------------------
DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-bootstrap-tools/x86_64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0/lib" '/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc' --out-dir /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed -L /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed  -Ainternal_features -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=hashed -C metadata=foo a_dylib.rs
DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-bootstrap-tools/x86_64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0/lib" '/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc' --out-dir /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed -L /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed  -Ainternal_features -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=hashed -C metadata=bar a_rlib.rs
DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-bootstrap-tools/x86_64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0/lib" '/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc' --out-dir /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed -L /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed  -Ainternal_features -C prefer-dynamic -L /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed b_dylib.rs
DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-bootstrap-tools/x86_64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0/lib" '/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc' --out-dir /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed -L /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed  -Ainternal_features -C prefer-dynamic -L /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed b_bin.rs
[ "$(nm -gU /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed/liba_dylib.dylib | grep -c hello)" -eq "0" ]
[ "$(nm -gU /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed/liba_dylib.dylib | grep _RNxC7a_dylib | grep -c ' T ')" -eq "1" ]
[ "$(nm -gU /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed/libb_dylib.dylib | grep b_dylib | grep -c hello)" -eq "1" ]
[ "$(nm -gU /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed/libb_dylib.dylib | grep _RNxC6a_rlib | grep -c ' T ')" -eq "1" ]
[ "$(nm -gU /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/run-make/symbol-mangling-hashed/symbol-mangling-hashed/libb_dylib.dylib | grep _RNxC7a_dylib | grep -c ' U ')" -eq "1" ]
--- stderr -------------------------------
make: *** [all] Error 1
------------------------------------------

@bors
Copy link
Contributor

bors commented Jan 24, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 24, 2024
@fmease fmease closed this Jan 24, 2024
@fmease fmease deleted the rollup-to11ql5 branch January 24, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues about the rust-lang/rust repository. A-testsuite Area: The testsuite used to check the correctness of rustc O-wasi Operating system: Wasi, Webassembly System Interface rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-style Relevant to the style team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.