about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2022-09-02Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplettbors-1/+33
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE` When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program ```rust fn main() { loop { println!("hello world"); } } ``` will print an error if used with a short-lived pipe, e.g. % ./main | head -n 1 hello world thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace by enabling `#[unix_sigpipe = "sig_dfl"]` like this ```rust #![feature(unix_sigpipe)] #[unix_sigpipe = "sig_dfl"] fn main() { loop { println!("hello world"); } } ``` there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately: % ./main | head -n 1 hello world The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`. With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`. See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-09-02Rollup merge of #100814 - gabrielBusta:port_trait_selection_diagnostics, ↵Matthias Krüger-0/+6
r=davidtwco Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1 ``@rustbot`` label +A-translation r? rust-lang/diagnostics cc #100717
2022-09-02Make CrateConfig make order depended for linting purposeUrgau-4/+4
2022-09-02Rollup merge of #100552 - petrochenkov:flavorcompat, r=lqdGuillaume Gomez-17/+7
rustc_target: Add a compatibility layer to separate internal and user-facing linker flavors I want to do some refactorings in `rustc_target` - merge `lld_flavor` and `linker_is_gnu` into `linker_flavor`, support combination gcc+lld (https://github.com/rust-lang/rust/pull/96827). This PR adds some compatibility infra that makes that possible without making any changes to user-facing interfaces - `-Clinker-flavor` values and json target specs. (For json target specs this infra may eventually go away since they are not very stable.) The second commit does some light refactoring of internal linker flavors (applies changes from https://github.com/petrochenkov/rust/commit/53eca42973b7e379b9fa0469c33f08680b57c35f that don't require mass-editing target specs).
2022-09-01Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1Gabriel Bustamante-0/+6
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-3/+4
by module
2022-09-01rustc_target: Refactor internal linker flavors slightlyVadim Petrochenkov-12/+2
Remove one unstable user-facing linker flavor (l4-bender)
2022-09-01rustc_target: Add a compatibility layer to separate internal and user-facing ↵Vadim Petrochenkov-7/+7
linker flavors
2022-08-31unix_sigpipe: Inline compiler sigpipe constants in stdMartin Nordholts-0/+2
2022-08-31Rollup merge of #100753 - LuisCardosoOliveira:translation-migrate-session, ↵Ralf Jung-18/+92
r=davidtwco translations(rustc_session): migrates `rustc_session` to use `SessionDiagnostic` - Pt. 1 ## Description This is the first PR for the migration of the module `rustc_session`. You can follow my progress [here](https://github.com/rust-lang/rust/issues/100717#issuecomment-1220279883). The PR migrates the files `cgu_reuse_tracker` and `parse.rs` to use `SessionDiagnostic `.
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-28Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`Martin Nordholts-1/+31
This makes it possible to instruct libstd to never touch the signal handler for `SIGPIPE`, which makes programs pipeable by default (e.g. with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe` errors.
2022-08-27Auto merge of #100732 - dpaoliello:import_name_type, r=wesleywiserbors-1/+32
Implementation of import_name_type Fixes #96534 by implementing https://github.com/rust-lang/compiler-team/issues/525 Symbols that are exported or imported from a binary on 32bit x86 Windows can be named in four separate ways, corresponding to the [import name types](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type) from the PE-COFF spec. The exporting and importing binaries must use the same name encoding, otherwise mismatches can lead to link failures due to "missing symbols" or to 0xc0000139 (`STATUS_ENTRYPOINT_NOT_FOUND`) errors when the executable/library is loaded. For details, see the comments on the raw-dylib feature's https://github.com/rust-lang/rust/issues/58713. To generate the correct import libraries for these DLLs, therefore, rustc must know the import name type for each `extern` function, and there is currently no way for users to provide this information. This change adds a new `MetaNameValueStr` key to the `#[link]` attribute called `import_name_type`, and which accepts one of three values: `decorated`, `noprefix`, and `undecorated`. A single DLL is likely to export all its functions using the same import type name, hence `import_name_type` is a parameter of `#[link]` rather than being its own attribute that is applied per-function. It is possible to have a single DLL that exports different functions using different import name types, but users could express such cases by providing multiple export blocks for the same DLL, each with a different import name type. Note: there is a fourth import name type defined in the PE-COFF spec, `IMPORT_ORDINAL`. This case is already handled by the `#[link_ordinal]` attribute. While it could be merged into `import_type_name`, that would not make sense as `#[link_ordinal]` provides per-function information (namely the ordinal itself). Design decisions (these match the MCP linked above): * For GNU, `decorated` matches the PE Spec and MSVC rather than the default behavior of `dlltool` (i.e., there will be a leading `_` for `stdcall`). * If `import_name_type` is not present, we will keep our current behavior of matching the environment (MSVC vs GNU) default for decorating. * Using `import_name_type` on architectures other than 32bit x86 will result in an error. * Using `import_name_type` with link kinds other than `"raw-dylib"` will result in an error.
2022-08-26Rollup merge of #100738 - nidnogg:diagnostics_migr_const_eval, r=davidtwcoMichael Goulet-2/+5
Diagnostics migr const eval This PR should eventually contain all diagnostic migrations for the `rustc_const_eval` crate. r? `@davidtwco` `@rustbot` label +A-translation
2022-08-26Implementation of import_name_typeDaniel Paoliello-1/+32
2022-08-26Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiserbors-9/+12
session: stabilize split debuginfo on linux Stabilize the `-Csplit-debuginfo` flag... - ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance. - ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable.
2022-08-26translations(rustc_session): migrate check_expected_reuseLuis Cardoso-20/+12
This commit migrates the errors in the function check_expected_reuse to use the new SessionDiagnostic. It also does some small refactor for the IncorrectCguReuseType to include the 'at least' word in the fluent translation file
2022-08-26translations(rustc_session): migrate 80% of the file parse.rsLuis Cardoso-11/+44
This commit migrates around 80% of the parse file to use SsessionDiagnostic We still have to migrate struct_err and struct_warn.
2022-08-26translations(rustc_session): migrate the file cgu_reuse_trackerLuis Cardoso-5/+54
This commit migrates the errors that indicates an incorrect CGU type and the fatal error that indicates that a CGU has not been correctly recorded
2022-08-21Hotfix ftl err name, added check for err.code in create_feature_errnidnogg-1/+3
2022-08-21Fixed failing tests (missing labels), added automatic error code in ↵nidnogg-2/+3
create_feature_err() builder
2022-08-22Fix incorrect return type of emit_fatalPark Jaeon [파차]-1/+1
Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
2022-08-22Support #[fatal(..)]finalchild-0/+25
2022-08-21Add Handler::struct_diagnostic()Xiretza-1/+9
This unifies the struct_{warn,error,fatal}() methods in one generic method.
2022-08-18session: stabilize split debuginfo on linuxDavid Wood-9/+12
Stabilize the `-Csplit-debuginfo` flag... - ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance. - ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable. Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-17Reenable early feature-gates as future-compat warningsChristopher Durham-3/+52
2022-08-15Revert "Revert "Remove num_cpus dependency from bootstrap, build-manifest ↵The 8472-1/+1
and rustc_session"" This reverts commit 1ae4b258267462da0b1aae1badcf83578153c799.
2022-08-12Adjust cfgsMark Rousskov-43/+42
2022-08-07add -Zextra-const-ub-checks to enable more UB checking in const-evalRalf Jung-0/+2
2022-07-31Rollup merge of #99620 - hudson-ayers:fix-location-detail, r=davidtwcoMatthias Krüger-4/+7
`-Z location-detail`: provide option to disable all location details As reported [here](https://github.com/rust-lang/rust/pull/89920#issuecomment-1190598924), when I first implemented the `-Z location-detail` flag there was a bug, where passing an empty list was not correctly supported, and instead rejected by the compiler. This PR fixes that such that passing an empty list results in no location details being tracked, as originally specified in https://github.com/rust-lang/rfcs/pull/2091 . This PR also adds a test case to verify that this option continues to work as intended.
2022-07-31Rollup merge of #99519 - Urgau:check-cfg-implicit, r=petrochenkovMatthias Krüger-14/+0
Remove implicit names and values from `--cfg` in `--check-cfg` This PR remove the implicit names and values from `--cfg` in `--check-cfg` because the behavior is quite surprising but also because it's really easy to inadvertently really on the implicitness and when the `--cfg` is not set anymore to have an unexpected warning from an unexpected condition that pass with the implicitness. This change in behavior will also enable us to warn when an unexpected `--cfg` is passed, ex: the user wrote `--cfg=unstabl` instead of `--cfg=unstable`. The implementation of the warning will be done in a follow-up PR. cc `@petrochenkov`
2022-07-30Auto merge of #99123 - mystor:crossbeam_bridge, r=eddybbors-0/+27
proc_macro: use crossbeam channels for the proc_macro cross-thread bridge This is done by having the crossbeam dependency inserted into the `proc_macro` server code from the server side, to avoid adding a dependency to `proc_macro`. In addition, this introduces a -Z command-line option which will switch rustc to run proc-macros using this cross-thread executor. With the changes to the bridge in #98186, #98187, #98188 and #98189, the performance of the executor should be much closer to same-thread execution. In local testing, the crossbeam executor was substantially more performant than either of the two existing `CrossThread` strategies, so they have been removed to keep things simple. r? `@eddyb`
2022-07-29proc_macro: use crossbeam channels for the proc_macro cross-thread bridgeNika Layzell-0/+27
This is done by having the crossbeam dependency inserted into the proc_macro server code from the server side, to avoid adding a dependency to proc_macro. In addition, this introduces a -Z command-line option which will switch rustc to run proc-macros using this cross-thread executor. With the changes to the bridge in #98186, #98187, #98188 and #98189, the performance of the executor should be much closer to same-thread execution. In local testing, the crossbeam executor was substantially more performant than either of the two existing CrossThread strategies, so they have been removed to keep things simple.
2022-07-29Auto merge of #99467 - BelovDV:add_option_link_arg, r=petrochenkovbors-3/+19
flag '-l link-arg=___ was added #99427
2022-07-28location-detail: disable all location details when passed `none`Hudson Ayers-4/+7
Prior to this fix, `-Z location-detail` provided no mechanism for disabling all location details. This commit also adds a test case to verify that this option continues to work as intended, and clarifies the documentation of this option.
2022-07-28Use line numbers relative to function in mir opt testsNilstrieb-0/+2
This adds a new option, `-Zmir-pretty-relative-line-numbers`, that is then used in compiletest for the mir-opt tests.
2022-07-27lint: add bad opt access internal lintDavid Wood-296/+354
Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`. Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted. A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27session: disable internal lints for rustdocDavid Wood-0/+8
If an internal lint uses `typeck_results` or similar queries then that can result in rustdoc checking code that it shouldn't (e.g. from other platforms) and emit compilation errors. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-26Lib kind -l link-arg:Daniil Belov-3/+19
arbitrary link argument like -C link-arg, but respecting relative order to other `-l` options, unstable
2022-07-25feat: impl export-executable-symbolscsmoe-0/+2
2022-07-23Auto merge of #98208 - ivanloz:master, r=nagisabors-1/+2
Add support for LLVM ShadowCallStack. LLVMs ShadowCallStack provides backward edge control flow integrity protection by using a separate shadow stack to store and retrieve a function's return address. LLVM currently only supports this for AArch64 targets. The x18 register is used to hold the pointer to the shadow stack, and therefore this only works on ABIs which reserve x18. Further details are available in the [LLVM ShadowCallStack](https://clang.llvm.org/docs/ShadowCallStack.html) docs. # Usage `-Zsanitizer=shadow-call-stack` # Comments/Caveats * Currently only enabled for the aarch64-linux-android target * Requires the platform to define a runtime to initialize the shadow stack, see the [LLVM docs](https://clang.llvm.org/docs/ShadowCallStack.html) for more detail.
2022-07-21Rollup merge of #99528 - matthiaskrgr:2022_07_perf, r=estebankMatthias Krüger-1/+1
couple of clippy::perf fixes
2022-07-21Auto merge of #98162 - nextsilicon:support_lto_embed_bitcode, r=davidtwcobors-0/+2
Allow to disable thinLTO buffer to support lto-embed-bitcode lld feature Hello This change is to fix issue (https://github.com/rust-lang/rust/issues/84395) in which passing "-lto-embed-bitcode=optimized" to lld when linking rust code via linker-plugin-lto doesn't produce the expected result. Instead of emitting a single unified module into a llvmbc section of the linked elf, it emits multiple submodules. This is caused because rustc emits the BC modules after running llvm `createWriteThinLTOBitcodePass` pass. Which in turn triggers a thinLTO linkage and causes the said issue. This patch allows via compiler flag (-Cemit-thin-lto=<bool>) to select between running `createWriteThinLTOBitcodePass` and `createBitcodeWriterPass`. Note this pattern of selecting between those 2 passes is common inside of LLVM code. The default is to match the old behavior.
2022-07-20Remove implicit names and values from --cfg in --check-cfgUrgau-14/+0
2022-07-20Add ShadowCallStack SupportIvan Lozano-1/+2
Adds support for the LLVM ShadowCallStack sanitizer.
2022-07-20clippy::perf fixesMatthias Krüger-1/+1
2022-07-19Add flag to configure `noalias` on `Box<T>`nils-0/+2
To aid making an informed decision about the aliasing rules of box, give users an option to remove `noalias` from box.
2022-07-18Rollup merge of #99360 - compiler-errors:issue-99331, r=fee1-deadYuki Okushi-0/+8
Do not ICE when we have `-Zunpretty=expanded` with invalid ABI Fixes #99331
2022-07-16Do not ICE when we have -Zunpretty=expand with invalid ABIMichael Goulet-0/+8
2022-07-16Stabilize `let_chains`Caio-1/+1