rustc: Set rust.frame-pointers if !isx86_32

We want -Cforce-frame-pointers=yes when building rustc itself, but the
bootstrap process does not use cargoSetupHook, so set the bootstrap
config option rust.frame-pointers = true if target is not x86_32.

Note that std is unconditionally compiled with frame pointers. See code
comment for elaboration.

See also #399014 for discussion when we enabled frame pointers for C.
This commit is contained in:
dramforever
2025-06-30 00:54:32 +08:00
committed by Alyssa Ross
parent e05a1a15ac
commit 30f7a22432
+11
View File
@@ -260,6 +260,17 @@ stdenv.mkDerivation (finalAttrs: {
# https://github.com/NixOS/nixpkgs/issues/311930
"--llvm-libunwind=${if withBundledLLVM then "in-tree" else "system"}"
"--enable-use-libcxx"
]
++ optionals (!stdenv.hostPlatform.isx86_32) [
# This enables frame pointers for the compiler itself.
#
# Note that when compiling std, frame pointers (or at least non-leaf
# frame pointers, depending on version) are unconditionally enabled and
# cannot be overridden, so we do not touch that. (Also note this only
# applies to functions that can be immediately compiled when building
# std. Generic functions that do codegen when called in user code obey
# -Cforce-frame-pointers specified then, if any)
"--set rust.frame-pointers"
];
# if we already have a rust compiler for build just compile the target std