rust/compiler
Stuart Cook b618119fa9
Rollup merge of #145974 - pmur:murp/stabilize-zno-jump-tables, r=wesleywiser
Stabilize -Zno-jump-tables into -Cjump-tables=bool

I propose stabilizing the -Zno-jump-tables option into -Cjump-tables=<bool>.

# `-Zno-jump-tables` stabilization report
## What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?
No RFC was created for this option. This was a narrowly scoped option introduced in rust-lang/rust#105812 to support code generation requirements of the x86-64 linux kernel, and eventually other targets as Rust For Linux grows.

The tracking is rust-lang/rust#116592.

##  What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

The behavior of this flag is well defined, and mimics the existing `-fno-jump-tables` option currently available with LLVM and GCC with some caveats:

* Unlike clang or gcc, this option may be ignored by the code generation backend. Rust can support multiple code-generation backends. For stabilization, only the LLVM backend honors this option.
* The usage of this option will not guarantee a library or binary is free of jump tables. To ensure a jump-table free binary, all crates in the build graph must be compiled with this option. This includes implicitly linked crates such as std or core.
* This option only enforces the crate being compiled is free of jump tables.
* No verification is done to ensure other crates are compiled with this option. Enforcing code generation options are applied across the crate graph is out of scope for this option.

What should the flag name be?
* As introduced, this option was named `-Zno-jump-tables`. However, other major toolchains allow both positive and negative variants of this option to toggle this feature. Renaming the option to `-Cjump-tables=<bool>` makes this option consistent, and if for some reason, expandable to other arguments in the future. Notably, many LLVM targets have a configurable and different thresholds for when to lower into a jump table.

## Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those.
No. This option is used exclusively to gate a very specific class of optimization.

## Summarize the major parts of the implementation and provide links into the code (or to PRs)
* The original PR rust-lang/rust#105812 by ```@ojeda```
* The stabilized CLI option is parsed as a bool:
68bfda9025/compiler/rustc_session/src/options.rs (L2025-L2026)
* This options adds an attribute to each llvm function via:
68bfda9025/compiler/rustc_codegen_llvm/src/attributes.rs (L210-L215)
* Finally, the rustc book is updated with the new option:
68bfda9025/src/doc/rustc/src/codegen-options/index.md (L212-L223)

## Has a call-for-testing period been conducted? If so, what feedback was received?
No. The option has originally created is being used by Rust For Linux to build the x86-64 kernel without issue.

## What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?
There are no outstanding issues.

## Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization

* ```@ojeda``` implemented this feature in rust-lang/rust#105815 as  `-Zno-jump-tables`.
* ```@tgross35``` created and maintained the tracking issue rust-lang/rust#116592, and provided feedback about the naming of the cli option.

## What FIXMEs are still in the code for that feature and why is it ok to leave them there?
There are none.

## What static checks are done that are needed to prevent undefined behavior?
This option cannot cause undefined behavior. It is a boolean option with well defined behavior in both cases.

## In what way does this feature interact with the reference/specification, and are those edits prepared?
This adds a new cli option to `rustc`. The documentation is updated, and the unstable documentation cleaned up in this PR.

## Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries?
No.

## What other unstable features may be exposed by this feature?
None.

## What is tooling support like for this feature, w.r.t rustdoc, clippy, rust-analzyer, rustfmt, etc.?
No support is required from other rust tooling.

## Open Items

- [x] Are there objections renaming `-Zno-jump-tables` to `-Cjump-tables=<bool>`? The consensus is no.
- [x] Is it desirable to keep `-Zno-jump-tables` for a period of time? The consensus is no.

---

Closes rust-lang/rust#116592
2025-11-04 13:44:48 +11:00
..
rustc Make llvm_enzyme a regular cargo feature 2025-09-15 15:31:56 +00:00
rustc_abi Rollup merge of #147134 - workingjubilee:remove-explicit-abialign-deref, r=Zalathar 2025-09-29 15:44:55 +10:00
rustc_arena some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_ast Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril,traviscross 2025-11-01 08:25:44 +01:00
rustc_ast_ir Implement pattern matching for &pin mut|const T 2025-10-30 07:56:16 +08:00
rustc_ast_lowering Rollup merge of #144291 - oli-obk:const_trait_alias, r=fee1-dead 2025-10-31 02:39:14 +01:00
rustc_ast_passes Generate const predicates for const trait aliases 2025-10-30 08:05:37 +00:00
rustc_ast_pretty Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril,traviscross 2025-11-01 08:25:44 +01:00
rustc_attr_parsing Add ParsedDescription to the attribute parsers 2025-11-03 18:27:06 +01:00
rustc_baked_icu_data Use default locale fallback data 2025-08-28 09:48:54 +00:00
rustc_borrowck Rollup merge of #133149 - estebank:niko-rustnation, r=wesleywiser 2025-11-04 13:44:47 +11:00
rustc_builtin_macros Add ParsedDescription to the attribute parsers 2025-11-03 18:27:06 +01:00
rustc_codegen_cranelift Skip codegen_crate call in check mode 2025-10-24 10:25:13 +00:00
rustc_codegen_gcc remove broken link 2025-10-20 20:50:44 +00:00
rustc_codegen_llvm Rollup merge of #145974 - pmur:murp/stabilize-zno-jump-tables, r=wesleywiser 2025-11-04 13:44:48 +11:00
rustc_codegen_ssa Rollup merge of #148247 - bjorn3:minor_symbol_export_cleanup, r=WaffleLapkin 2025-11-03 11:52:40 +11:00
rustc_const_eval Rollup merge of #147520 - sayantn:simd-const-eval, r=RalfJung 2025-11-03 17:20:32 +01:00
rustc_data_structures Rollup merge of #147716 - zhetaicheleba:master, r=jdonszelmann 2025-10-15 23:41:05 +02:00
rustc_driver compiler: Add Windows resources to rustc-main and rustc_driver 2025-09-05 14:06:31 -04:00
rustc_driver_impl Better warning message for crate type unsupported by codegen backend 2025-11-02 12:33:38 +00:00
rustc_error_codes Port cfg!() macro to the new attribute parsing system 2025-11-03 18:23:41 +01:00
rustc_error_messages Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_errors Rollup merge of #148004 - Muscraft:only-single-line-item-attributes, r=estebank 2025-11-03 21:20:22 +01:00
rustc_expand Rollup merge of #147438 - reddevilmidzy:rename-non-inline-module-in-msg, r=fee1-dead 2025-10-18 23:54:44 +02:00
rustc_feature Rename #[pin_project] to #[pin_v2] to avoid naming conflicts 2025-10-30 07:56:17 +08:00
rustc_fluent_macro some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_fs_util Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_graphviz some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hashes some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hir Rollup merge of #145915 - coolreader18:stabilize-fmt_from_fn, r=dtolnay 2025-11-04 13:44:47 +11:00
rustc_hir_analysis Rollup merge of #145915 - coolreader18:stabilize-fmt_from_fn, r=dtolnay 2025-11-04 13:44:47 +11:00
rustc_hir_id rustc_hir_id: Add a comment explaining why the crate exists 2025-08-20 15:04:00 -07:00
rustc_hir_pretty Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril,traviscross 2025-11-01 08:25:44 +01:00
rustc_hir_typeck Rollup merge of #147951 - Kivooeo:plus-equal-let-chains, r=davidtwco 2025-11-03 21:20:21 +01:00
rustc_incremental Use the actual StableCrateId for the incr comp session dir 2025-10-27 15:56:09 +00:00
rustc_index clippy fixes and code simplification 2025-11-02 08:16:38 +00:00
rustc_index_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_infer Rollup merge of #148290 - oli-obk:push-qwxvxyopypry, r=nnethercote 2025-11-02 09:10:38 +01:00
rustc_interface Stabilize -Zjump-tables=<bool> into -Cjump-table=<bool> 2025-11-03 08:12:16 -06:00
rustc_lexer Fix a crash/mislex when more than one frontmatter closing possibility is considered 2025-09-22 15:10:41 -04:00
rustc_lint Rollup merge of #148348 - hkBst:dangling-ptr-lint-1, r=Urgau 2025-11-02 15:56:50 +01:00
rustc_lint_defs Rollup merge of #147185 - RalfJung:repr-c-not-zst, r=petrochenkov 2025-10-28 20:39:32 +11:00
rustc_llvm Rollup merge of #148103 - Zalathar:compression, r=wesleywiser 2025-10-31 18:41:51 +01:00
rustc_log Restrict sysroot crate imports to those defined in this repo. 2025-10-15 13:17:25 +01:00
rustc_macros use declarative macro for #[derive(TryFromU32)] 2025-10-06 14:54:38 +00:00
rustc_metadata Rollup merge of #148306 - zetanumbers:expn_id_decode, r=nnethercote 2025-11-03 17:20:38 +01:00
rustc_middle Auto merge of #148412 - matthiaskrgr:rollup-59a302x, r=matthiaskrgr 2025-11-02 23:12:25 +00:00
rustc_mir_build Rollup merge of #147642 - camelid:misc-const-fixes, r=BoxyUwU 2025-11-02 15:56:48 +01:00
rustc_mir_dataflow Put Analysis back into Results. 2025-10-28 10:26:50 +11:00
rustc_mir_transform clippy fixes and code simplification 2025-11-02 08:16:38 +00:00
rustc_monomorphize Allow unsizing pattern types with pointer base 2025-10-21 11:22:51 +00:00
rustc_next_trait_solver Rollup merge of #144291 - oli-obk:const_trait_alias, r=fee1-dead 2025-10-31 02:39:14 +01:00
rustc_parse Rollup merge of #145903 - Kivooeo:c-style-pointer, r=davidtwco 2025-11-03 17:20:31 +01:00
rustc_parse_format Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_passes Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril,traviscross 2025-11-01 08:25:44 +01:00
rustc_pattern_analysis split definition and use site hidden tys 2025-10-31 14:48:43 +01:00
rustc_privacy Remove QPath::LangItem 2025-10-27 21:19:38 -05:00
rustc_proc_macro Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_public Simplify rustc_public context handling 2025-10-29 23:31:50 +00:00
rustc_public_bridge Simplify rustc_public context handling 2025-10-29 23:31:50 +00:00
rustc_query_impl fixup limit handling code 2025-09-08 15:07:12 -07:00
rustc_query_system Rollup merge of #147830 - Noratrieb:reword-unstable-fingerprint-ice, r=jackh726 2025-10-22 13:20:23 -04:00
rustc_resolve Add note to E0401 2025-11-03 16:24:36 +00:00
rustc_sanitizers Rollup merge of #144936 - rcvalle:rust-cfi-fix-144641, r=lcnr 2025-10-28 20:39:32 +11:00
rustc_serialize Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_session Stabilize -Zjump-tables=<bool> into -Cjump-table=<bool> 2025-11-03 08:12:16 -06:00
rustc_span Rollup merge of #148346 - Alexendoo:cfg-trace-values, r=JonathanBrouwer 2025-11-02 15:56:50 +01:00
rustc_symbol_mangling Fix wasm_import_module attribute cross-crate 2025-11-01 05:04:30 -07:00
rustc_target Rollup merge of #145915 - coolreader18:stabilize-fmt_from_fn, r=dtolnay 2025-11-04 13:44:47 +11:00
rustc_thread_pool some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_trait_selection Auto merge of #148420 - Zalathar:rollup-1rrbzk7, r=Zalathar 2025-11-03 02:52:00 +00:00
rustc_traits Auto merge of #146096 - adwinwhite:handle_normalization_overflow_in_mono1, r=saethlin 2025-10-13 00:20:10 +00:00
rustc_transmute prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
rustc_ty_utils Deduce captures(none) for a return place and parameters 2025-10-25 22:53:52 +02:00
rustc_type_ir Rollup merge of #148153 - osamakader:fix-duplicate-the, r=JonathanBrouwer 2025-10-27 22:13:23 +11:00
rustc_type_ir_macros some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_windows_rc [win] Use find-msvc-tools instead of cc to find the linker and rc on Windows 2025-09-19 12:00:30 -07:00