From 0138187e9fc351c6d4615bbe2ab020a3ac646b50 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 31 Mar 2015 03:55:56 -0700 Subject: [PATCH] Add --with-system-zlib in gas This patch adds --with-system-zlib and remove --with-zlib in gas. gas/ * Makefile.am (ZLIBINC): New. (AM_CFLAGS): Add $(ZLIBINC). * as.c: (show_usage): Don't check HAVE_ZLIB_H. (parse_args): Likewise. * compress-debug.c: Don't check HAVE_ZLIB_H to include . (compress_init): Don't check HAVE_ZLIB_H. (compress_data): Likewise. (compress_finish): Likewise. * configure.ac (AM_ZLIB): Removed. (zlibinc): New. AC_SUBST. Add --with-system-zlib. * Makefile.in: Regenerated. * config.in: Likewise. * configure: Likewise. * doc/Makefile.in: Likewise. gas/testsuite/ * gas/i386/dw2-compress-1.d: Expect .zdebug_info. --- gas/ChangeLog | 18 +++++++ gas/Makefile.am | 7 ++- gas/Makefile.in | 9 +++- gas/as.c | 6 --- gas/compress-debug.c | 30 ++--------- gas/config.in | 3 -- gas/configure | 94 ++++----------------------------- gas/configure.ac | 9 +++- gas/doc/Makefile.in | 2 +- gas/testsuite/ChangeLog | 4 ++ gas/testsuite/gas/i386/dw2-compress-1.d | 2 +- 11 files changed, 59 insertions(+), 125 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index e4623e6..4c2a20d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,21 @@ +2015-03-31 H.J. Lu + + * Makefile.am (ZLIBINC): New. + (AM_CFLAGS): Add $(ZLIBINC). + * as.c: (show_usage): Don't check HAVE_ZLIB_H. + (parse_args): Likewise. + * compress-debug.c: Don't check HAVE_ZLIB_H to include . + (compress_init): Don't check HAVE_ZLIB_H. + (compress_data): Likewise. + (compress_finish): Likewise. + * configure.ac (AM_ZLIB): Removed. + (zlibinc): New. AC_SUBST. + Add --with-system-zlib. + * Makefile.in: Regenerated. + * config.in: Likewise. + * configure: Likewise. + * doc/Makefile.in: Likewise. + 2015-03-27 H.J. Lu * config/tc-i386.c (cpu_flags_set): Removed. diff --git a/gas/Makefile.am b/gas/Makefile.am index a822be7..5161b5e 100644 --- a/gas/Makefile.am +++ b/gas/Makefile.am @@ -24,6 +24,11 @@ SUBDIRS = doc po tooldir = $(exec_prefix)/$(target_alias) +# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is +# -I../zlib, unless we were configured with --with-system-zlib, in which +# case both are empty. +ZLIBINC = @zlibinc@ + YACC = `if [ -f ../bison/bison ] ; then echo ../bison/bison -y -L../bison/bison ; else echo @YACC@ ; fi` LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo @LEX@ ; fi` @@ -34,7 +39,7 @@ am__skipyacc = WARN_CFLAGS = @WARN_CFLAGS@ NO_WERROR = @NO_WERROR@ -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC) TARG_CPU = @target_cpu_type@ TARG_CPU_C = $(srcdir)/config/tc-@target_cpu_type@.c diff --git a/gas/Makefile.in b/gas/Makefile.in index edd3638..240d7d9 100644 --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -66,7 +66,6 @@ DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \ $(srcdir)/../ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ - $(top_srcdir)/../config/zlib.m4 \ $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/gettext-sister.m4 \ @@ -298,16 +297,22 @@ te_file = @te_file@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +zlibinc = @zlibinc@ AUTOMAKE_OPTIONS = 1.11 dejagnu foreign no-dist ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd SUBDIRS = doc po tooldir = $(exec_prefix)/$(target_alias) +# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is +# -I../zlib, unless we were configured with --with-system-zlib, in which +# case both are empty. +ZLIBINC = @zlibinc@ + # Automake 1.10+ disables lex and yacc output file regeneration if # maintainer mode is disabled. Avoid this. am__skiplex = am__skipyacc = -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC) TARG_CPU = @target_cpu_type@ TARG_CPU_C = $(srcdir)/config/tc-@target_cpu_type@.c TARG_CPU_O = tc-@target_cpu_type@.@OBJEXT@ diff --git a/gas/as.c b/gas/as.c index 503add9..a670d3e 100644 --- a/gas/as.c +++ b/gas/as.c @@ -245,14 +245,12 @@ Options:\n\ fprintf (stream, _("\ --alternate initially turn on alternate macro syntax\n")); -#ifdef HAVE_ZLIB_H fprintf (stream, _("\ --compress-debug-sections\n\ compress DWARF debug sections using zlib\n")); fprintf (stream, _("\ --nocompress-debug-sections\n\ don't compress DWARF debug sections\n")); -#endif /* HAVE_ZLIB_H */ fprintf (stream, _("\ -D produce assembler debugging messages\n")); fprintf (stream, _("\ @@ -657,11 +655,7 @@ This program has absolutely no warranty.\n")); exit (EXIT_SUCCESS); case OPTION_COMPRESS_DEBUG: -#ifdef HAVE_ZLIB_H flag_compress_debug = 1; -#else - as_warn (_("cannot compress debug sections (zlib not installed)")); -#endif /* HAVE_ZLIB_H */ break; case OPTION_NOCOMPRESS_DEBUG: diff --git a/gas/compress-debug.c b/gas/compress-debug.c index b036610..8749399 100644 --- a/gas/compress-debug.c +++ b/gas/compress-debug.c @@ -20,21 +20,15 @@ #include "config.h" #include +#include #include "ansidecl.h" #include "compress-debug.h" -#ifdef HAVE_ZLIB_H -#include -#endif - /* Initialize the compression engine. */ struct z_stream_s * compress_init (void) { -#ifndef HAVE_ZLIB_H - return NULL; -#else static struct z_stream_s strm; strm.zalloc = NULL; @@ -42,22 +36,15 @@ compress_init (void) strm.opaque = NULL; deflateInit (&strm, Z_DEFAULT_COMPRESSION); return &strm; -#endif /* HAVE_ZLIB_H */ } /* Stream the contents of a frag to the compression engine. Output from the engine goes into the current frag on the obstack. */ int -compress_data (struct z_stream_s *strm ATTRIBUTE_UNUSED, - const char **next_in ATTRIBUTE_UNUSED, - int *avail_in ATTRIBUTE_UNUSED, - char **next_out ATTRIBUTE_UNUSED, - int *avail_out ATTRIBUTE_UNUSED) +compress_data (struct z_stream_s *strm, const char **next_in, + int *avail_in, char **next_out, int *avail_out) { -#ifndef HAVE_ZLIB_H - return -1; -#else int out_size = 0; int x; @@ -77,7 +64,6 @@ compress_data (struct z_stream_s *strm ATTRIBUTE_UNUSED, *avail_out = strm->avail_out; return out_size; -#endif /* HAVE_ZLIB_H */ } /* Finish the compression and consume the remaining compressed output. @@ -85,14 +71,9 @@ compress_data (struct z_stream_s *strm ATTRIBUTE_UNUSED, needed. */ int -compress_finish (struct z_stream_s *strm ATTRIBUTE_UNUSED, - char **next_out ATTRIBUTE_UNUSED, - int *avail_out ATTRIBUTE_UNUSED, - int *out_size ATTRIBUTE_UNUSED) +compress_finish (struct z_stream_s *strm, char **next_out, + int *avail_out, int *out_size) { -#ifndef HAVE_ZLIB_H - return -1; -#else int x; strm->avail_in = 0; @@ -113,5 +94,4 @@ compress_finish (struct z_stream_s *strm ATTRIBUTE_UNUSED, if (strm->avail_out != 0) return -1; return 1; -#endif /* HAVE_ZLIB_H */ } diff --git a/gas/config.in b/gas/config.in index fef16ee..a2d62f4 100644 --- a/gas/config.in +++ b/gas/config.in @@ -157,9 +157,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H -/* Define to 1 if you have the header file. */ -#undef HAVE_ZLIB_H - /* Using i386 COFF? */ #undef I386COFF diff --git a/gas/configure b/gas/configure index 75d8a52..07bcee0 100755 --- a/gas/configure +++ b/gas/configure @@ -602,6 +602,7 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +zlibinc LIBM ALLOCA GENINSRC_NEVER_FALSE @@ -766,7 +767,7 @@ enable_werror enable_build_warnings enable_nls enable_maintainer_mode -with_zlib +with_system_zlib ' ac_precious_vars='build_alias host_alias @@ -1422,7 +1423,7 @@ Optional Packages: --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-zlib include zlib support (auto/yes/no) default=auto + --with-system-zlib use installed libz Some influential environment variables: CC C compiler command @@ -10967,7 +10968,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10970 "configure" +#line 10971 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11073,7 +11074,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11076 "configure" +#line 11077 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14319,90 +14320,15 @@ $as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h ;; esac -# Link in zlib if we can. This allows us to write compressed debug sections. +# Use the system's zlib library. +zlibinc="-I\$(srcdir)/../zlib" - # See if the user specified whether he wants zlib support or not. +# Check whether --with-system-zlib was given. +if test "${with_system_zlib+set}" = set; then : + withval=$with_system_zlib; zlibinc= -# Check whether --with-zlib was given. -if test "${with_zlib+set}" = set; then : - withval=$with_zlib; -else - with_zlib=auto -fi - - - if test "$with_zlib" != "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5 -$as_echo_n "checking for library containing zlibVersion... " >&6; } -if test "${ac_cv_search_zlibVersion+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char zlibVersion (); -int -main () -{ -return zlibVersion (); - ; - return 0; -} -_ACEOF -for ac_lib in '' z; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_zlibVersion=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if test "${ac_cv_search_zlibVersion+set}" = set; then : - break fi -done -if test "${ac_cv_search_zlibVersion+set}" = set; then : -else - ac_cv_search_zlibVersion=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5 -$as_echo "$ac_cv_search_zlibVersion" >&6; } -ac_res=$ac_cv_search_zlibVersion -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - for ac_header in zlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_ZLIB_H 1 -_ACEOF - -fi - -done - -fi - - if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then - as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5 - fi - fi # Support for VMS timestamps via cross compile diff --git a/gas/configure.ac b/gas/configure.ac index 8e05fb8..fbe8c0b 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -816,8 +816,13 @@ AC_CHECK_DECLS([free, getenv, malloc, mempcpy, realloc, stpcpy, strstr, vsnprint BFD_BINARY_FOPEN -# Link in zlib if we can. This allows us to write compressed debug sections. -AM_ZLIB +# Use the system's zlib library. +zlibinc="-I\$(srcdir)/../zlib" +AC_ARG_WITH(system-zlib, +[AS_HELP_STRING([--with-system-zlib], [use installed libz])], +zlibinc= +) +AC_SUBST(zlibinc) # Support for VMS timestamps via cross compile diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in index 02841d9..49ddf94 100644 --- a/gas/doc/Makefile.in +++ b/gas/doc/Makefile.in @@ -57,7 +57,6 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(as_TEXINFOS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ - $(top_srcdir)/../config/zlib.m4 \ $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/gettext-sister.m4 \ @@ -267,6 +266,7 @@ te_file = @te_file@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +zlibinc = @zlibinc@ AUTOMAKE_OPTIONS = 1.8 cygnus # What version of the manual you want; "all" includes everything diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index e26755e..2e15eb4 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-03-31 H.J. Lu + + * gas/i386/dw2-compress-1.d: Expect .zdebug_info. + 2015-03-20 H.J. Lu * gas/i386/i386.exp: Don't run nops-1-bdver1, nops-1-bdver2, diff --git a/gas/testsuite/gas/i386/dw2-compress-1.d b/gas/testsuite/gas/i386/dw2-compress-1.d index da0c2b8..c29a26c 100644 --- a/gas/testsuite/gas/i386/dw2-compress-1.d +++ b/gas/testsuite/gas/i386/dw2-compress-1.d @@ -2,7 +2,7 @@ #readelf: -w #name: DWARF2 debugging information 1 -Contents of the .*debug_info section: +Contents of the .zdebug_info section: Compilation Unit @ offset 0x0: Length: 0x4e \(32-bit\) -- 2.7.4