[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkTjxNEmCTnuH5f41WB50ef6ErBM2Kp2zJ-t9q_5U8rBA@mail.gmail.com>
Date: Mon, 23 May 2022 11:44:51 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
Jarkko Sakkinen <jarkko@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Finn Behrens <me@...enk.de>,
Adam Bratschi-Kaye <ark.email@...il.com>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Michael Ellerman <mpe@...erman.id.au>,
Sven Van Asbroeck <thesven73@...il.com>,
Gary Guo <gary@...yguo.net>,
Boris-Chengbiao Zhou <bobo1239@....de>,
Boqun Feng <boqun.feng@...il.com>,
Douglas Su <d0u9.su@...look.com>,
Dariusz Sosnowski <dsosnowski@...snowski.pl>,
Antonio Terceiro <antonio.terceiro@...aro.org>,
Daniel Xu <dxu@...uu.xyz>, Miguel Cano <macanroj@...il.com>,
David Gow <davidgow@...gle.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Richard Weinberger <richard@....at>,
Anton Ivanov <anton.ivanov@...bridgegreys.com>,
Johannes Berg <johannes@...solutions.net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, linux-kbuild@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linuxppc-dev@...ts.ozlabs.org, linux-riscv@...ts.infradead.org,
linux-um@...ts.infradead.org
Subject: Re: [PATCH v7 21/25] Kbuild: add Rust support
> +choice
> + prompt "Optimization level"
> + default RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C
> + depends on RUST
> + help
> + Controls rustc's `-Copt-level` codegen option.
> +
> + This flag controls the optimization level.
> +
> + If unsure, say "Similar as chosen for C".
> +
> +config RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C
> + bool "Similar as chosen for C"
> + help
> + This choice will pick a similar optimization level as chosen in
> + the "Compiler optimization level" for C:
> +
> + -O2 is currently mapped to -Copt-level=2
> + -O3 is currently mapped to -Copt-level=3
> + -Os is currently mapped to -Copt-level=s
> +
> + The mapping may change over time to follow the intended semantics
> + of the choice for C as sensibly as possible.
> +
> + This is the default.
> +
> +config RUST_OPT_LEVEL_0
> + bool "No optimizations (-Copt-level=0)"
> + help
> + Not recommended for most purposes. It may come in handy for debugging
> + suspected optimizer bugs, unexpected undefined behavior, etc.
> +
> + Note that this level will *not* enable debug assertions nor overflow
> + checks on its own (like it happens when interacting with rustc
> + directly). Use the corresponding configuration options to control
> + that instead, orthogonally.
> +
> + Note this level may cause excessive stack usage, which can lead to stack
> + overflow and subsequent crashes.
> +
> +config RUST_OPT_LEVEL_1
> + bool "Basic optimizations (-Copt-level=1)"
> + help
> + Useful for debugging without getting too lost, but without
> + the overhead and boilerplate of no optimizations at all.
> +
> + Note this level may cause excessive stack usage, which can lead to stack
> + overflow and subsequent crashes.
> +
> +config RUST_OPT_LEVEL_2
> + bool "Some optimizations (-Copt-level=2)"
> + help
> + The sensible choice in most cases.
> +
> +config RUST_OPT_LEVEL_3
> + bool "All optimizations (-Copt-level=3)"
> + help
> + Yet more performance (hopefully).
> +
> +config RUST_OPT_LEVEL_S
> + bool "Optimize for size (-Copt-level=s)"
> + help
> + Smaller kernel, ideally without too much performance loss.
> +
> +config RUST_OPT_LEVEL_Z
> + bool "Optimize for size, no loop vectorization (-Copt-level=z)"
> + help
> + Like the previous level, but also turn off loop vectorization.
I'm super not into having the rust optimization level differ from the
C optimization level. This is just someone having too much fun
wrapping every compiler flag in a kbuild option. Either folks wan't
smaller size or more optimizations. Allowing for RUST_OPT_LEVEL_S and
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE or RUST_OPT_LEVEL_3 and
CONFIG_CC_OPTIMIZE_FOR_SIZE is just wacky nonsense that's going to
make randconfig bug reports more confusing to tease out.
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists