[GOLD] Take into account --enable-compressed-debug-sections

Message ID alpine.LNX.2.10.1905082258530.25659@ncegcolnx273.nce.amadeus.net
State New
Headers show
Series
  • [GOLD] Take into account --enable-compressed-debug-sections
Related show

Commit Message

Romain Geissler May 8, 2019, 9:01 p.m.
Hi,

It looks like the configure flag --enable-compressed-debug-sections is ignored by gold. This implements the necessary bits to take it into account.

Cheers,
Romain


2019-05-08  Romain Geissler  <romain.geissler@amadeus.com>

	* configure.ac (DEFAULT_FLAG_COMPRESS_DEBUG): Define if
	--enable-compressed-debug-sections={all,gold}.
	* options.h (compress_debug_sections): Check if DEFAULT_FLAG_COMPRESS_DEBUG
	is defined.
	* configure: Regenerate.
	* config.in: Regenerate.



From f2e7335eed550d87c969f4dbedafd8aeb7363484 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@amadeus.com>

Date: Wed, 8 May 2019 17:55:46 +0000
Subject: [PATCH] Enable default compression in gold.

---
 gold/config.in    |  3 +++
 gold/configure    | 21 +++++++++++++++++++++
 gold/configure.ac | 16 ++++++++++++++++
 gold/options.h    |  7 ++++++-
 4 files changed, 46 insertions(+), 1 deletion(-)

-- 
2.17.1

Patch

diff --git a/gold/config.in b/gold/config.in
index 7bac34aab25..a3f562adbbd 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@ 
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD

+/* Define if you want compressed debug sections by default. */
+#undef DEFAULT_FLAG_COMPRESS_DEBUG
+
 /* Set the default --hash-style value */
 #undef DEFAULT_HASH_STYLE

diff --git a/gold/configure b/gold/configure
index 474c69a1258..76dfe0ebd14 100755
--- a/gold/configure
+++ b/gold/configure
@@ -847,6 +847,7 @@  with_gold_ldflags
 with_gold_ldadd
 with_system_zlib
 enable_threads
+enable_compressed_debug_sections
 enable_maintainer_mode
 '
       ac_precious_vars='build_alias
@@ -1499,6 +1500,8 @@  Optional Features:
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
   --enable-threads[=ARG]  multi-threaded linking [ARG={auto,yes,no}]
+  --enable-compressed-debug-sections={all,gold,none}
+                          compress debug sections by default]
   --enable-maintainer-mode
                           enable make rules and dependencies not useful (and
                           sometimes confusing) to the casual installer
@@ -9470,6 +9473,24 @@  else
 fi


+# PR gas/19109
+# Decide the default method for compressing debug sections.
+ac_default_compressed_debug_sections=unset
+# Provide a configure time option to override our default.
+# Check whether --enable-compressed_debug_sections was given.
+if test "${enable_compressed_debug_sections+set}" = set; then :
+  enableval=$enable_compressed_debug_sections; case ,"${enableval}", in
+  ,yes, | ,all, | *,gold,*) ac_default_compressed_debug_sections=yes ;;
+  ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
+esac
+fi
+
+if test x$ac_default_compressed_debug_sections = xyes ; then
+
+$as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h
+
+fi
+
 ac_fn_c_check_decl "$LINENO" "basename" "ac_cv_have_decl_basename" "$ac_includes_default"
 if test "x$ac_cv_have_decl_basename" = xyes; then :
   ac_have_decl=1
diff --git a/gold/configure.ac b/gold/configure.ac
index 76db2b7586b..465130ab901 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -570,6 +570,22 @@  if test "$threads" = "yes"; then
 fi
 AM_CONDITIONAL(THREADS, test "$threads" = "yes")

+# PR gas/19109
+# Decide the default method for compressing debug sections.
+ac_default_compressed_debug_sections=unset
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE(compressed_debug_sections,
+	      AS_HELP_STRING([--enable-compressed-debug-sections={all,gold,none}],
+	      [compress debug sections by default])],
+[case ,"${enableval}", in
+  ,yes, | ,all, | *,gold,*) ac_default_compressed_debug_sections=yes ;;
+  ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
+esac])dnl
+
+if test x$ac_default_compressed_debug_sections = xyes ; then
+  AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
+fi
+
 dnl We have to check these in C, not C++, because autoconf generates
 dnl tests which have no type information, and current glibc provides
 dnl multiple declarations of functions like basename when compiling
diff --git a/gold/options.h b/gold/options.h
index 5ca89bd1d02..e73471c7dca 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -759,7 +759,12 @@  class General_options
 	      N_("Check segment addresses for overlaps"),
 	      N_("Do not check segment addresses for overlaps"));

-  DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0', "none",
+  DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0',
+#ifdef DEFAULT_FLAG_COMPRESS_DEBUG
+	      "zlib",
+#else
+	      "none",
+#endif
 	      N_("Compress .debug_* sections in the output file"),
 	      ("[none,zlib,zlib-gnu,zlib-gabi]"),
 	      {"none", "zlib", "zlib-gnu", "zlib-gabi"});