Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/docs/CommandGuide/dsymutil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ OPTIONS

Print this help output.

.. option:: --include-swiftmodules-from-interface

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.

.. option:: --keep-function-for-static

Make a static variable keep the enclosing function even if it would have been
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# RUN: dsymutil -include-swiftmodules-from-interface -verbose -oso-prepend-path=%p -y -o %t.dSYM %s | FileCheck %s
#
# RUN: dsymutil -include-swiftmodules-from-interface --linker parallel -verbose -oso-prepend-path=%p -y %s -o %t-parallel.dSYM | FileCheck %s
#
# To regenerate:
# echo ''>I.swift
# echo ''>B.swift
# echo 'import I'>main.swift
# xcrun swiftc -emit-module-interface-path I.swiftinterface -enable-library-evolution I.swift
# xcrun swiftc -emit-module-path B.swiftmodule B.swift -Xfrontend -no-serialize-debugging-options
# xcrun swiftc -explicit-module-build main.swift -I. -module-cache-path cache -g -Xfrontend -no-serialize-debugging-options
# output is "B.swiftmodule" and "cache/I*.swiftmodule"
#
# CHECK-NOT: Skipping compiled textual Swift interface: {{.*}}/Inputs/Binary.swiftmodule
# CHECK-NOT: Skipping compiled textual Swift interface: {{.*}}/Inputs/FromInterface.swiftmodule

#
---
triple: 'arm64-apple-darwin'
objects:
- filename: '../Inputs/Binary.swiftmodule'
timestamp: 0
type: 50
symbols: []
- filename: '../Inputs/FromInterface.swiftmodule'
timestamp: 0
type: 50
symbols: []
- filename: '../Inputs/FromInterface.swiftmodule'
timestamp: 0
type: 50
symbols: []
...
1 change: 1 addition & 0 deletions llvm/test/tools/dsymutil/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 7 additions & 0 deletions llvm/tools/dsymutil/LinkUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions llvm/tools/dsymutil/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -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'">,
Expand Down
3 changes: 3 additions & 0 deletions llvm/tools/dsymutil/dsymutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down