Skip to content

Commit 5f48fa8

Browse files
authored
Merge pull request torvalds#846 from ojeda/drop-optlevel-diff-c
rust: drop support for different optimization levels than C
2 parents 246f942 + fee989b commit 5f48fa8

File tree

3 files changed

+6
-89
lines changed

3 files changed

+6
-89
lines changed

Documentation/rust/arch-support.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
1515
============ ================ ==============================================
1616
Architecture Level of support Constraints
1717
============ ================ ==============================================
18-
``arm`` Maintained ``armv6`` and compatible only,
19-
``RUST_OPT_LEVEL >= 2``.
18+
``arm`` Maintained ``armv6`` and compatible only.
2019
``arm64`` Maintained None.
21-
``powerpc`` Maintained ``ppc64le`` only, ``RUST_OPT_LEVEL < 2``
22-
requires ``CONFIG_THREAD_SHIFT=15``.
20+
``powerpc`` Maintained ``ppc64le`` only.
2321
``riscv`` Maintained ``riscv64`` only.
2422
``x86`` Maintained ``x86_64`` only.
2523
============ ================ ==============================================

Makefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -819,27 +819,19 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
819819

820820
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
821821
KBUILD_CFLAGS += -O2
822-
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 2
822+
KBUILD_RUSTFLAGS += -Copt-level=2
823823
else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
824824
KBUILD_CFLAGS += -O3
825-
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 3
825+
KBUILD_RUSTFLAGS += -Copt-level=3
826826
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
827827
KBUILD_CFLAGS += -Os
828-
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := s
828+
KBUILD_RUSTFLAGS += -Copt-level=s
829829
endif
830830

831831
# Always set `debug-assertions` and `overflow-checks` because their default
832832
# depends on `opt-level` and `debug-assertions`, respectively.
833833
KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
834834
KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
835-
KBUILD_RUSTFLAGS += -Copt-level=$\
836-
$(if $(CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C),$(KBUILD_RUSTFLAGS_OPT_LEVEL_MAP))$\
837-
$(if $(CONFIG_RUST_OPT_LEVEL_0),0)$\
838-
$(if $(CONFIG_RUST_OPT_LEVEL_1),1)$\
839-
$(if $(CONFIG_RUST_OPT_LEVEL_2),2)$\
840-
$(if $(CONFIG_RUST_OPT_LEVEL_3),3)$\
841-
$(if $(CONFIG_RUST_OPT_LEVEL_S),s)$\
842-
$(if $(CONFIG_RUST_OPT_LEVEL_Z),z)
843835

844836
# Tell gcc to never replace conditional load with a non-conditional one
845837
ifdef CONFIG_CC_IS_GCC

lib/Kconfig.debug

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,81 +2720,9 @@ config RUST_OVERFLOW_CHECKS
27202720

27212721
If unsure, say Y.
27222722

2723-
choice
2724-
prompt "Optimization level"
2725-
default RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C
2726-
depends on RUST
2727-
help
2728-
Controls rustc's `-Copt-level` codegen option.
2729-
2730-
This flag controls the optimization level.
2731-
2732-
If unsure, say "Similar as chosen for C".
2733-
2734-
config RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C
2735-
bool "Similar as chosen for C"
2736-
help
2737-
This choice will pick a similar optimization level as chosen in
2738-
the "Compiler optimization level" for C:
2739-
2740-
-O2 is currently mapped to -Copt-level=2
2741-
-O3 is currently mapped to -Copt-level=3
2742-
-Os is currently mapped to -Copt-level=s
2743-
2744-
The mapping may change over time to follow the intended semantics
2745-
of the choice for C as sensibly as possible.
2746-
2747-
This is the default.
2748-
2749-
config RUST_OPT_LEVEL_0
2750-
bool "No optimizations (-Copt-level=0)"
2751-
help
2752-
Not recommended for most purposes. It may come in handy for debugging
2753-
suspected optimizer bugs, unexpected undefined behavior, etc.
2754-
2755-
Note that this level will *not* enable debug assertions nor overflow
2756-
checks on its own (like it happens when interacting with rustc
2757-
directly). Use the corresponding configuration options to control
2758-
that instead, orthogonally.
2759-
2760-
Note this level may cause excessive stack usage, which can lead to stack
2761-
overflow and subsequent crashes.
2762-
2763-
config RUST_OPT_LEVEL_1
2764-
bool "Basic optimizations (-Copt-level=1)"
2765-
help
2766-
Useful for debugging without getting too lost, but without
2767-
the overhead and boilerplate of no optimizations at all.
2768-
2769-
Note this level may cause excessive stack usage, which can lead to stack
2770-
overflow and subsequent crashes.
2771-
2772-
config RUST_OPT_LEVEL_2
2773-
bool "Some optimizations (-Copt-level=2)"
2774-
help
2775-
The sensible choice in most cases.
2776-
2777-
config RUST_OPT_LEVEL_3
2778-
bool "All optimizations (-Copt-level=3)"
2779-
help
2780-
Yet more performance (hopefully).
2781-
2782-
config RUST_OPT_LEVEL_S
2783-
bool "Optimize for size (-Copt-level=s)"
2784-
help
2785-
Smaller kernel, ideally without too much performance loss.
2786-
2787-
config RUST_OPT_LEVEL_Z
2788-
bool "Optimize for size, no loop vectorization (-Copt-level=z)"
2789-
help
2790-
Like the previous level, but also turn off loop vectorization.
2791-
2792-
endchoice
2793-
27942723
choice
27952724
prompt "Build-time assertions"
2796-
default RUST_BUILD_ASSERT_ALLOW if RUST_OPT_LEVEL_0
2797-
default RUST_BUILD_ASSERT_DENY if !RUST_OPT_LEVEL_0
2725+
default RUST_BUILD_ASSERT_DENY
27982726
depends on RUST
27992727
help
28002728
Controls how are `build_error!` and `build_assert!` handled during build.
@@ -2822,7 +2750,6 @@ config RUST_BUILD_ASSERT_WARN
28222750

28232751
config RUST_BUILD_ASSERT_DENY
28242752
bool "Deny"
2825-
depends on !RUST_OPT_LEVEL_0
28262753
help
28272754
Unoptimized calls to `build_error!` will abort compilation.
28282755

0 commit comments

Comments
 (0)