Discussion:
[Scons-users] Question about splitting debug information
Martin Ritter
2018-10-24 08:41:10 UTC
Permalink
Hi,

I have a question regarding splitting debug information from binaries
and libraries with SCons: What we want to do is to split the debug
information from libraries and executables and put them into separate
files following
https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html

So we wrote a simple builder which does just that:

strip_debug = Builder(
    action='objcopy --only-keep-debug $SOURCE $TARGET && '
    'strip --strip-debug --strip-unneeded $SOURCE && '
    'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
    suffix='.debug', prefix=".debug/")

but obviously this modifies the original $SOURCE. So when running scons
again it will notice that the libraries are not up to date and relink them.

One solution is to first link the library into the build directory and
then copy and strip the files to their final destination. But I was
wondering if there is a way to do this without a temporary copy of the
binaries (which is quite some disk space in our project)

Best Regards,

Martin


--
Dr. Martin Ritter

LMU München, Excellence Cluster Universe
Boltzmannstrasse 2, 85748 Garching

Tel: (+49) 89 35831-7152
Fax: (+49) 89 3299-4002
Andrew C. Morrow
2018-10-24 12:18:17 UTC
Permalink
I'm actually working on this right now, and have something that is pretty
much working. Hopefully lands in the MongoDB master tree this week and I'll
follow up with a link.

Thanks,
Andrew



On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de> wrote:

> Hi,
>
> I have a question regarding splitting debug information from binaries
> and libraries with SCons: What we want to do is to split the debug
> information from libraries and executables and put them into separate
> files following
> https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
>
> So we wrote a simple builder which does just that:
>
> strip_debug = Builder(
> action='objcopy --only-keep-debug $SOURCE $TARGET && '
> 'strip --strip-debug --strip-unneeded $SOURCE && '
> 'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
> suffix='.debug', prefix=".debug/")
>
> but obviously this modifies the original $SOURCE. So when running scons
> again it will notice that the libraries are not up to date and relink them.
>
> One solution is to first link the library into the build directory and
> then copy and strip the files to their final destination. But I was
> wondering if there is a way to do this without a temporary copy of the
> binaries (which is quite some disk space in our project)
>
> Best Regards,
>
> Martin
>
>
> --
> Dr. Martin Ritter
>
> LMU MÃŒnchen, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
Martin Ritter
2018-10-24 14:53:53 UTC
Permalink
Hi Andrew,

thanks, that would be helpful.

Cheers,

Martin

On 24/10/2018 14:18, Andrew C. Morrow wrote:
>
> I'm actually working on this right now, and have something that is
> pretty much working. Hopefully lands in the MongoDB master tree this
> week and I'll follow up with a link.
>
> Thanks,
> Andrew
>
>
>
> On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de
> <mailto:***@lmu.de>> wrote:
>
> Hi,
>
> I have a question regarding splitting debug information from binaries
> and libraries with SCons: What we want to do is to split the debug
> information from libraries and executables and put them into separate
> files following
> https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
>
> So we wrote a simple builder which does just that:
>
> strip_debug = Builder(
>      action='objcopy --only-keep-debug $SOURCE $TARGET && '
>      'strip --strip-debug --strip-unneeded $SOURCE && '
>      'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
>      suffix='.debug', prefix=".debug/")
>
> but obviously this modifies the original $SOURCE. So when running scons
> again it will notice that the libraries are not up to date and
> relink them.
>
> One solution is to first link the library into the build directory and
> then copy and strip the files to their final destination. But I was
> wondering if there is a way to do this without a temporary copy of the
> binaries (which is quite some disk space in our project)
>
> Best Regards,
>
> Martin
>
>
> --
> Dr. Martin Ritter
>
> LMU München, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org <mailto:Scons-***@scons.org>
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>

--
Dr. Martin Ritter

LMU München, Excellence Cluster Universe
Boltzmannstrasse 2, 85748 Garching

Tel: (+49) 89 35831-7152
Fax: (+49) 89 3299-4002
Gary Oberbrunner
2018-10-24 13:18:03 UTC
Permalink
The standard approach for this is to use AddPostAction to do your
post-build steps, rather than a separate builder. Those operate on the
target before its signature is stored.

-- Gary

On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de> wrote:

> Hi,
>
> I have a question regarding splitting debug information from binaries
> and libraries with SCons: What we want to do is to split the debug
> information from libraries and executables and put them into separate
> files following
> https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
>
> So we wrote a simple builder which does just that:
>
> strip_debug = Builder(
> action='objcopy --only-keep-debug $SOURCE $TARGET && '
> 'strip --strip-debug --strip-unneeded $SOURCE && '
> 'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
> suffix='.debug', prefix=".debug/")
>
> but obviously this modifies the original $SOURCE. So when running scons
> again it will notice that the libraries are not up to date and relink them.
>
> One solution is to first link the library into the build directory and
> then copy and strip the files to their final destination. But I was
> wondering if there is a way to do this without a temporary copy of the
> binaries (which is quite some disk space in our project)
>
> Best Regards,
>
> Martin
>
>
> --
> Dr. Martin Ritter
>
> LMU MÃŒnchen, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>


--
Gary
Martin Ritter
2018-10-24 15:01:41 UTC
Permalink
Hi Gary,

thank you, I overlooked AddPostAction. I now have something which does
what I want but I'm looking forward to compare that with Andrews
implementation.

Best Regards,

Martin

On 24/10/2018 15:18, Gary Oberbrunner wrote:
> The standard approach for this is to use AddPostAction to do your
> post-build steps, rather than a separate builder. Those operate on the
> target before its signature is stored.
>
> -- Gary
>
> On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de
> <mailto:***@lmu.de>> wrote:
>
> Hi,
>
> I have a question regarding splitting debug information from binaries
> and libraries with SCons: What we want to do is to split the debug
> information from libraries and executables and put them into separate
> files following
> https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
>
> So we wrote a simple builder which does just that:
>
> strip_debug = Builder(
>      action='objcopy --only-keep-debug $SOURCE $TARGET && '
>      'strip --strip-debug --strip-unneeded $SOURCE && '
>      'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
>      suffix='.debug', prefix=".debug/")
>
> but obviously this modifies the original $SOURCE. So when running scons
> again it will notice that the libraries are not up to date and
> relink them.
>
> One solution is to first link the library into the build directory and
> then copy and strip the files to their final destination. But I was
> wondering if there is a way to do this without a temporary copy of the
> binaries (which is quite some disk space in our project)
>
> Best Regards,
>
> Martin
>
>
> --
> Dr. Martin Ritter
>
> LMU München, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org <mailto:Scons-***@scons.org>
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
>
> --
> Gary
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>

--
Dr. Martin Ritter

LMU München, Excellence Cluster Universe
Boltzmannstrasse 2, 85748 Garching

Tel: (+49) 89 35831-7152
Fax: (+49) 89 3299-4002
Jason Kenny
2018-10-24 15:32:04 UTC
Permalink
Just a question... would this be useful to have in SCons? The Parts extension I work on for SCons did this via adding it to the env["PDB"] = "lib.debug". This required tweaking the actions for the linker tool on posix systems. I find it very useful for similar reasons.

Jason
________________________________
From: Scons-users <scons-users-***@scons.org> on behalf of Martin Ritter <***@lmu.de>
Sent: Wednesday, October 24, 2018 10:01 AM
To: SCons users mailing list; Gary Oberbrunner
Subject: Re: [Scons-users] Question about splitting debug information

Hi Gary,

thank you, I overlooked AddPostAction. I now have something which does
what I want but I'm looking forward to compare that with Andrews
implementation.

Best Regards,

Martin

On 24/10/2018 15:18, Gary Oberbrunner wrote:
> The standard approach for this is to use AddPostAction to do your
> post-build steps, rather than a separate builder. Those operate on the
> target before its signature is stored.
>
> -- Gary
>
> On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de
> <mailto:***@lmu.de>> wrote:
>
> Hi,
>
> I have a question regarding splitting debug information from binaries
> and libraries with SCons: What we want to do is to split the debug
> information from libraries and executables and put them into separate
> files following
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceware.org%2Fgdb%2Fonlinedocs%2Fgdb%2FSeparate-Debug-Files.html&amp;data=02%7C01%7C%7Cb32b75c36e694acc62d108d639c19ecb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636759901081619364&amp;sdata=S87AVOFBXz6jVOu4eEz%2FG6O%2FGD6AUAhnz1cN2%2BLO6sk%3D&amp;reserved=0
>
> So we wrote a simple builder which does just that:
>
> strip_debug = Builder(
> action='objcopy --only-keep-debug $SOURCE $TARGET && '
> 'strip --strip-debug --strip-unneeded $SOURCE && '
> 'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
> suffix='.debug', prefix=".debug/")
>
> but obviously this modifies the original $SOURCE. So when running scons
> again it will notice that the libraries are not up to date and
> relink them.
>
> One solution is to first link the library into the build directory and
> then copy and strip the files to their final destination. But I was
> wondering if there is a way to do this without a temporary copy of the
> binaries (which is quite some disk space in our project)
>
> Best Regards,
>
> Martin
>
>
> --
> Dr. Martin Ritter
>
> LMU München, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org <mailto:Scons-***@scons.org>
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&amp;data=02%7C01%7C%7Cb32b75c36e694acc62d108d639c19ecb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636759901081619364&amp;sdata=ZgLW8a4J843FLEpxH%2FUThvo88OMykOjAgY%2F6BiFCjK0%3D&amp;reserved=0
>
>
>
> --
> Gary
>
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&amp;data=02%7C01%7C%7Cb32b75c36e694acc62d108d639c19ecb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636759901081619364&amp;sdata=ZgLW8a4J843FLEpxH%2FUThvo88OMykOjAgY%2F6BiFCjK0%3D&amp;reserved=0
>

--
Dr. Martin Ritter

LMU München, Excellence Cluster Universe
Boltzmannstrasse 2, 85748 Garching

Tel: (+49) 89 35831-7152
Fax: (+49) 89 3299-4002
Mats Wichmann
2018-10-24 16:47:29 UTC
Permalink
On 10/24/2018 09:32 AM, Jason Kenny wrote:
> Just a question... would this be useful to have in SCons? The Parts extension I work on for SCons did this via adding it to the env["PDB"] = "lib.debug". This required tweaking the actions for the linker tool on posix systems. I find it very useful for similar reasons.

The rpm packaging code might be able to do this during the step of
building the package. I had to do some fiddling to turn off the default
behavior of trying to split out debug support on recent Fedoras because
it was breaking tests, but it's just a flag to turn it back on.

Anyway I'll keep an eye on what you guys are doing in case the packaging
bits need another kick.
Jason Kenny
2018-10-24 17:17:01 UTC
Permalink
Just a note on my personal experience with RPMs. ( might be useful or might not..)
In Parts I making a new drop with a number of fixes to the RPM builders it provides. The rpmbuild program on fedora and rhel/centos will make a .debug package for you unless you turn it off. I found that it does not like the build to a preemptive split of debug info. So for me, I turn off this feature when making RPMs. The other quirk I have seen with centos\rhel systems is when using devtools7 for the compiler. The binaries rpm split debug info feature seems to break with some binary difference with gcc 7 vs older versions of gcc. At least for Parts I have not done the clean up needed to allow scons to understand that a debug package would be made as well and to make sure the binaries are in a good state for rpmbuild to split the debug info out. I currently just turning the feature off in the spec file to get around this issue.
Jason
________________________________
From: Scons-users <scons-users-***@scons.org> on behalf of Mats Wichmann <***@wichmann.us>
Sent: Wednesday, October 24, 2018 11:47 AM
To: scons-***@scons.org
Subject: Re: [Scons-users] Question about splitting debug information

On 10/24/2018 09:32 AM, Jason Kenny wrote:
> Just a question... would this be useful to have in SCons? The Parts extension I work on for SCons did this via adding it to the env["PDB"] = "lib.debug". This required tweaking the actions for the linker tool on posix systems. I find it very useful for similar reasons.

The rpm packaging code might be able to do this during the step of
building the package. I had to do some fiddling to turn off the default
behavior of trying to split out debug support on recent Fedoras because
it was breaking tests, but it's just a flag to turn it back on.

Anyway I'll keep an eye on what you guys are doing in case the packaging
bits need another kick.
Andrew C. Morrow
2018-10-25 18:55:51 UTC
Permalink
Here is my current state for this. Hasn't yet gone through code review so
may change. I've also pulled out some unnecessary pieces that relate to
some other future projects, so it is possible I've slightly broken it in
the editing of this email:

# Copyright 2018 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import SCons

def _update_builder(env, builder, bitcode):

base_action = builder.action
if not isinstance(base_action, SCons.Action.ListAction):
base_action = SCons.Action.ListAction([base_action])

# TODO: Make variables for dsymutil and strip, and for the action
strings
if env.TargetOSIs('darwin'):
base_action.list.append(
SCons.Action.Action(
"dsymutil $TARGET -o ${TARGET}.dSYM",
"Generating debug info for $TARGET into ${TARGET}.dSYM"
)
)
base_action.list.append(
SCons.Action.Action(
"strip -S ${TARGET}",
"Stripping ${TARGET}"
)
)
elif env.TargetOSIs('posix'):
base_action.list.extend([
SCons.Action.Action(
"${OBJCOPY} --only-keep-debug $TARGET ${TARGET}.debug",
"Generating debug info for $TARGET into ${TARGET}.debug"
),
SCons.Action.Action(
"${OBJCOPY} --strip-debug --add-gnu-debuglink
${TARGET}.debug ${TARGET}",
"Stripping debug info from ${TARGET} and adding
.gnu.debuglink to ${TARGET}.debug"
),
])
else:
pass

base_emitter = builder.emitter
def new_emitter(target, source, env):

if env.TargetOSIs('darwin'):
debug_file = env.Dir(str(target[0]) + ".dSYM")
elif env.TargetOSIs('posix'):
debug_file = env.File(str(target[0]) + ".debug")
else:
pass

target.append(debug_file)

return (target, source)

new_emitter = SCons.Builder.ListEmitter([base_emitter, new_emitter])
builder.emitter = new_emitter

def generate(env):
if not exists(env):
return

for builder in ['Program', 'SharedLibrary', 'LoadableModule']:
_update_builder(env, env['BUILDERS'][builder])

def exists(env):
return True

The general idea is to update the relevant builders with emitters that
describe the separate debug files, and additional actions that produce
them. By doing it this way, the debug files can move into and be retrieved
from the cache.

There are some TODOs here. Among the parts that I stripped out as not ready
to show is an improvement that automatically makes it so that if dynamic
library A depends on dynamic library B, then the installation (not shown
here) of the debug information for A depends on the the installation of the
debug info for library B (as does the installation of A depend on the
installation of B).

Suggestions welcome. The more complete version of this code is likely to
land on MongoDB master tomorrow or early next week.

Thanks,
Andrew


On Wed, Oct 24, 2018 at 11:01 AM Martin Ritter <***@lmu.de> wrote:

> Hi Gary,
>
> thank you, I overlooked AddPostAction. I now have something which does
> what I want but I'm looking forward to compare that with Andrews
> implementation.
>
> Best Regards,
>
> Martin
>
> On 24/10/2018 15:18, Gary Oberbrunner wrote:
> > The standard approach for this is to use AddPostAction to do your
> > post-build steps, rather than a separate builder. Those operate on the
> > target before its signature is stored.
> >
> > -- Gary
> >
> > On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de
> > <mailto:***@lmu.de>> wrote:
> >
> > Hi,
> >
> > I have a question regarding splitting debug information from binaries
> > and libraries with SCons: What we want to do is to split the debug
> > information from libraries and executables and put them into separate
> > files following
> > https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
> >
> > So we wrote a simple builder which does just that:
> >
> > strip_debug = Builder(
> > action='objcopy --only-keep-debug $SOURCE $TARGET && '
> > 'strip --strip-debug --strip-unneeded $SOURCE && '
> > 'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
> > suffix='.debug', prefix=".debug/")
> >
> > but obviously this modifies the original $SOURCE. So when running
> scons
> > again it will notice that the libraries are not up to date and
> > relink them.
> >
> > One solution is to first link the library into the build directory
> and
> > then copy and strip the files to their final destination. But I was
> > wondering if there is a way to do this without a temporary copy of
> the
> > binaries (which is quite some disk space in our project)
> >
> > Best Regards,
> >
> > Martin
> >
> >
> > --
> > Dr. Martin Ritter
> >
> > LMU MÃŒnchen, Excellence Cluster Universe
> > Boltzmannstrasse 2, 85748 Garching
> >
> > Tel: (+49) 89 35831-7152
> > Fax: (+49) 89 3299-4002
> >
> > _______________________________________________
> > Scons-users mailing list
> > Scons-***@scons.org <mailto:Scons-***@scons.org>
> > https://pairlist4.pair.net/mailman/listinfo/scons-users
> >
> >
> >
> > --
> > Gary
> >
> > _______________________________________________
> > Scons-users mailing list
> > Scons-***@scons.org
> > https://pairlist4.pair.net/mailman/listinfo/scons-users
> >
>
> --
> Dr. Martin Ritter
>
> LMU MÃŒnchen, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
Jason Kenny
2018-10-25 20:31:12 UTC
Permalink
This post might be inappropriate. Click to display it.
Andrew C. Morrow
2018-10-25 20:47:24 UTC
Permalink
In the broader build system where I'm using this, we wil indeed have a top
level command line Option called --enable-split-debug, which defaults to
false, and this tool is only loaded if it is set. So it is opt-in. For most
developers doing a compile/test/debug/edit loop, separate debug information
isn't useful, necessary, or worth the additional time. But great for
releases!

On Thu, Oct 25, 2018 at 4:31 PM Jason Kenny <***@live.com> wrote:

> The only suggestion I would have is that you might want a variable to
> control the separation should happen or not.
> The base of the imple used in Parts is here https://tinyurl.com/y7dnvx5c
> as an example
>
> it provided the ability to not make the debug information via an variable
> that can be set in the environment or the command line ( ie IGNORE_PDB =
> True | False)
>
> The form used in Parts extends the env["PDB"]="debug file" used with the
> windows compilers. The one tweak I would make in the Parts version would be
> to tweak the logic to auto add extension such as .pdb or .debug, etc (
> which you do nicely in your version)
>
> Jason
> ------------------------------
> *From:* Scons-users <scons-users-***@scons.org> on behalf of Andrew
> C. Morrow <***@gmail.com>
> *Sent:* Thursday, October 25, 2018 1:55 PM
> *To:* SCons users mailing list
> *Subject:* Re: [Scons-users] Question about splitting debug information
>
>
> Here is my current state for this. Hasn't yet gone through code review so
> may change. I've also pulled out some unnecessary pieces that relate to
> some other future projects, so it is possible I've slightly broken it in
> the editing of this email:
>
> # Copyright 2018 MongoDB Inc.
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> # You may obtain a copy of the License at
> #
> # http://www.apache.org/licenses/LICENSE-2.0
> <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7C%7Cffd583f52a654331732a08d63aab87fc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636760905722827894&sdata=4dYg4%2FTcUbUg%2BTR8iq0oi%2ByaZJ1QU22VLWc9sk2M9TI%3D&reserved=0>
> #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS,
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> # See the License for the specific language governing permissions and
> # limitations under the License.
>
> import SCons
>
> def _update_builder(env, builder, bitcode):
>
> base_action = builder.action
> if not isinstance(base_action, SCons.Action.ListAction):
> base_action = SCons.Action.ListAction([base_action])
>
> # TODO: Make variables for dsymutil and strip, and for the action
> strings
> if env.TargetOSIs('darwin'):
> base_action.list.append(
> SCons.Action.Action(
> "dsymutil $TARGET -o ${TARGET}.dSYM",
> "Generating debug info for $TARGET into ${TARGET}.dSYM"
> )
> )
> base_action.list.append(
> SCons.Action.Action(
> "strip -S ${TARGET}",
> "Stripping ${TARGET}"
> )
> )
> elif env.TargetOSIs('posix'):
> base_action.list.extend([
> SCons.Action.Action(
> "${OBJCOPY} --only-keep-debug $TARGET ${TARGET}.debug",
> "Generating debug info for $TARGET into ${TARGET}.debug"
> ),
> SCons.Action.Action(
> "${OBJCOPY} --strip-debug --add-gnu-debuglink
> ${TARGET}.debug ${TARGET}",
> "Stripping debug info from ${TARGET} and adding
> .gnu.debuglink to ${TARGET}.debug"
> ),
> ])
> else:
> pass
>
> base_emitter = builder.emitter
> def new_emitter(target, source, env):
>
> if env.TargetOSIs('darwin'):
> debug_file = env.Dir(str(target[0]) + ".dSYM")
> elif env.TargetOSIs('posix'):
> debug_file = env.File(str(target[0]) + ".debug")
> else:
> pass
>
> target.append(debug_file)
>
> return (target, source)
>
> new_emitter = SCons.Builder.ListEmitter([base_emitter, new_emitter])
> builder.emitter = new_emitter
>
> def generate(env):
> if not exists(env):
> return
>
> for builder in ['Program', 'SharedLibrary', 'LoadableModule']:
> _update_builder(env, env['BUILDERS'][builder])
>
> def exists(env):
> return True
>
> The general idea is to update the relevant builders with emitters that
> describe the separate debug files, and additional actions that produce
> them. By doing it this way, the debug files can move into and be retrieved
> from the cache.
>
> There are some TODOs here. Among the parts that I stripped out as not
> ready to show is an improvement that automatically makes it so that if
> dynamic library A depends on dynamic library B, then the installation (not
> shown here) of the debug information for A depends on the the installation
> of the debug info for library B (as does the installation of A depend on
> the installation of B).
>
> Suggestions welcome. The more complete version of this code is likely to
> land on MongoDB master tomorrow or early next week.
>
> Thanks,
> Andrew
>
>
> On Wed, Oct 24, 2018 at 11:01 AM Martin Ritter <***@lmu.de>
> wrote:
>
> Hi Gary,
>
> thank you, I overlooked AddPostAction. I now have something which does
> what I want but I'm looking forward to compare that with Andrews
> implementation.
>
> Best Regards,
>
> Martin
>
> On 24/10/2018 15:18, Gary Oberbrunner wrote:
> > The standard approach for this is to use AddPostAction to do your
> > post-build steps, rather than a separate builder. Those operate on the
> > target before its signature is stored.
> >
> > -- Gary
> >
> > On Wed, Oct 24, 2018 at 4:48 AM Martin Ritter <***@lmu.de
> > <mailto:***@lmu.de>> wrote:
> >
> > Hi,
> >
> > I have a question regarding splitting debug information from binaries
> > and libraries with SCons: What we want to do is to split the debug
> > information from libraries and executables and put them into separate
> > files following
> > https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceware.org%2Fgdb%2Fonlinedocs%2Fgdb%2FSeparate-Debug-Files.html&data=02%7C01%7C%7Cffd583f52a654331732a08d63aab87fc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636760905722827894&sdata=8gt5UHMPO%2BkiRHZQnKt8KXPgWw5wSgF18mVSYwMPpHo%3D&reserved=0>
> >
> > So we wrote a simple builder which does just that:
> >
> > strip_debug = Builder(
> > action='objcopy --only-keep-debug $SOURCE $TARGET && '
> > 'strip --strip-debug --strip-unneeded $SOURCE && '
> > 'objcopy --add-gnu-debuglink=$TARGET $SOURCE',
> > suffix='.debug', prefix=".debug/")
> >
> > but obviously this modifies the original $SOURCE. So when running
> scons
> > again it will notice that the libraries are not up to date and
> > relink them.
> >
> > One solution is to first link the library into the build directory
> and
> > then copy and strip the files to their final destination. But I was
> > wondering if there is a way to do this without a temporary copy of
> the
> > binaries (which is quite some disk space in our project)
> >
> > Best Regards,
> >
> > Martin
> >
> >
> > --
> > Dr. Martin Ritter
> >
> > LMU MÃŒnchen, Excellence Cluster Universe
> > Boltzmannstrasse 2, 85748 Garching
> >
> > Tel: (+49) 89 35831-7152
> > Fax: (+49) 89 3299-4002
> >
> > _______________________________________________
> > Scons-users mailing list
> > Scons-***@scons.org <mailto:Scons-***@scons.org>
> > https://pairlist4.pair.net/mailman/listinfo/scons-users
> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7Cffd583f52a654331732a08d63aab87fc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636760905722984404&sdata=XTLh0arwb6AqwkxRduVT3TP01EPQiu5jJMPAcvLbA%2Bw%3D&reserved=0>
> >
> >
> >
> > --
> > Gary
> >
> > _______________________________________________
> > Scons-users mailing list
> > Scons-***@scons.org
> > https://pairlist4.pair.net/mailman/listinfo/scons-users
> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7Cffd583f52a654331732a08d63aab87fc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636760905722984404&sdata=XTLh0arwb6AqwkxRduVT3TP01EPQiu5jJMPAcvLbA%2Bw%3D&reserved=0>
> >
>
> --
> Dr. Martin Ritter
>
> LMU MÃŒnchen, Excellence Cluster Universe
> Boltzmannstrasse 2, 85748 Garching
>
> Tel: (+49) 89 35831-7152
> Fax: (+49) 89 3299-4002
> _______________________________________________
> Scons-users mailing list
> Scons-***@scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7Cffd583f52a654331732a08d63aab87fc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636760905722984404&sdata=XTLh0arwb6AqwkxRduVT3TP01EPQiu5jJMPAcvLbA%2Bw%3D&reserved=0>
>
>
Jason Kenny
2018-10-25 20:59:50 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...