From 30f7a224325124241d2164e077ac83ae2c12cc9a Mon Sep 17 00:00:00 2001 From: dramforever Date: Mon, 30 Jun 2025 00:54:32 +0800 Subject: [PATCH] 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. --- pkgs/development/compilers/rust/rustc.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 01bcdfd11fb0..18a889fe9349 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -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