forked from Mirrors/flatpak-builder
Automatically compress debug info unless no-debuginfo-compression is set
This uses eu-elfcompress to compress the debuginfo. We use the older zlib-gnu compression format which is older and has more widespread support. Closes: #43 Approved by: alexlarssontingping/wmclass
parent
5818790510
commit
34710550ef
|
@ -301,6 +301,10 @@
|
||||||
<listitem><para>By default (if strip is not true) flatpak-builder extracts all debug info in ELF files to a separate files
|
<listitem><para>By default (if strip is not true) flatpak-builder extracts all debug info in ELF files to a separate files
|
||||||
and puts this in an extension. If you want to disable this, set no-debuginfo to true.</para></listitem>
|
and puts this in an extension. If you want to disable this, set no-debuginfo to true.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>no-debuginfo-compression</option> (boolean)</term>
|
||||||
|
<listitem><para>By default when extracting debuginfo we compress the debug sections. If you want to disable this, set no-debuginfo-compression to true.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>arch</option> (object)</term>
|
<term><option>arch</option> (object)</term>
|
||||||
<listitem><para>This is a dictionary defining for each arch a separate build options object that override the main one.</para></listitem>
|
<listitem><para>This is a dictionary defining for each arch a separate build options object that override the main one.</para></listitem>
|
||||||
|
|
|
@ -1653,7 +1653,11 @@ builder_module_build_helper (BuilderModule *self,
|
||||||
else if (!builder_options_get_no_debuginfo (self->build_options, context) &&
|
else if (!builder_options_get_no_debuginfo (self->build_options, context) &&
|
||||||
/* No support for debuginfo for extensions atm */
|
/* No support for debuginfo for extensions atm */
|
||||||
!builder_context_get_build_extension (context))
|
!builder_context_get_build_extension (context))
|
||||||
post_process_flags |= BUILDER_POST_PROCESS_FLAGS_DEBUGINFO;
|
{
|
||||||
|
post_process_flags |= BUILDER_POST_PROCESS_FLAGS_DEBUGINFO;
|
||||||
|
if (!builder_options_get_no_debuginfo_compression (self->build_options, context))
|
||||||
|
post_process_flags |= BUILDER_POST_PROCESS_FLAGS_DEBUGINFO_COMPRESSION;
|
||||||
|
}
|
||||||
|
|
||||||
if (!builder_post_process (post_process_flags, app_dir,
|
if (!builder_post_process (post_process_flags, app_dir,
|
||||||
cache, context, error))
|
cache, context, error))
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct BuilderOptions
|
||||||
|
|
||||||
gboolean strip;
|
gboolean strip;
|
||||||
gboolean no_debuginfo;
|
gboolean no_debuginfo;
|
||||||
|
gboolean no_debuginfo_compression;
|
||||||
char *cflags;
|
char *cflags;
|
||||||
char *cppflags;
|
char *cppflags;
|
||||||
char *cxxflags;
|
char *cxxflags;
|
||||||
|
@ -73,6 +74,7 @@ enum {
|
||||||
PROP_ENV,
|
PROP_ENV,
|
||||||
PROP_STRIP,
|
PROP_STRIP,
|
||||||
PROP_NO_DEBUGINFO,
|
PROP_NO_DEBUGINFO,
|
||||||
|
PROP_NO_DEBUGINFO_COMPRESSION,
|
||||||
PROP_ARCH,
|
PROP_ARCH,
|
||||||
PROP_BUILD_ARGS,
|
PROP_BUILD_ARGS,
|
||||||
PROP_CONFIG_OPTS,
|
PROP_CONFIG_OPTS,
|
||||||
|
@ -176,6 +178,10 @@ builder_options_get_property (GObject *object,
|
||||||
g_value_set_boolean (value, self->no_debuginfo);
|
g_value_set_boolean (value, self->no_debuginfo);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_NO_DEBUGINFO_COMPRESSION:
|
||||||
|
g_value_set_boolean (value, self->no_debuginfo_compression);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -271,6 +277,10 @@ builder_options_set_property (GObject *object,
|
||||||
self->no_debuginfo = g_value_get_boolean (value);
|
self->no_debuginfo = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_NO_DEBUGINFO_COMPRESSION:
|
||||||
|
self->no_debuginfo_compression = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -390,6 +400,13 @@ builder_options_class_init (BuilderOptionsClass *klass)
|
||||||
"",
|
"",
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_NO_DEBUGINFO_COMPRESSION,
|
||||||
|
g_param_spec_boolean ("no-debuginfo-compression",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -775,6 +792,22 @@ builder_options_get_no_debuginfo (BuilderOptions *self, BuilderContext *context)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
builder_options_get_no_debuginfo_compression (BuilderOptions *self, BuilderContext *context)
|
||||||
|
{
|
||||||
|
g_autoptr(GList) options = get_all_options (self, context);
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = options; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
BuilderOptions *o = l->data;
|
||||||
|
if (o->no_debuginfo_compression)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
char **
|
char **
|
||||||
builder_options_get_env (BuilderOptions *self, BuilderContext *context)
|
builder_options_get_env (BuilderOptions *self, BuilderContext *context)
|
||||||
{
|
{
|
||||||
|
@ -953,6 +986,7 @@ builder_options_checksum (BuilderOptions *self,
|
||||||
builder_cache_checksum_strv (cache, self->make_install_args);
|
builder_cache_checksum_strv (cache, self->make_install_args);
|
||||||
builder_cache_checksum_boolean (cache, self->strip);
|
builder_cache_checksum_boolean (cache, self->strip);
|
||||||
builder_cache_checksum_boolean (cache, self->no_debuginfo);
|
builder_cache_checksum_boolean (cache, self->no_debuginfo);
|
||||||
|
builder_cache_checksum_compat_boolean (cache, self->no_debuginfo_compression);
|
||||||
|
|
||||||
arch_options = g_hash_table_lookup (self->arch, builder_context_get_arch (context));
|
arch_options = g_hash_table_lookup (self->arch, builder_context_get_arch (context));
|
||||||
if (arch_options)
|
if (arch_options)
|
||||||
|
|
|
@ -66,6 +66,8 @@ void builder_options_checksum (BuilderOptions *self,
|
||||||
BuilderContext *context);
|
BuilderContext *context);
|
||||||
gboolean builder_options_get_no_debuginfo (BuilderOptions *self,
|
gboolean builder_options_get_no_debuginfo (BuilderOptions *self,
|
||||||
BuilderContext *context);
|
BuilderContext *context);
|
||||||
|
gboolean builder_options_get_no_debuginfo_compression (BuilderOptions *self,
|
||||||
|
BuilderContext *context);
|
||||||
gboolean builder_options_get_strip (BuilderOptions *self,
|
gboolean builder_options_get_strip (BuilderOptions *self,
|
||||||
BuilderContext *context);
|
BuilderContext *context);
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,6 @@ builder_post_process_python_time_stamp (GFile *app_dir,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
builder_post_process_strip (GFile *app_dir,
|
builder_post_process_strip (GFile *app_dir,
|
||||||
GPtrArray *changed,
|
GPtrArray *changed,
|
||||||
|
@ -341,6 +340,7 @@ builder_post_process_strip (GFile *app_dir,
|
||||||
static gboolean
|
static gboolean
|
||||||
builder_post_process_debuginfo (GFile *app_dir,
|
builder_post_process_debuginfo (GFile *app_dir,
|
||||||
GPtrArray *changed,
|
GPtrArray *changed,
|
||||||
|
BuilderPostProcessFlags flags,
|
||||||
BuilderContext *context,
|
BuilderContext *context,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
@ -453,13 +453,28 @@ builder_post_process_debuginfo (GFile *app_dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("stripping %s to %s\n", path, debug_path);
|
|
||||||
|
|
||||||
/* Some files are hardlinked and eu-strip modifies in-place,
|
/* Some files are hardlinked and eu-strip modifies in-place,
|
||||||
which breaks rofiles-fuse. Unlink them */
|
which breaks rofiles-fuse. Unlink them */
|
||||||
if (!flatpak_break_hardlink (file, error))
|
if (!flatpak_break_hardlink (file, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (flags & BUILDER_POST_PROCESS_FLAGS_DEBUGINFO_COMPRESSION)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) my_error = NULL;
|
||||||
|
g_print ("compressing debuginfo in: %s\n", path);
|
||||||
|
if (!eu_elfcompress (&my_error, "-t", "zlib-gnu", "-v", path, NULL))
|
||||||
|
{
|
||||||
|
if (g_error_matches (my_error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT))
|
||||||
|
g_print ("Warning: eu-elfcompress not installed, will not compress debuginfo\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_propagate_error (error, g_steal_pointer (&my_error));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("stripping %s to %s\n", path, debug_path);
|
||||||
if (!eu_strip (error, "--remove-comment", "--reloc-debug-sections",
|
if (!eu_strip (error, "--remove-comment", "--reloc-debug-sections",
|
||||||
"-f", debug_path,
|
"-f", debug_path,
|
||||||
"-F", real_debug_path,
|
"-F", real_debug_path,
|
||||||
|
@ -496,7 +511,7 @@ builder_post_process (BuilderPostProcessFlags flags,
|
||||||
}
|
}
|
||||||
else if (flags & BUILDER_POST_PROCESS_FLAGS_DEBUGINFO)
|
else if (flags & BUILDER_POST_PROCESS_FLAGS_DEBUGINFO)
|
||||||
{
|
{
|
||||||
if (!builder_post_process_debuginfo (app_dir, changed, context, error))
|
if (!builder_post_process_debuginfo (app_dir, changed, flags, context, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ typedef enum {
|
||||||
BUILDER_POST_PROCESS_FLAGS_PYTHON_TIMESTAMPS = 1<<0,
|
BUILDER_POST_PROCESS_FLAGS_PYTHON_TIMESTAMPS = 1<<0,
|
||||||
BUILDER_POST_PROCESS_FLAGS_STRIP = 1<<1,
|
BUILDER_POST_PROCESS_FLAGS_STRIP = 1<<1,
|
||||||
BUILDER_POST_PROCESS_FLAGS_DEBUGINFO = 1<<2,
|
BUILDER_POST_PROCESS_FLAGS_DEBUGINFO = 1<<2,
|
||||||
|
BUILDER_POST_PROCESS_FLAGS_DEBUGINFO_COMPRESSION = 1<<3,
|
||||||
} BuilderPostProcessFlags;
|
} BuilderPostProcessFlags;
|
||||||
|
|
||||||
gboolean builder_post_process (BuilderPostProcessFlags flags,
|
gboolean builder_post_process (BuilderPostProcessFlags flags,
|
||||||
|
|
|
@ -159,6 +159,21 @@ eu_strip (GError **error,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
eu_elfcompress (GError **error,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
gboolean res;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start (ap, error);
|
||||||
|
res = flatpak_spawn (NULL, NULL, error, "eu-elfcompress", ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
elf_has_symtab (Elf *elf)
|
elf_has_symtab (Elf *elf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,8 @@ gboolean strip (GError **error,
|
||||||
...);
|
...);
|
||||||
gboolean eu_strip (GError **error,
|
gboolean eu_strip (GError **error,
|
||||||
...);
|
...);
|
||||||
|
gboolean eu_elfcompress (GError **error,
|
||||||
|
...);
|
||||||
|
|
||||||
gboolean is_elf_file (const char *path,
|
gboolean is_elf_file (const char *path,
|
||||||
gboolean *is_shared,
|
gboolean *is_shared,
|
||||||
|
|
Loading…
Reference in New Issue