[clang] [Clang] Add clang driver option -fpartition-static-data-sections (PR #124991)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 23 11:03:04 PST 2025


mingmingl-llvm wrote:

> Can we ensure that `-z,keep-data-section-prefix` gets passed to the linker too from the driver? Should it be part of this pull request?

I actually did wonder about it when making the changes; inferred from the current status, it's more canonical to let users specify linker options separately.

[tools::gnutools::Linker::ConstructJob](https://github.com/llvm/llvm-project/blob/1cb99036b41562b233e7bb44801202742733f5d3/clang/lib/Driver/ToolChains/Gnu.cpp#L271) and its caller [LinkerWrapper::ConstructJob](https://github.com/llvm/llvm-project/blob/4e44e8761795d4672121368929b9c99f6dbaffa7/clang/lib/Driver/ToolChains/Clang.cpp#L9223) [^1] constructs the linker options, and PGO linker options like  `-keep-text-section-prefix` are not implied; toolchain users typically specify `-Wl,-z,keep-text-section-prefix` besides `-fprofile-use` to partition text sections.  

[^1]: While 'gnu' is in the namespace / filename, the functions get invoked when compiling a binary the common way.

https://github.com/llvm/llvm-project/pull/124991


More information about the cfe-commits mailing list