From: Neil Horman Date: Tue, 13 Aug 2024 19:16:08 +0000 (-0400) Subject: Add debuginfo build target X-Git-Tag: openssl-3.4.0-alpha1~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5d56626b97dd06d02d02821485df99e2068696d;p=thirdparty%2Fopenssl.git Add debuginfo build target In the webinar we are currently producing on debugging openssl applications, we talk about ways to allow debugable binaries without having to ship all the debug DWARF information to production systems. Add an optional target to do that DWARF separation to aid users Reviewed-by: Tom Cosgrove Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25174) --- diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf index d55ecea6dc4..86287c3a25a 100644 --- a/Configurations/00-base-templates.conf +++ b/Configurations/00-base-templates.conf @@ -78,6 +78,7 @@ my %targets=( AR => "ar", ARFLAGS => "qc", CC => "cc", + OBJCOPY => "objcopy", bin_cflags => sub { my @flags = (); diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 4c24cae7ab6..966d8fec898 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -373,6 +373,7 @@ CFLAGS={- join(' ', @{$config{CFLAGS}}) -} CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -} LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -} EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -} +OBJCOPY={- $config{OBJCOPY} -} MAKEDEPEND={- $config{makedepcmd} -} @@ -533,6 +534,11 @@ LANG=C {- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep all: build_sw {- "build_docs" if !$disabled{docs}; -} ## Build software and documentation +debuginfo: $(SHLIBS) + @set -e; for i in $(SHLIBS); do \ + $(OBJCOPY) --only-keep-debug $$i $$i.debug; \ + $(OBJCOPY) --strip-debug --add-gnu-debuglink=$$i.debug $$i; \ + done; ##@ Documentation build_generated_pods: $(GENERATED_PODS) diff --git a/Configure b/Configure index a6b66df4c4d..fff97bd6fc8 100755 --- a/Configure +++ b/Configure @@ -758,6 +758,7 @@ my %user = ( RANLIB => env('RANLIB'), RC => env('RC') || env('WINDRES'), RCFLAGS => [ env('RCFLAGS') || () ], + OBJCOPY => undef, RM => undef, ); # Info about what "make variables" may be prefixed with the cross compiler diff --git a/INSTALL.md b/INSTALL.md index c25bec82250..63ca4e37a5d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1676,6 +1676,12 @@ described here. Examine the Makefiles themselves for the full list. build_docs Build all documentation components. + debuginfo + On unix platforms, this target can be used to create .debug + libraries, which separate the DWARF information in the + shared library ELF files into a separate file for use + in post-mortem (core dump) debugging + clean Remove all build artefacts and return the directory to a "clean" state.