https://github.com/citymarina updated https://github.com/llvm/llvm-project/pull/178005
>From 52f1c204af4cddf809a258e22fc44c5b5ff923b4 Mon Sep 17 00:00:00 2001 From: Marina Taylor <[email protected]> Date: Wed, 4 Feb 2026 14:21:07 +0000 Subject: [PATCH] [Driver][Darwin] Pass stack usage file for LTO Add a .su extension to the main output's filename and pass this down to the LLVM layer. rdar://143089305 --- clang/lib/Driver/ToolChains/Darwin.cpp | 9 +++++++++ clang/test/Driver/darwin-ld-lto.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index c2dea22670df4..ba547c8fd8b0c 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -660,6 +660,15 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString("-lto-stats-file=" + StatsFile.str())); } + // Set up stack usage file path. + if (Args.hasArg(options::OPT_fstack_usage)) { + SmallString<128> StackUsageFile(Output.getFilename()); + llvm::sys::path::replace_extension(StackUsageFile, "su"); + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back( + Args.MakeArgString("-stack-usage-file=" + StackUsageFile)); + } + // It seems that the 'e' option is completely ignored for dynamic executables // (the default), and with static executables, the last one wins, as expected. Args.addAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, options::OPT_t, diff --git a/clang/test/Driver/darwin-ld-lto.c b/clang/test/Driver/darwin-ld-lto.c index b96d5ab30b496..6473248dfabdd 100644 --- a/clang/test/Driver/darwin-ld-lto.c +++ b/clang/test/Driver/darwin-ld-lto.c @@ -46,3 +46,8 @@ // RUN: FileCheck --check-prefix=KEXT %s // KEXT: {{ld(.exe)?"}} // KEXT: "-mllvm" "-disable-atexit-based-global-dtor-lowering" + +// Check that we select a filename for -fstack-usage. +// RUN: %clang --target=arm64-apple-darwin %s -flto -fstack-usage -o foo \ +// RUN: -### 2>&1 | FileCheck --check-prefix=STACKUSAGE %s +// STACKUSAGE: "-mllvm" "-stack-usage-file=foo.su" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
