diff --git a/doc/flatpak-manifest.xml b/doc/flatpak-manifest.xml index 58e9bd73..bbdfb18f 100644 --- a/doc/flatpak-manifest.xml +++ b/doc/flatpak-manifest.xml @@ -301,6 +301,10 @@ 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. + + (boolean) + By default when extracting debuginfo we compress the debug sections. If you want to disable this, set no-debuginfo-compression to true. + (object) This is a dictionary defining for each arch a separate build options object that override the main one. diff --git a/src/builder-module.c b/src/builder-module.c index f470f1e0..7c441502 100644 --- a/src/builder-module.c +++ b/src/builder-module.c @@ -1653,7 +1653,11 @@ builder_module_build_helper (BuilderModule *self, else if (!builder_options_get_no_debuginfo (self->build_options, context) && /* No support for debuginfo for extensions atm */ !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, cache, context, error)) diff --git a/src/builder-options.c b/src/builder-options.c index 5c43b499..ae31b5dc 100644 --- a/src/builder-options.c +++ b/src/builder-options.c @@ -38,6 +38,7 @@ struct BuilderOptions gboolean strip; gboolean no_debuginfo; + gboolean no_debuginfo_compression; char *cflags; char *cppflags; char *cxxflags; @@ -73,6 +74,7 @@ enum { PROP_ENV, PROP_STRIP, PROP_NO_DEBUGINFO, + PROP_NO_DEBUGINFO_COMPRESSION, PROP_ARCH, PROP_BUILD_ARGS, PROP_CONFIG_OPTS, @@ -176,6 +178,10 @@ builder_options_get_property (GObject *object, g_value_set_boolean (value, self->no_debuginfo); break; + case PROP_NO_DEBUGINFO_COMPRESSION: + g_value_set_boolean (value, self->no_debuginfo_compression); + break; + default: 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); break; + case PROP_NO_DEBUGINFO_COMPRESSION: + self->no_debuginfo_compression = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -390,6 +400,13 @@ builder_options_class_init (BuilderOptionsClass *klass) "", FALSE, 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 @@ -775,6 +792,22 @@ builder_options_get_no_debuginfo (BuilderOptions *self, BuilderContext *context) 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 ** 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_boolean (cache, self->strip); 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)); if (arch_options) diff --git a/src/builder-options.h b/src/builder-options.h index c1975cae..bc9b90bb 100644 --- a/src/builder-options.h +++ b/src/builder-options.h @@ -66,6 +66,8 @@ void builder_options_checksum (BuilderOptions *self, BuilderContext *context); gboolean builder_options_get_no_debuginfo (BuilderOptions *self, BuilderContext *context); +gboolean builder_options_get_no_debuginfo_compression (BuilderOptions *self, + BuilderContext *context); gboolean builder_options_get_strip (BuilderOptions *self, BuilderContext *context); diff --git a/src/builder-post-process.c b/src/builder-post-process.c index 744ff53d..8e36a201 100644 --- a/src/builder-post-process.c +++ b/src/builder-post-process.c @@ -301,7 +301,6 @@ builder_post_process_python_time_stamp (GFile *app_dir, return TRUE; } - static gboolean builder_post_process_strip (GFile *app_dir, GPtrArray *changed, @@ -341,6 +340,7 @@ builder_post_process_strip (GFile *app_dir, static gboolean builder_post_process_debuginfo (GFile *app_dir, GPtrArray *changed, + BuilderPostProcessFlags flags, BuilderContext *context, 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, which breaks rofiles-fuse. Unlink them */ if (!flatpak_break_hardlink (file, error)) 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", "-f", debug_path, "-F", real_debug_path, @@ -496,7 +511,7 @@ builder_post_process (BuilderPostProcessFlags flags, } 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; } diff --git a/src/builder-post-process.h b/src/builder-post-process.h index ddbf39c0..2977adbb 100644 --- a/src/builder-post-process.h +++ b/src/builder-post-process.h @@ -31,6 +31,7 @@ typedef enum { BUILDER_POST_PROCESS_FLAGS_PYTHON_TIMESTAMPS = 1<<0, BUILDER_POST_PROCESS_FLAGS_STRIP = 1<<1, BUILDER_POST_PROCESS_FLAGS_DEBUGINFO = 1<<2, + BUILDER_POST_PROCESS_FLAGS_DEBUGINFO_COMPRESSION = 1<<3, } BuilderPostProcessFlags; gboolean builder_post_process (BuilderPostProcessFlags flags, diff --git a/src/builder-utils.c b/src/builder-utils.c index 38f1a6a8..226002af 100644 --- a/src/builder-utils.c +++ b/src/builder-utils.c @@ -159,6 +159,21 @@ eu_strip (GError **error, 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 elf_has_symtab (Elf *elf) { diff --git a/src/builder-utils.h b/src/builder-utils.h index c3960f4d..407d92e5 100644 --- a/src/builder-utils.h +++ b/src/builder-utils.h @@ -37,6 +37,8 @@ gboolean strip (GError **error, ...); gboolean eu_strip (GError **error, ...); +gboolean eu_elfcompress (GError **error, + ...); gboolean is_elf_file (const char *path, gboolean *is_shared,