[llvm] [dsymutil] Add option to copy swiftmodules built from interface (PR #165293)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 11:43:38 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Roy Shi (royitaqi)
<details>
<summary>Changes</summary>
The default behavior is to _not_ copy such swiftmodules into the dSYM, as perviously set by 96f95c9d89d8a1784d3865fa941fb1c510f4e2d7.
This patch adds the option to override the behavior, so that such swiftmodules _are_ copied into the dSYM. This is useful when the dSYM will be used on a machine which has a different Xcode/SDK.
---
Full diff: https://github.com/llvm/llvm-project/pull/165293.diff
5 Files Affected:
- (modified) llvm/test/tools/dsymutil/cmdline.test (+1)
- (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.cpp (+4-3)
- (modified) llvm/tools/dsymutil/LinkUtils.h (+7)
- (modified) llvm/tools/dsymutil/Options.td (+8)
- (modified) llvm/tools/dsymutil/dsymutil.cpp (+3)
``````````diff
diff --git a/llvm/test/tools/dsymutil/cmdline.test b/llvm/test/tools/dsymutil/cmdline.test
index 1574fe35f5254..0b0bce194d575 100644
--- a/llvm/test/tools/dsymutil/cmdline.test
+++ b/llvm/test/tools/dsymutil/cmdline.test
@@ -14,6 +14,7 @@ CHECK: -fat64
CHECK: -flat
CHECK: -gen-reproducer
CHECK: -help
+CHECK: -include-swiftmodules-from-interface
CHECK: -keep-function-for-static
CHECK: -no-object-timestamp
CHECK: -no-odr
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index b91c27e6a0f86..ee1e9060657b0 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -794,9 +794,10 @@ bool DwarfLinkerForBinary::linkImpl(
reportWarning("Could not parse binary Swift module: " +
toString(FromInterfaceOrErr.takeError()),
Obj->getObjectFilename());
- // Only skip swiftmodules that could be parsed and are
- // positively identified as textual.
- } else if (*FromInterfaceOrErr) {
+ // Only skip swiftmodules that could be parsed and are positively
+ // identified as textual. Do so only when the option allows.
+ } else if (*FromInterfaceOrErr &&
+ !Options.IncludeSwiftModulesFromInterface) {
if (Options.Verbose)
outs() << "Skipping compiled textual Swift interface: "
<< Obj->getObjectFilename() << "\n";
diff --git a/llvm/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h
index ad5515a04333e..c333a3d4afee0 100644
--- a/llvm/tools/dsymutil/LinkUtils.h
+++ b/llvm/tools/dsymutil/LinkUtils.h
@@ -114,6 +114,13 @@ struct LinkOptions {
/// Whether all remarks should be kept or only remarks with valid debug
/// locations.
bool RemarksKeepAll = true;
+
+ /// Whether or not to copy binary swiftmodules built from textual
+ /// .swiftinterface files into the dSYM bundle. These typically come only
+ /// from the SDK (since textual interfaces require library evolution) and
+ /// thus are a waste of space to copy into the bundle. Turn this on if the
+ /// swiftmodules are different from those in the SDK.
+ bool IncludeSwiftModulesFromInterface = false;
/// @}
LinkOptions() = default;
diff --git a/llvm/tools/dsymutil/Options.td b/llvm/tools/dsymutil/Options.td
index ad35e55e33b12..e99bc12fa7fd8 100644
--- a/llvm/tools/dsymutil/Options.td
+++ b/llvm/tools/dsymutil/Options.td
@@ -202,6 +202,14 @@ def remarks_drop_without_debug: Flag<["--", "-"], "remarks-drop-without-debug">,
"all remarks are kept.">,
Group<grp_general>;
+def include_swiftmodules_from_interface: Flag<["--", "-"], "include-swiftmodules-from-interface">,
+ HelpText<"Whether or not to copy binary swiftmodules built from textual "
+ ".swiftinterface files into the dSYM bundle. These typically come only "
+ "from the SDK (since textual interfaces require library evolution) and "
+ "thus are a waste of space to copy into the bundle. Turn this on if the "
+ "swiftmodules are different from those in the SDK.">,
+ Group<grp_general>;
+
def linker: Separate<["--", "-"], "linker">,
MetaVarName<"<DWARF linker type>">,
HelpText<"Specify the desired type of DWARF linker. Defaults to 'classic'">,
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 913077eb0b06d..688f6aaf3d0c9 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -391,6 +391,9 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
Options.LinkOpts.RemarksKeepAll =
!Args.hasArg(OPT_remarks_drop_without_debug);
+ Options.LinkOpts.IncludeSwiftModulesFromInterface =
+ Args.hasArg(OPT_include_swiftmodules_from_interface);
+
if (opt::Arg *BuildVariantSuffix = Args.getLastArg(OPT_build_variant_suffix))
Options.LinkOpts.BuildVariantSuffix = BuildVariantSuffix->getValue();
``````````
</details>
https://github.com/llvm/llvm-project/pull/165293
More information about the llvm-commits
mailing list