[Scons-users] Adding support for split dwarf info

William Blevins wblevins001 at gmail.com
Thu Jul 28 16:17:00 EDT 2016


Andrew,

I'm not an expert on complex builders, but I *think* what you still need is
to associate an action with the '.dwo' scanner key.

Please look at SCons.Tool.swig.py
<https://bitbucket.org/scons/scons/src/4e1b77a684f40c9df0d66bd2da415815c436f6e3/src/engine/SCons/Tool/swig.py?at=default&fileviewer=file-view-default>
in the generate method. You will notice that they add an action for the
swig key ".i" to the CFileBuilder.

Hopefully, someone with more experience will chime in if I am mistaken.

V/R,
William



On Thu, Jul 28, 2016 at 8:45 PM, Andrew C. Morrow <andrew.c.morrow at gmail.com
> wrote:

>
> I'd like to write a SCons Tool to support debug fission:
>
> https://gcc.gnu.org/wiki/DebugFission
>
> The motivation for doing so is to reduce the duplication of DWARF
> debugging information in the SCons cache. In a large statically linked
> codebase, each binary that is injected into the cache contains its own copy
> of the DWARF info for each .o that it linked. Especially for things like
> unit tests, this may result in many many copies of the same DWARF info
> taking up space in the cache.
>
> If we could use debug fission, then all of the debug information would be
> contained only in .dwo files, and not reproduced in each executable.
>
> The effect of adding -gsplit-dwarf to CCFLAGS is that each invocation of
> the compiler to generate a .o file from a C or C++ source file also emits a
> .dwo file. To achieve the aim of making the cache smaller, but also keep
> the debugging information consistent, it is important that this .dwo file
> move into and out of the cache in tandem with its associated .o file.
>
> However, I'm having some trouble making this work. My idea was to add an
> emitter to the various Object builders that added the .dwo file to the
> associated targets. This "works", in the sense that the emitter runs.
> However, the .dwo file is never pushed to the Cache.
>
> Additionally, SCons seems not to know how to build the .dwo file: if named
> as an explicit target, the build fails. I had assumed, mistakenly it seems,
> that the additional emitted target would associate it with the Action, but
> this does not seem to be the case.
>
> Here is what I have so far, suggestions on how to take this further are
> much appreciated:
>
> import SCons
> import itertools
>
> def _dwo_emitter(target, source, env):
>     new_targets = []
>     for t in target:
>         dwo = SCons.Util.splitext(str(t))[0] + ".dwo"
>         dwotarget = (t.builder.target_factory or env.File)(dwo)
>         print(str(dwotarget))
>         new_targets.append(dwotarget)
>     targets = target + new_targets
>     return (targets, source)
>
> def generate(env):
>
>     env.Append(
>         CCFLAGS=[
>             "-gsplit-dwarf",
>         ],
>         LINKFLAGS=[
>             "-fuse-ld=gold",
>             "-Wl,--gdb-index",
>         ]
>     )
>
>     # TODO: This should filter for C/C++ language files only
>     for object_builder in SCons.Tool.createObjBuilders(env):
>         emitterdict = object_builder.builder.emitter
>         for suffix in emitterdict.iterkeys():
>             base = emitterdict[suffix]
>             emitterdict[suffix] = SCons.Builder.ListEmitter([
>                 base,
>                 _dwo_emitter,
>             ])
>
> def exists(env):
>     return true
>
> Thanks,
> Andrew
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20160728/fe726940/attachment.html>


More information about the Scons-users mailing list