Author: Marina Taylor Date: 2026-02-09T12:32:13Z New Revision: f6acc800f2c6e57e2e22bad3f475cd7a01139ca1
URL: https://github.com/llvm/llvm-project/commit/f6acc800f2c6e57e2e22bad3f475cd7a01139ca1 DIFF: https://github.com/llvm/llvm-project/commit/f6acc800f2c6e57e2e22bad3f475cd7a01139ca1.diff LOG: [Driver][Darwin] Pass stack usage file for LTO (#178005) Add a .su extension to the main output's filename and pass this down to the LLVM layer. rdar://143089305 Added: Modified: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/darwin-ld-lto.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 6e523bd113c85..073f23950160c 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -665,6 +665,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
