[1/8] Add --with-system-zlib in bfd

Message ID 20150326155711.GA10088@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu March 26, 2015, 3:57 p.m. UTC
  I imported zlib from GCC.  This patch adds --with-system-zlib and remove
--with-zlib in bfd.  OK for master?

Thanks.


H.J.
---
	* Makefile.am (ZLIB): New.
	(ZLIBINC): Likewise.
	(AM_CFLAGS): Add $(ZLIBINC).
	(libbfd_la_LIBADD): Add $(ZLIB).
	* compress.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	(decompress_contents): Don't check HAVE_ZLIB_H.
	(decompress_contents): Likewise.
	(bfd_compress_section_contents): Likewise.
	(bfd_get_full_section_contents): Likewise.
	(bfd_init_section_decompress_status): Likewise.
	(bfd_init_section_compress_status): Likewise.
	* configure.ac (AM_ZLIB): Removed
	(zlibdir): New.  AC_SUBST.
	(zlibinc): Likewise.
	Add --with-system-zlib.
	* Makefile.in: Regenerated.
	* acinclude.m4: Likewise.
	* config.in: Likewise.
	* configure: Likewise.
	* doc/Makefile.in: Likewise.
---
 bfd/Makefile.am     | 10 ++++--
 bfd/Makefile.in     | 16 ++++++---
 bfd/acinclude.m4    |  2 --
 bfd/compress.c      | 36 ++++----------------
 bfd/config.in       |  3 --
 bfd/configure       | 97 +++++++----------------------------------------------
 bfd/configure.ac    | 13 +++++--
 bfd/doc/Makefile.in |  6 ++--
 8 files changed, 53 insertions(+), 130 deletions(-)
  

Comments

H.J. Lu March 29, 2015, 2:10 p.m. UTC | #1
On Thu, Mar 26, 2015 at 8:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> I imported zlib from GCC.  This patch adds --with-system-zlib and remove
> --with-zlib in bfd.  OK for master?
>
> Thanks.
>
>
> H.J.
> ---
>         * Makefile.am (ZLIB): New.
>         (ZLIBINC): Likewise.
>         (AM_CFLAGS): Add $(ZLIBINC).
>         (libbfd_la_LIBADD): Add $(ZLIB).
>         * compress.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
>         (decompress_contents): Don't check HAVE_ZLIB_H.
>         (decompress_contents): Likewise.
>         (bfd_compress_section_contents): Likewise.
>         (bfd_get_full_section_contents): Likewise.
>         (bfd_init_section_decompress_status): Likewise.
>         (bfd_init_section_compress_status): Likewise.
>         * configure.ac (AM_ZLIB): Removed
>         (zlibdir): New.  AC_SUBST.
>         (zlibinc): Likewise.
>         Add --with-system-zlib.
>         * Makefile.in: Regenerated.
>         * acinclude.m4: Likewise.
>         * config.in: Likewise.
>         * configure: Likewise.
>         * doc/Makefile.in: Likewise.

I will check in this patch shortly.
  
Steve Ellcey March 30, 2015, 3:52 p.m. UTC | #2
On Sun, 2015-03-29 at 07:10 -0700, H.J. Lu wrote:
> On Thu, Mar 26, 2015 at 8:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > I imported zlib from GCC.  This patch adds --with-system-zlib and remove
> > --with-zlib in bfd.  OK for master?

I think the global binutils-gdb Makefile needs to have a dependency of
bfd on zlib.  If I build 'all-binutils' (using just the binutils-gdb
repository, not a combined tree with GCC) I get a build failure.  If I
explicitly build all-zlib before building all-binutils it works, but I
should not have to do that.


/bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/scratch/sellcey/repos/nightly/src/binutils-gdb/bfd/../zlib -g -O2 -rpath /scratch/sellcey/repos/nightly/install-mips-mti-linux-gnu/x86_64-unknown-linux-gnu/mips-mti-linux-gnu/lib -release `cat libtool-soversion`  -static-libstdc++ -static-libgcc  -o libbfd.la  archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo coff-bfd.lo compress.lo corefile.lo format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo `cat ofiles`  -ldl -L../zlib -lz -ldl
./libtool: line 5195: cd: ../zlib: No such file or directory
libtool: link: cannot determine absolute directory name of `../zlib'
make[3]: *** [libbfd.la] Error 1
make[3]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
make: *** [all-bfd] Error 2
Error: Make command failed, stopping build.


Steve Ellcey
sellcey@imgtec.com
  
H.J. Lu March 30, 2015, 4:31 p.m. UTC | #3
On Mon, Mar 30, 2015 at 8:52 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
> On Sun, 2015-03-29 at 07:10 -0700, H.J. Lu wrote:
>> On Thu, Mar 26, 2015 at 8:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> > I imported zlib from GCC.  This patch adds --with-system-zlib and remove
>> > --with-zlib in bfd.  OK for master?
>
> I think the global binutils-gdb Makefile needs to have a dependency of
> bfd on zlib.  If I build 'all-binutils' (using just the binutils-gdb
> repository, not a combined tree with GCC) I get a build failure.  If I
> explicitly build all-zlib before building all-binutils it works, but I
> should not have to do that.
>
>
> /bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/scratch/sellcey/repos/nightly/src/binutils-gdb/bfd/../zlib -g -O2 -rpath /scratch/sellcey/repos/nightly/install-mips-mti-linux-gnu/x86_64-unknown-linux-gnu/mips-mti-linux-gnu/lib -release `cat libtool-soversion`  -static-libstdc++ -static-libgcc  -o libbfd.la  archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo coff-bfd.lo compress.lo corefile.lo format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo `cat ofiles`  -ldl -L../zlib -lz -ldl
> ./libtool: line 5195: cd: ../zlib: No such file or directory
> libtool: link: cannot determine absolute directory name of `../zlib'
> make[3]: *** [libbfd.la] Error 1
> make[3]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
> make: *** [all-bfd] Error 2
> Error: Make command failed, stopping build.

I will take a look.
  
Luis Machado March 30, 2015, 4:45 p.m. UTC | #4
On 03/30/2015 01:31 PM, H.J. Lu wrote:
> On Mon, Mar 30, 2015 at 8:52 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
>> On Sun, 2015-03-29 at 07:10 -0700, H.J. Lu wrote:
>>> On Thu, Mar 26, 2015 at 8:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> I imported zlib from GCC.  This patch adds --with-system-zlib and remove
>>>> --with-zlib in bfd.  OK for master?
>>
>> I think the global binutils-gdb Makefile needs to have a dependency of
>> bfd on zlib.  If I build 'all-binutils' (using just the binutils-gdb
>> repository, not a combined tree with GCC) I get a build failure.  If I
>> explicitly build all-zlib before building all-binutils it works, but I
>> should not have to do that.
>>
>>
>> /bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I/scratch/sellcey/repos/nightly/src/binutils-gdb/bfd/../zlib -g -O2 -rpath /scratch/sellcey/repos/nightly/install-mips-mti-linux-gnu/x86_64-unknown-linux-gnu/mips-mti-linux-gnu/lib -release `cat libtool-soversion`  -static-libstdc++ -static-libgcc  -o libbfd.la  archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo coff-bfd.lo compress.lo corefile.lo format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo `cat ofiles`  -ldl -L../zlib -lz -ldl
>> ./libtool: line 5195: cd: ../zlib: No such file or directory
>> libtool: link: cannot determine absolute directory name of `../zlib'
>> make[3]: *** [libbfd.la] Error 1
>> make[3]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>> make[2]: *** [all-recursive] Error 1
>> make[2]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>> make[1]: *** [all] Error 2
>> make[1]: Leaving directory `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>> make: *** [all-bfd] Error 2
>> Error: Make command failed, stopping build.
>
> I will take a look.
>

It seems GDB's Makefile.in is also missing a few bits to make sure it 
includes ../zlib/libz.a in the final link step, otherwise it tries to 
pick the system's zlib instead of the included zlib, which may fail if 
you have an older libz installed.

--

/usr/bin/ld: ../bfd/libbfd.a(compress.o): undefined reference to symbol 
'compressBound@@ZLIB_1.2.0'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from 
command line
collect2: error: ld returned 1 exit status
make[2]: *** [gdb] Error 1

--

We need something like libiberty in gdb/Makefile.in, but conditionalized 
based on the configure switches to use the system's or the include zlib.

gdb/Makefile.in:

# Where is the "-liberty" library?  Typically in ../libiberty.
LIBIBERTY = ../libiberty/libiberty.a

... and then ...

CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) 
$(LIBDECNUMBER) \
         $(XM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) \
         @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
         $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) \
         $(LIBIBERTY) $(WIN32LIBS) $(LIBGNU)
  
H.J. Lu March 30, 2015, 4:50 p.m. UTC | #5
On Mon, Mar 30, 2015 at 9:45 AM, Luis Machado <lgustavo@codesourcery.com> wrote:
> On 03/30/2015 01:31 PM, H.J. Lu wrote:
>>
>> On Mon, Mar 30, 2015 at 8:52 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
>>>
>>> On Sun, 2015-03-29 at 07:10 -0700, H.J. Lu wrote:
>>>>
>>>> On Thu, Mar 26, 2015 at 8:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>
>>>>> I imported zlib from GCC.  This patch adds --with-system-zlib and
>>>>> remove
>>>>> --with-zlib in bfd.  OK for master?
>>>
>>>
>>> I think the global binutils-gdb Makefile needs to have a dependency of
>>> bfd on zlib.  If I build 'all-binutils' (using just the binutils-gdb
>>> repository, not a combined tree with GCC) I get a build failure.  If I
>>> explicitly build all-zlib before building all-binutils it works, but I
>>> should not have to do that.
>>>
>>>
>>> /bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes
>>> -Wmissing-prototypes -Wshadow -Werror
>>> -I/scratch/sellcey/repos/nightly/src/binutils-gdb/bfd/../zlib -g -O2 -rpath
>>> /scratch/sellcey/repos/nightly/install-mips-mti-linux-gnu/x86_64-unknown-linux-gnu/mips-mti-linux-gnu/lib
>>> -release `cat libtool-soversion`  -static-libstdc++ -static-libgcc  -o
>>> libbfd.la  archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo
>>> coff-bfd.lo compress.lo corefile.lo format.lo hash.lo init.lo libbfd.lo
>>> linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo
>>> stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo
>>> `cat ofiles`  -ldl -L../zlib -lz -ldl
>>> ./libtool: line 5195: cd: ../zlib: No such file or directory
>>> libtool: link: cannot determine absolute directory name of `../zlib'
>>> make[3]: *** [libbfd.la] Error 1
>>> make[3]: Leaving directory
>>> `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>>> make[2]: *** [all-recursive] Error 1
>>> make[2]: Leaving directory
>>> `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>>> make[1]: *** [all] Error 2
>>> make[1]: Leaving directory
>>> `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>>> make: *** [all-bfd] Error 2
>>> Error: Make command failed, stopping build.
>>
>>
>> I will take a look.
>>
>
> It seems GDB's Makefile.in is also missing a few bits to make sure it
> includes ../zlib/libz.a in the final link step, otherwise it tries to pick
> the system's zlib instead of the included zlib, which may fail if you have
> an older libz installed.
>
> --
>
> /usr/bin/ld: ../bfd/libbfd.a(compress.o): undefined reference to symbol
> 'compressBound@@ZLIB_1.2.0'
> //lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from
> command line
> collect2: error: ld returned 1 exit status
> make[2]: *** [gdb] Error 1
>
> --
>
> We need something like libiberty in gdb/Makefile.in, but conditionalized
> based on the configure switches to use the system's or the include zlib.
>

Please check out users/hjl/zlib branch.
  
Steve Ellcey March 30, 2015, 5:13 p.m. UTC | #6
On Mon, 2015-03-30 at 09:50 -0700, H.J. Lu wrote:

> > We need something like libiberty in gdb/Makefile.in, but conditionalized
> > based on the configure switches to use the system's or the include zlib.
> >
> 
> Please check out users/hjl/zlib branch.


This didn't do anything for my build.

Steve Ellcey
sellcey@imgtec.com
  
H.J. Lu March 30, 2015, 5:21 p.m. UTC | #7
On Mon, Mar 30, 2015 at 10:13 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
> On Mon, 2015-03-30 at 09:50 -0700, H.J. Lu wrote:
>
>> > We need something like libiberty in gdb/Makefile.in, but conditionalized
>> > based on the configure switches to use the system's or the include zlib.
>> >
>>
>> Please check out users/hjl/zlib branch.
>
>
> This didn't do anything for my build.
>

master branch is fixed now.
  
Steve Ellcey March 30, 2015, 5:36 p.m. UTC | #8
On Mon, 2015-03-30 at 10:21 -0700, H.J. Lu wrote:

> master branch is fixed now.

Yes, my build is working now.  Thanks.

Steve Ellcey
sellcey@imgtec.com
  
Luis Machado March 30, 2015, 6:18 p.m. UTC | #9
On 03/30/2015 01:50 PM, H.J. Lu wrote:
> On Mon, Mar 30, 2015 at 9:45 AM, Luis Machado <lgustavo@codesourcery.com> wrote:
>> On 03/30/2015 01:31 PM, H.J. Lu wrote:
>>>
>>> On Mon, Mar 30, 2015 at 8:52 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
>>>>
>>>> On Sun, 2015-03-29 at 07:10 -0700, H.J. Lu wrote:
>>>>>
>>>>> On Thu, Mar 26, 2015 at 8:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>>
>>>>>> I imported zlib from GCC.  This patch adds --with-system-zlib and
>>>>>> remove
>>>>>> --with-zlib in bfd.  OK for master?
>>>>
>>>>
>>>> I think the global binutils-gdb Makefile needs to have a dependency of
>>>> bfd on zlib.  If I build 'all-binutils' (using just the binutils-gdb
>>>> repository, not a combined tree with GCC) I get a build failure.  If I
>>>> explicitly build all-zlib before building all-binutils it works, but I
>>>> should not have to do that.
>>>>
>>>>
>>>> /bin/sh ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes
>>>> -Wmissing-prototypes -Wshadow -Werror
>>>> -I/scratch/sellcey/repos/nightly/src/binutils-gdb/bfd/../zlib -g -O2 -rpath
>>>> /scratch/sellcey/repos/nightly/install-mips-mti-linux-gnu/x86_64-unknown-linux-gnu/mips-mti-linux-gnu/lib
>>>> -release `cat libtool-soversion`  -static-libstdc++ -static-libgcc  -o
>>>> libbfd.la  archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo
>>>> coff-bfd.lo compress.lo corefile.lo format.lo hash.lo init.lo libbfd.lo
>>>> linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo
>>>> stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo
>>>> `cat ofiles`  -ldl -L../zlib -lz -ldl
>>>> ./libtool: line 5195: cd: ../zlib: No such file or directory
>>>> libtool: link: cannot determine absolute directory name of `../zlib'
>>>> make[3]: *** [libbfd.la] Error 1
>>>> make[3]: Leaving directory
>>>> `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>>>> make[2]: *** [all-recursive] Error 1
>>>> make[2]: Leaving directory
>>>> `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>>>> make[1]: *** [all] Error 2
>>>> make[1]: Leaving directory
>>>> `/scratch/sellcey/repos/nightly/obj-mips-mti-linux-gnu/binutils-gdb/bfd'
>>>> make: *** [all-bfd] Error 2
>>>> Error: Make command failed, stopping build.
>>>
>>>
>>> I will take a look.
>>>
>>
>> It seems GDB's Makefile.in is also missing a few bits to make sure it
>> includes ../zlib/libz.a in the final link step, otherwise it tries to pick
>> the system's zlib instead of the included zlib, which may fail if you have
>> an older libz installed.
>>
>> --
>>
>> /usr/bin/ld: ../bfd/libbfd.a(compress.o): undefined reference to symbol
>> 'compressBound@@ZLIB_1.2.0'
>> //lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from
>> command line
>> collect2: error: ld returned 1 exit status
>> make[2]: *** [gdb] Error 1
>>
>> --
>>
>> We need something like libiberty in gdb/Makefile.in, but conditionalized
>> based on the configure switches to use the system's or the include zlib.
>>
>
> Please check out users/hjl/zlib branch.
>
>

That fixed it.

Thanks,
Luis
  
Antoine Tremblay March 30, 2015, 7:33 p.m. UTC | #10
On 03/30/2015 01:36 PM, Steve Ellcey wrote:
> On Mon, 2015-03-30 at 10:21 -0700, H.J. Lu wrote:
>
>> master branch is fixed now.
>
> Yes, my build is working now.  Thanks.

Could there still be something missing ?

Doing a ./configure && make on binutils-gdb I get :

gcc -g -O2   -static-libstdc++ -static-libgcc    \
		-o gdb gdb.o ...

     ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a 
../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -lmcheck -ldl 
-lncurses -lm -ldl -lexpat   ../libiberty/libiberty.a 
build-gnulib/import/libgnu.a -ldl 
-Wl,--dynamic-list=../../gdb/proc-service.list
../bfd/libbfd.a(compress.o): In function `decompress_contents':
/home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:46: undefined 
reference to `inflateInit_'
/home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:53: undefined 
reference to `inflate'
/home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:56: undefined 
reference to `inflateReset'
/home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:58: undefined 
reference to `inflateEnd'
../bfd/libbfd.a(compress.o): In function `bfd_compress_section_contents':
/home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:79: undefined 
reference to `compressBound'
/home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:85: undefined 
reference to `compress'

Note this is with d2d67aea8e776d63a987f8dcdb96bc524df96e81

On ubuntu 14.04

I do see zlib being built it just seems like the .a is missing from the 
linking... ?

Regards,

Antoine
  
Antoine Tremblay March 30, 2015, 7:37 p.m. UTC | #11
On 03/30/2015 03:33 PM, Antoine Tremblay wrote:
>
> On 03/30/2015 01:36 PM, Steve Ellcey wrote:
>> On Mon, 2015-03-30 at 10:21 -0700, H.J. Lu wrote:
>>
>>> master branch is fixed now.
>>
>> Yes, my build is working now.  Thanks.
>
> Could there still be something missing ?
>
> Doing a ./configure && make on binutils-gdb I get :
>
> gcc -g -O2   -static-libstdc++ -static-libgcc    \
>          -o gdb gdb.o ...
>
>      ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a
> ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -lmcheck -ldl
> -lncurses -lm -ldl -lexpat   ../libiberty/libiberty.a
> build-gnulib/import/libgnu.a -ldl
> -Wl,--dynamic-list=../../gdb/proc-service.list
> ../bfd/libbfd.a(compress.o): In function `decompress_contents':
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:46: undefined
> reference to `inflateInit_'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:53: undefined
> reference to `inflate'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:56: undefined
> reference to `inflateReset'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:58: undefined
> reference to `inflateEnd'
> ../bfd/libbfd.a(compress.o): In function `bfd_compress_section_contents':
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:79: undefined
> reference to `compressBound'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:85: undefined
> reference to `compress'
>
> Note this is with d2d67aea8e776d63a987f8dcdb96bc524df96e81
>
> On ubuntu 14.04
>
> I do see zlib being built it just seems like the .a is missing from the
> linking... ?
>

Also doing ./configure in binutils/zlib I get :

config.status: creating Makefile
config.status: executing default-1 commands
./config.status: line 1190: ./../../config-ml.in: No such file or directory

So configure does not exit cleanly...ideas?
  
H.J. Lu March 30, 2015, 8:19 p.m. UTC | #12
On Mon, Mar 30, 2015 at 12:33 PM, Antoine Tremblay
<antoine.tremblay@ericsson.com> wrote:
>
> On 03/30/2015 01:36 PM, Steve Ellcey wrote:
>>
>> On Mon, 2015-03-30 at 10:21 -0700, H.J. Lu wrote:
>>
>>> master branch is fixed now.
>>
>>
>> Yes, my build is working now.  Thanks.
>
>
> Could there still be something missing ?
>
> Doing a ./configure && make on binutils-gdb I get :
>
> gcc -g -O2   -static-libstdc++ -static-libgcc    \
>>     ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a
> ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -lmcheck -ldl
> -lncurses -lm -ldl -lexpat   ../libiberty/libiberty.a
> build-gnulib/import/libgnu.a -ldl
> -Wl,--dynamic-list=../../gdb/proc-service.list
> ../bfd/libbfd.a(compress.o): In function `decompress_contents':
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:46: undefined
> reference to `inflateInit_'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:53: undefined
> reference to `inflate'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:56: undefined
> reference to `inflateReset'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:58: undefined
> reference to `inflateEnd'
> ../bfd/libbfd.a(compress.o): In function `bfd_compress_section_contents':
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:79: undefined
> reference to `compressBound'
> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:85: undefined
> reference to `compress'
>                 -o gdb gdb.o ...
>
> Note this is with d2d67aea8e776d63a987f8dcdb96bc524df96e81
>
> On ubuntu 14.04
>
> I do see zlib being built it just seems like the .a is missing from the
> linking... ?

Have you tried users/hjl/zlib branch?
  
Mike Frysinger March 31, 2015, 6:13 a.m. UTC | #13
On 26 Mar 2015 08:57, H.J. Lu wrote:
> --- a/bfd/configure.ac
> +++ b/bfd/configure.ac
>  
> -# Link in zlib if we can.  This allows us to read compressed debug sections.
> -# This is used only by compress.c.
> -AM_ZLIB
> +# Use the system's zlib library.
> +zlibdir=-L../zlib
> +zlibinc="-I\$(srcdir)/../zlib"
> +AC_ARG_WITH(system-zlib,
> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> +zlibdir=
> +zlibinc=
> +)

this is wrong.  the 3rd arg is whether the option was specified, not that the 
option was disabled.  you need to check $withval is equal to "no" (or not equal 
to "yes").
-mike
  
H.J. Lu March 31, 2015, 10:10 a.m. UTC | #14
On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 26 Mar 2015 08:57, H.J. Lu wrote:
>> --- a/bfd/configure.ac
>> +++ b/bfd/configure.ac
>>
>> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>> -# This is used only by compress.c.
>> -AM_ZLIB
>> +# Use the system's zlib library.
>> +zlibdir=-L../zlib
>> +zlibinc="-I\$(srcdir)/../zlib"
>> +AC_ARG_WITH(system-zlib,
>> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>> +zlibdir=
>> +zlibinc=
>> +)
>
> this is wrong.  the 3rd arg is whether the option was specified, not that the
> option was disabled.  you need to check $withval is equal to "no" (or not equal
> to "yes").
> -mike

That is what gcc/configure.ac has and it works for me.
  
Pedro Alves March 31, 2015, 10:37 a.m. UTC | #15
On 03/31/2015 11:10 AM, H.J. Lu wrote:
> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> On 26 Mar 2015 08:57, H.J. Lu wrote:
>>> --- a/bfd/configure.ac
>>> +++ b/bfd/configure.ac
>>>
>>> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>>> -# This is used only by compress.c.
>>> -AM_ZLIB
>>> +# Use the system's zlib library.
>>> +zlibdir=-L../zlib
>>> +zlibinc="-I\$(srcdir)/../zlib"
>>> +AC_ARG_WITH(system-zlib,
>>> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>>> +zlibdir=
>>> +zlibinc=
>>> +)
>>
>> this is wrong.  the 3rd arg is whether the option was specified, not that the
>> option was disabled.  you need to check $withval is equal to "no" (or not equal
>> to "yes").
>> -mike
> 
> That is what gcc/configure.ac has and it works for me.
> 
> 

Why are we patching every tool's configury instead of tweaking
config/zlib.m4 (where AM_ZLIB is from)?  We go from a single
place to edit, to the same configure bits spread around the
tree.  Seems like a step backwards.
  
H.J. Lu March 31, 2015, 10:46 a.m. UTC | #16
On Tue, Mar 31, 2015 at 3:37 AM, Pedro Alves <palves@redhat.com> wrote:
> On 03/31/2015 11:10 AM, H.J. Lu wrote:
>> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>>> On 26 Mar 2015 08:57, H.J. Lu wrote:
>>>> --- a/bfd/configure.ac
>>>> +++ b/bfd/configure.ac
>>>>
>>>> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>>>> -# This is used only by compress.c.
>>>> -AM_ZLIB
>>>> +# Use the system's zlib library.
>>>> +zlibdir=-L../zlib
>>>> +zlibinc="-I\$(srcdir)/../zlib"
>>>> +AC_ARG_WITH(system-zlib,
>>>> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>>>> +zlibdir=
>>>> +zlibinc=
>>>> +)
>>>
>>> this is wrong.  the 3rd arg is whether the option was specified, not that the
>>> option was disabled.  you need to check $withval is equal to "no" (or not equal
>>> to "yes").
>>> -mike
>>
>> That is what gcc/configure.ac has and it works for me.
>>
>>
>
> Why are we patching every tool's configury instead of tweaking
> config/zlib.m4 (where AM_ZLIB is from)?  We go from a single
> place to edit, to the same configure bits spread around the
> tree.  Seems like a step backwards.
>

Replace AM_ZLIB in configure.ac isn't complete. I also needed to change

* Makefile.am (ZLIB): New.
(ZLIBINC): Likewise.
(AM_CFLAGS): Add $(ZLIBINC).
(libbfd_la_LIBADD): Add $(ZLIB).

It is better for Makefile.am to use what configure.ac defines
  
Pedro Alves March 31, 2015, 10:53 a.m. UTC | #17
On 03/31/2015 11:46 AM, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 3:37 AM, Pedro Alves <palves@redhat.com> wrote:
>> On 03/31/2015 11:10 AM, H.J. Lu wrote:
>>> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>>>> On 26 Mar 2015 08:57, H.J. Lu wrote:
>>>>> --- a/bfd/configure.ac
>>>>> +++ b/bfd/configure.ac
>>>>>
>>>>> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>>>>> -# This is used only by compress.c.
>>>>> -AM_ZLIB
>>>>> +# Use the system's zlib library.
>>>>> +zlibdir=-L../zlib
>>>>> +zlibinc="-I\$(srcdir)/../zlib"
>>>>> +AC_ARG_WITH(system-zlib,
>>>>> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>>>>> +zlibdir=
>>>>> +zlibinc=
>>>>> +)
>>>>
>>>> this is wrong.  the 3rd arg is whether the option was specified, not that the
>>>> option was disabled.  you need to check $withval is equal to "no" (or not equal
>>>> to "yes").
>>>> -mike
>>>
>>> That is what gcc/configure.ac has and it works for me.
>>>
>>>
>>
>> Why are we patching every tool's configury instead of tweaking
>> config/zlib.m4 (where AM_ZLIB is from)?  We go from a single
>> place to edit, to the same configure bits spread around the
>> tree.  Seems like a step backwards.
>>
> 
> Replace AM_ZLIB in configure.ac isn't complete. I also needed to change

Never said it was complete.

> 
> * Makefile.am (ZLIB): New.
> (ZLIBINC): Likewise.
> (AM_CFLAGS): Add $(ZLIBINC).
> (libbfd_la_LIBADD): Add $(ZLIB).
> 
> It is better for Makefile.am to use what configure.ac defines

That's orthogonal.  How configure.ac defines what Makefile.am
consumes is the issue.  That can either be through a shared macro,
which makes sure all tools have the exact same command line option
(like AM_ZLIB), or you manually put the same configure.ac bits
everywhere.

Thanks,
Pedro Alves
  
H.J. Lu March 31, 2015, 11:33 a.m. UTC | #18
On Tue, Mar 31, 2015 at 3:53 AM, Pedro Alves <palves@redhat.com> wrote:
> On 03/31/2015 11:46 AM, H.J. Lu wrote:
>> On Tue, Mar 31, 2015 at 3:37 AM, Pedro Alves <palves@redhat.com> wrote:
>>> On 03/31/2015 11:10 AM, H.J. Lu wrote:
>>>> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>>>>> On 26 Mar 2015 08:57, H.J. Lu wrote:
>>>>>> --- a/bfd/configure.ac
>>>>>> +++ b/bfd/configure.ac
>>>>>>
>>>>>> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>>>>>> -# This is used only by compress.c.
>>>>>> -AM_ZLIB
>>>>>> +# Use the system's zlib library.
>>>>>> +zlibdir=-L../zlib
>>>>>> +zlibinc="-I\$(srcdir)/../zlib"
>>>>>> +AC_ARG_WITH(system-zlib,
>>>>>> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>>>>>> +zlibdir=
>>>>>> +zlibinc=
>>>>>> +)
>>>>>
>>>>> this is wrong.  the 3rd arg is whether the option was specified, not that the
>>>>> option was disabled.  you need to check $withval is equal to "no" (or not equal
>>>>> to "yes").
>>>>> -mike
>>>>
>>>> That is what gcc/configure.ac has and it works for me.
>>>>
>>>>
>>>
>>> Why are we patching every tool's configury instead of tweaking
>>> config/zlib.m4 (where AM_ZLIB is from)?  We go from a single
>>> place to edit, to the same configure bits spread around the
>>> tree.  Seems like a step backwards.
>>>
>>
>> Replace AM_ZLIB in configure.ac isn't complete. I also needed to change
>
> Never said it was complete.
>
>>
>> * Makefile.am (ZLIB): New.
>> (ZLIBINC): Likewise.
>> (AM_CFLAGS): Add $(ZLIBINC).
>> (libbfd_la_LIBADD): Add $(ZLIB).
>>
>> It is better for Makefile.am to use what configure.ac defines
>
> That's orthogonal.  How configure.ac defines what Makefile.am
> consumes is the issue.  That can either be through a shared macro,
> which makes sure all tools have the exact same command line option
> (like AM_ZLIB), or you manually put the same configure.ac bits
> everywhere.

They aren't the same.  Some tools like ld, which use zlib implicitly
via libfd and libtool, don't need to reference zlib.  Some only need
to reference zlib library.  Some only need to reference header.
  
Pedro Alves March 31, 2015, 11:46 a.m. UTC | #19
On 03/31/2015 12:33 PM, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 3:53 AM, Pedro Alves <palves@redhat.com> wrote:
>> On 03/31/2015 11:46 AM, H.J. Lu wrote:

>>> It is better for Makefile.am to use what configure.ac defines
>>
>> That's orthogonal.  How configure.ac defines what Makefile.am
>> consumes is the issue.  That can either be through a shared macro,
>> which makes sure all tools have the exact same command line option
>> (like AM_ZLIB), or you manually put the same configure.ac bits
>> everywhere.
> 
> They aren't the same.  Some tools like ld, which use zlib implicitly
> via libfd and libtool, don't need to reference zlib. 

Sure, that one just drops AM_ZLIB.

> Some only need
> to reference zlib library.  Some only need to reference header.
> 

And?  If you replace AM_ZLIB's body with:

# Use the system's zlib library.
zlibdir=-L../zlib
zlibinc="-I\$(srcdir)/../zlib"
AC_ARG_WITH(system-zlib,
[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
zlibdir=
zlibinc=
)
AC_SUBST(zlibdir)
AC_SUBST(zlibinc)

then it'll work for those too.  They just won't use zlibinc
or zlibinc if they don't need it.  Currently you have:

bfd:

> +# Use the system's zlib library.
> +zlibdir=-L../zlib
> +zlibinc="-I\$(srcdir)/../zlib"
> +AC_ARG_WITH(system-zlib,
> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> +zlibdir=
> +zlibinc=
> +)
> +AC_SUBST(zlibdir)
> +AC_SUBST(zlibinc)

gold:

+# Use the system's zlib library.
+zlibdir=-L../zlib
+zlibinc="-I\$(srcdir)/../zlib"
+AC_ARG_WITH(system-zlib,
+[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
+zlibdir=
+zlibinc=
+)
+AC_SUBST(zlibdir)
+AC_SUBST(zlibinc)

gas:

+# 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)

binutils:

+# Use the system's zlib library.
+zlibdir=-L../zlib
+zlibinc="-I\$(srcdir)/../zlib"
+AC_ARG_WITH(system-zlib,
+[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
+zlibdir=
+zlibinc=
+)
+AC_SUBST(zlibdir)
+AC_SUBST(zlibinc)

gdb:

+# Use the system's zlib library.
+zlibdir=-L../zlib
+AC_ARG_WITH(system-zlib,
+[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
+zlibdir=
+)
+AC_SUBST(zlibdir)

and gcc has:

# Use the system's zlib library.
zlibdir=-L../zlib
zlibinc="-I\$(srcdir)/../zlib"
AC_ARG_WITH(system-zlib,
[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
zlibdir=
zlibinc=
)
AC_SUBST(zlibdir)
AC_SUBST(zlibinc)



They're all the same.  Just a couple doesn't define zlibdir or zlibinc.

Thanks,
Pedro Alves
  
H.J. Lu March 31, 2015, 12:01 p.m. UTC | #20
On Tue, Mar 31, 2015 at 4:46 AM, Pedro Alves <palves@redhat.com> wrote:
> On 03/31/2015 12:33 PM, H.J. Lu wrote:
>> On Tue, Mar 31, 2015 at 3:53 AM, Pedro Alves <palves@redhat.com> wrote:
>>> On 03/31/2015 11:46 AM, H.J. Lu wrote:
>
>>>> It is better for Makefile.am to use what configure.ac defines
>>>
>>> That's orthogonal.  How configure.ac defines what Makefile.am
>>> consumes is the issue.  That can either be through a shared macro,
>>> which makes sure all tools have the exact same command line option
>>> (like AM_ZLIB), or you manually put the same configure.ac bits
>>> everywhere.
>>
>> They aren't the same.  Some tools like ld, which use zlib implicitly
>> via libfd and libtool, don't need to reference zlib.
>
> Sure, that one just drops AM_ZLIB.
>
>> Some only need
>> to reference zlib library.  Some only need to reference header.
>>
>
> And?  If you replace AM_ZLIB's body with:
>
> # Use the system's zlib library.
> zlibdir=-L../zlib
> zlibinc="-I\$(srcdir)/../zlib"
> AC_ARG_WITH(system-zlib,
> [AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> zlibdir=
> zlibinc=
> )
> AC_SUBST(zlibdir)
> AC_SUBST(zlibinc)
>
> then it'll work for those too.  They just won't use zlibinc
> or zlibinc if they don't need it.  Currently you have:
>
> bfd:
>
>> +# Use the system's zlib library.
>> +zlibdir=-L../zlib
>> +zlibinc="-I\$(srcdir)/../zlib"
>> +AC_ARG_WITH(system-zlib,
>> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>> +zlibdir=
>> +zlibinc=
>> +)
>> +AC_SUBST(zlibdir)
>> +AC_SUBST(zlibinc)
>
> gold:
>
> +# Use the system's zlib library.
> +zlibdir=-L../zlib
> +zlibinc="-I\$(srcdir)/../zlib"
> +AC_ARG_WITH(system-zlib,
> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> +zlibdir=
> +zlibinc=
> +)
> +AC_SUBST(zlibdir)
> +AC_SUBST(zlibinc)
>
> gas:
>
> +# 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)
>
> binutils:
>
> +# Use the system's zlib library.
> +zlibdir=-L../zlib
> +zlibinc="-I\$(srcdir)/../zlib"
> +AC_ARG_WITH(system-zlib,
> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> +zlibdir=
> +zlibinc=
> +)
> +AC_SUBST(zlibdir)
> +AC_SUBST(zlibinc)
>
> gdb:
>
> +# Use the system's zlib library.
> +zlibdir=-L../zlib
> +AC_ARG_WITH(system-zlib,
> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> +zlibdir=
> +)
> +AC_SUBST(zlibdir)
>
> and gcc has:
>
> # Use the system's zlib library.
> zlibdir=-L../zlib
> zlibinc="-I\$(srcdir)/../zlib"
> AC_ARG_WITH(system-zlib,
> [AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> zlibdir=
> zlibinc=
> )
> AC_SUBST(zlibdir)
> AC_SUBST(zlibinc)
>
>
>
> They're all the same.  Just a couple doesn't define zlibdir or zlibinc.

If zlib.m4 is changed, I will use it and GCC can also use it. But I
don't know if other packages use zlib.m4.
  
Antoine Tremblay March 31, 2015, 12:08 p.m. UTC | #21
On 03/30/2015 04:19 PM, H.J. Lu wrote:
> On Mon, Mar 30, 2015 at 12:33 PM, Antoine Tremblay
> <antoine.tremblay@ericsson.com> wrote:
>>
>> On 03/30/2015 01:36 PM, Steve Ellcey wrote:
>>>
>>> On Mon, 2015-03-30 at 10:21 -0700, H.J. Lu wrote:
>>>
>>>> master branch is fixed now.
>>>
>>>
>>> Yes, my build is working now.  Thanks.
>>
>>
>> Could there still be something missing ?
>>
>> Doing a ./configure && make on binutils-gdb I get :
>>
>> gcc -g -O2   -static-libstdc++ -static-libgcc    \
>>>      ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a
>> ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -lmcheck -ldl
>> -lncurses -lm -ldl -lexpat   ../libiberty/libiberty.a
>> build-gnulib/import/libgnu.a -ldl
>> -Wl,--dynamic-list=../../gdb/proc-service.list
>> ../bfd/libbfd.a(compress.o): In function `decompress_contents':
>> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:46: undefined
>> reference to `inflateInit_'
>> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:53: undefined
>> reference to `inflate'
>> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:56: undefined
>> reference to `inflateReset'
>> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:58: undefined
>> reference to `inflateEnd'
>> ../bfd/libbfd.a(compress.o): In function `bfd_compress_section_contents':
>> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:79: undefined
>> reference to `compressBound'
>> /home/x/src/binutils-gdb/build/bfd/../../bfd/compress.c:85: undefined
>> reference to `compress'
>>                  -o gdb gdb.o ...
>>
>> Note this is with d2d67aea8e776d63a987f8dcdb96bc524df96e81
>>
>> On ubuntu 14.04
>>
>> I do see zlib being built it just seems like the .a is missing from the
>> linking... ?
>
> Have you tried users/hjl/zlib branch?
>

That branch builds... but I need to use master...

I'll have to wait until you reach an agreement with Pedro to build again 
it seems :(

Antoine
  
Pedro Alves March 31, 2015, 12:15 p.m. UTC | #22
On 03/31/2015 01:01 PM, H.J. Lu wrote:
>> >
>> >
>> > They're all the same.  Just a couple doesn't define zlibdir or zlibinc.
> If zlib.m4 is changed, I will use it and GCC can also use it. But I
> don't know if other packages use zlib.m4.

Please change it.  Packages not in the tree can replace zlib.m4 with
something else if they need it, or adjust to the new body, and thus
end up consistent with the rest of the toolchain.

"git blame" shows that zlib.m4 was invented exactly to make
sure bfd/gdb use the same zlib switches and checks:

 https://sourceware.org/ml/binutils/2009-10/msg00600.html

Thanks,
Pedro Alves
  
Mike Frysinger March 31, 2015, 4:41 p.m. UTC | #23
On 31 Mar 2015 03:10, H.J. Lu wrote:
> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger wrote:
> > On 26 Mar 2015 08:57, H.J. Lu wrote:
> >> --- a/bfd/configure.ac
> >> +++ b/bfd/configure.ac
> >>
> >> -# Link in zlib if we can.  This allows us to read compressed debug sections.
> >> -# This is used only by compress.c.
> >> -AM_ZLIB
> >> +# Use the system's zlib library.
> >> +zlibdir=-L../zlib
> >> +zlibinc="-I\$(srcdir)/../zlib"
> >> +AC_ARG_WITH(system-zlib,
> >> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> >> +zlibdir=
> >> +zlibinc=
> >> +)
> >
> > this is wrong.  the 3rd arg is whether the option was specified, not that the
> > option was disabled.  you need to check $withval is equal to "no" (or not equal
> > to "yes").
> 
> That is what gcc/configure.ac has and it works for me.

then gcc/configure.ac is also broken.  whether "it works for me" is
irrelevant -- simply read the code and you'll see it's wrong.  if you
pass --without-system-zlib the code wrongly behaves as if you passed
--with-system-zlib.

i mention this because it is breaking my test builds.  not that that
really matters -- the code is clearly incorrect.
-mike
  
H.J. Lu March 31, 2015, 4:56 p.m. UTC | #24
On Tue, Mar 31, 2015 at 9:41 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 31 Mar 2015 03:10, H.J. Lu wrote:
>> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger wrote:
>> > On 26 Mar 2015 08:57, H.J. Lu wrote:
>> >> --- a/bfd/configure.ac
>> >> +++ b/bfd/configure.ac
>> >>
>> >> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>> >> -# This is used only by compress.c.
>> >> -AM_ZLIB
>> >> +# Use the system's zlib library.
>> >> +zlibdir=-L../zlib
>> >> +zlibinc="-I\$(srcdir)/../zlib"
>> >> +AC_ARG_WITH(system-zlib,
>> >> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>> >> +zlibdir=
>> >> +zlibinc=
>> >> +)
>> >
>> > this is wrong.  the 3rd arg is whether the option was specified, not that the
>> > option was disabled.  you need to check $withval is equal to "no" (or not equal
>> > to "yes").
>>
>> That is what gcc/configure.ac has and it works for me.
>
> then gcc/configure.ac is also broken.  whether "it works for me" is
> irrelevant -- simply read the code and you'll see it's wrong.  if you
> pass --without-system-zlib the code wrongly behaves as if you passed
> --with-system-zlib.
>
> i mention this because it is breaking my test builds.  not that that
> really matters -- the code is clearly incorrect.

We should fix zlib.m4 and use it in gcc/configure.ac.

FWIW, I tested with -with-system-zlib and without --with-system-zlib.
  
Mike Frysinger March 31, 2015, 5:01 p.m. UTC | #25
On 31 Mar 2015 09:56, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 9:41 AM, Mike Frysinger wrote:
> > On 31 Mar 2015 03:10, H.J. Lu wrote:
> >> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger wrote:
> >> > On 26 Mar 2015 08:57, H.J. Lu wrote:
> >> >> --- a/bfd/configure.ac
> >> >> +++ b/bfd/configure.ac
> >> >>
> >> >> -# Link in zlib if we can.  This allows us to read compressed debug sections.
> >> >> -# This is used only by compress.c.
> >> >> -AM_ZLIB
> >> >> +# Use the system's zlib library.
> >> >> +zlibdir=-L../zlib
> >> >> +zlibinc="-I\$(srcdir)/../zlib"
> >> >> +AC_ARG_WITH(system-zlib,
> >> >> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
> >> >> +zlibdir=
> >> >> +zlibinc=
> >> >> +)
> >> >
> >> > this is wrong.  the 3rd arg is whether the option was specified, not that the
> >> > option was disabled.  you need to check $withval is equal to "no" (or not equal
> >> > to "yes").
> >>
> >> That is what gcc/configure.ac has and it works for me.
> >
> > then gcc/configure.ac is also broken.  whether "it works for me" is
> > irrelevant -- simply read the code and you'll see it's wrong.  if you
> > pass --without-system-zlib the code wrongly behaves as if you passed
> > --with-system-zlib.
> >
> > i mention this because it is breaking my test builds.  not that that
> > really matters -- the code is clearly incorrect.
> 
> We should fix zlib.m4 and use it in gcc/configure.ac.

sure; i await your patches ;).  i'm not trying to point fingers here for
pointing's sake -- binutils & gdb were working before and now they're broken,
and they broke due to the zlib patches you merged.  so i think it's reasonable
to expect you to drive further fixes (probably across gcc) even though the bug 
has existed in gcc for sometime.
-mike
  
H.J. Lu March 31, 2015, 5:04 p.m. UTC | #26
On Tue, Mar 31, 2015 at 10:01 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 31 Mar 2015 09:56, H.J. Lu wrote:
>> On Tue, Mar 31, 2015 at 9:41 AM, Mike Frysinger wrote:
>> > On 31 Mar 2015 03:10, H.J. Lu wrote:
>> >> On Mon, Mar 30, 2015 at 11:13 PM, Mike Frysinger wrote:
>> >> > On 26 Mar 2015 08:57, H.J. Lu wrote:
>> >> >> --- a/bfd/configure.ac
>> >> >> +++ b/bfd/configure.ac
>> >> >>
>> >> >> -# Link in zlib if we can.  This allows us to read compressed debug sections.
>> >> >> -# This is used only by compress.c.
>> >> >> -AM_ZLIB
>> >> >> +# Use the system's zlib library.
>> >> >> +zlibdir=-L../zlib
>> >> >> +zlibinc="-I\$(srcdir)/../zlib"
>> >> >> +AC_ARG_WITH(system-zlib,
>> >> >> +[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
>> >> >> +zlibdir=
>> >> >> +zlibinc=
>> >> >> +)
>> >> >
>> >> > this is wrong.  the 3rd arg is whether the option was specified, not that the
>> >> > option was disabled.  you need to check $withval is equal to "no" (or not equal
>> >> > to "yes").
>> >>
>> >> That is what gcc/configure.ac has and it works for me.
>> >
>> > then gcc/configure.ac is also broken.  whether "it works for me" is
>> > irrelevant -- simply read the code and you'll see it's wrong.  if you
>> > pass --without-system-zlib the code wrongly behaves as if you passed
>> > --with-system-zlib.
>> >
>> > i mention this because it is breaking my test builds.  not that that
>> > really matters -- the code is clearly incorrect.
>>
>> We should fix zlib.m4 and use it in gcc/configure.ac.
>
> sure; i await your patches ;).  i'm not trying to point fingers here for
> pointing's sake -- binutils & gdb were working before and now they're broken,
> and they broke due to the zlib patches you merged.  so i think it's reasonable
> to expect you to drive further fixes (probably across gcc) even though the bug
> has existed in gcc for sometime.

Sure.  I have put it in my queue.

Sorry for the inconvenience.
  
Antoine Tremblay March 31, 2015, 5:12 p.m. UTC | #27
>Also doing ./configure in binutils/zlib I get :
>
> config.status: creating Makefile
> config.status: executing default-1 commands
> ./config.status: line 1190: ./../../config-ml.in: No such file or directory
>
> So configure does not exit cleanly...ideas?
>
>

I did a bit more research on this issue and I get this if I build gdb 
from it's source directory

in binutils-gdb
./configure
make

make fails with : while in zlib directory

configure: creating ./config.status
config.status: creating Makefile
config.status: executing default-1 commands
./config.status: line 1190: ./../../config-ml.in: No such file or directory

However if I build out of tree in like binutils-gdb/build for example I 
do not get this issue.

Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?

Subject: [PATCH 09/76] A zlib to tarball

I see this snippet there

-    ./configure --target=i386-pc-linux-gnu
+    ./configure --target=i386-pc-linux-gnu \
+       --with-target-subdir=. \
+       --disable-multilib

With these options I get around the configure problem only to fail in 
gas with :
make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
/bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall 
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g 
-O2  -static-libstdc++ -static-libgcc  -o as-new app.o as.o 
atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o 
ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o 
frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o 
messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o 
write.o tc-i386.o obj-elf.o atof-ieee.o  ../opcodes/libopcodes.la 
../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes 
-Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o 
as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o 
dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o 
flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o 
listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o 
stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o 
../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a 
-L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
/usr/bin/ld: cannot find -lz


This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e

Did you try to compile directly in the src tree ?
  
H.J. Lu March 31, 2015, 5:16 p.m. UTC | #28
On Tue, Mar 31, 2015 at 10:12 AM, Antoine Tremblay
<antoine.tremblay@ericsson.com> wrote:
>> Also doing ./configure in binutils/zlib I get :
>>
>> config.status: creating Makefile
>> config.status: executing default-1 commands
>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>> directory
>>
>> So configure does not exit cleanly...ideas?
>>
>>
>
> I did a bit more research on this issue and I get this if I build gdb from
> it's source directory
>
> in binutils-gdb
> ./configure
> make
>
> make fails with : while in zlib directory
>
> configure: creating ./config.status
> config.status: creating Makefile
> config.status: executing default-1 commands
> ./config.status: line 1190: ./../../config-ml.in: No such file or directory
>
> However if I build out of tree in like binutils-gdb/build for example I do
> not get this issue.
>
> Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?
>
> Subject: [PATCH 09/76] A zlib to tarball
>
> I see this snippet there
>
> -    ./configure --target=i386-pc-linux-gnu
> +    ./configure --target=i386-pc-linux-gnu \
> +       --with-target-subdir=. \
> +       --disable-multilib
>
> With these options I get around the configure problem only to fail in gas
> with :
> make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
> /bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes
> -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g -O2  -static-libstdc++
> -static-libgcc  -o as-new app.o as.o atof-generic.o compress-debug.o cond.o
> depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
> flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o
> listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
> stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
> ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
> libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes
> -Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o
> as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o
> dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o
> flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o
> macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o
> symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
> ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a
> -L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
> /usr/bin/ld: cannot find -lz
>
>
> This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e
>
> Did you try to compile directly in the src tree ?
>

Yes, I did.  You need to add --disable-multilib,  and maybe
--with-target-subdir=.
  
Antoine Tremblay March 31, 2015, 5:18 p.m. UTC | #29
On 03/31/2015 01:16 PM, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 10:12 AM, Antoine Tremblay
> <antoine.tremblay@ericsson.com> wrote:
>>> Also doing ./configure in binutils/zlib I get :
>>>
>>> config.status: creating Makefile
>>> config.status: executing default-1 commands
>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>> directory
>>>
>>> So configure does not exit cleanly...ideas?
>>>
>>>
>>
>> I did a bit more research on this issue and I get this if I build gdb from
>> it's source directory
>>
>> in binutils-gdb
>> ./configure
>> make
>>
>> make fails with : while in zlib directory
>>
>> configure: creating ./config.status
>> config.status: creating Makefile
>> config.status: executing default-1 commands
>> ./config.status: line 1190: ./../../config-ml.in: No such file or directory
>>
>> However if I build out of tree in like binutils-gdb/build for example I do
>> not get this issue.
>>
>> Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?
>>
>> Subject: [PATCH 09/76] A zlib to tarball
>>
>> I see this snippet there
>>
>> -    ./configure --target=i386-pc-linux-gnu
>> +    ./configure --target=i386-pc-linux-gnu \
>> +       --with-target-subdir=. \
>> +       --disable-multilib
>>
>> With these options I get around the configure problem only to fail in gas
>> with :
>> make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
>> /bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall -Wstrict-prototypes
>> -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g -O2  -static-libstdc++
>> -static-libgcc  -o as-new app.o as.o atof-generic.o compress-debug.o cond.o
>> depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>> flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o
>> listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
>> stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>> ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
>> libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>> -Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o
>> as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o
>> dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o
>> flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o
>> macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o
>> symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>> ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a
>> -L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
>> /usr/bin/ld: cannot find -lz
>>
>>
>> This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e
>>
>> Did you try to compile directly in the src tree ?
>>
>
> Yes, I did.  You need to add --disable-multilib,  and maybe
> --with-target-subdir=.
>

As I said if I add  --disable-multilib, -with-target-subdir=.

I get into the gas missing zlib error above ?

Also I don't think it's a good idea that gdb would require options to 
compile in it's source tree ?

Is there a good reason for this ?
  
H.J. Lu March 31, 2015, 8:16 p.m. UTC | #30
On Tue, Mar 31, 2015 at 10:18 AM, Antoine Tremblay
<antoine.tremblay@ericsson.com> wrote:
>
>
> On 03/31/2015 01:16 PM, H.J. Lu wrote:
>>
>> On Tue, Mar 31, 2015 at 10:12 AM, Antoine Tremblay
>> <antoine.tremblay@ericsson.com> wrote:
>>>>
>>>> Also doing ./configure in binutils/zlib I get :
>>>>
>>>> config.status: creating Makefile
>>>> config.status: executing default-1 commands
>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>> directory
>>>>
>>>> So configure does not exit cleanly...ideas?
>>>>
>>>>
>>>
>>> I did a bit more research on this issue and I get this if I build gdb
>>> from
>>> it's source directory
>>>
>>> in binutils-gdb
>>> ./configure
>>> make
>>>
>>> make fails with : while in zlib directory
>>>
>>> configure: creating ./config.status
>>> config.status: creating Makefile
>>> config.status: executing default-1 commands
>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>> directory
>>>
>>> However if I build out of tree in like binutils-gdb/build for example I
>>> do
>>> not get this issue.
>>>
>>> Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?
>>>
>>> Subject: [PATCH 09/76] A zlib to tarball
>>>
>>> I see this snippet there
>>>
>>> -    ./configure --target=i386-pc-linux-gnu
>>> +    ./configure --target=i386-pc-linux-gnu \
>>> +       --with-target-subdir=. \
>>> +       --disable-multilib
>>>
>>> With these options I get around the configure problem only to fail in gas
>>> with :
>>> make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
>>> /bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall
>>> -Wstrict-prototypes
>>> -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g -O2
>>> -static-libstdc++
>>> -static-libgcc  -o as-new app.o as.o atof-generic.o compress-debug.o
>>> cond.o
>>> depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>> flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o
>>> listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
>>> stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>> ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
>>> libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>>> -Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o
>>> as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o
>>> dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>> flonum-konst.o
>>> flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o
>>> literal.o
>>> macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o
>>> symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>> ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a
>>> -L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
>>> /usr/bin/ld: cannot find -lz
>>>
>>>
>>> This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e
>>>
>>> Did you try to compile directly in the src tree ?
>>>
>>
>> Yes, I did.  You need to add --disable-multilib,  and maybe
>> --with-target-subdir=.
>>
>
> As I said if I add  --disable-multilib, -with-target-subdir=.
>
> I get into the gas missing zlib error above ?
>
> Also I don't think it's a good idea that gdb would require options to
> compile in it's source tree ?
>
> Is there a good reason for this ?
>
>

It should be fixed now.
  
Antoine Tremblay April 1, 2015, 12:18 p.m. UTC | #31
On 03/31/2015 04:16 PM, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 10:18 AM, Antoine Tremblay
> <antoine.tremblay@ericsson.com> wrote:
>>
>>
>> On 03/31/2015 01:16 PM, H.J. Lu wrote:
>>>
>>> On Tue, Mar 31, 2015 at 10:12 AM, Antoine Tremblay
>>> <antoine.tremblay@ericsson.com> wrote:
>>>>>
>>>>> Also doing ./configure in binutils/zlib I get :
>>>>>
>>>>> config.status: creating Makefile
>>>>> config.status: executing default-1 commands
>>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>>> directory
>>>>>
>>>>> So configure does not exit cleanly...ideas?
>>>>>
>>>>>
>>>>
>>>> I did a bit more research on this issue and I get this if I build gdb
>>>> from
>>>> it's source directory
>>>>
>>>> in binutils-gdb
>>>> ./configure
>>>> make
>>>>
>>>> make fails with : while in zlib directory
>>>>
>>>> configure: creating ./config.status
>>>> config.status: creating Makefile
>>>> config.status: executing default-1 commands
>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>> directory
>>>>
>>>> However if I build out of tree in like binutils-gdb/build for example I
>>>> do
>>>> not get this issue.
>>>>
>>>> Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?
>>>>
>>>> Subject: [PATCH 09/76] A zlib to tarball
>>>>
>>>> I see this snippet there
>>>>
>>>> -    ./configure --target=i386-pc-linux-gnu
>>>> +    ./configure --target=i386-pc-linux-gnu \
>>>> +       --with-target-subdir=. \
>>>> +       --disable-multilib
>>>>
>>>> With these options I get around the configure problem only to fail in gas
>>>> with :
>>>> make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
>>>> /bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall
>>>> -Wstrict-prototypes
>>>> -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g -O2
>>>> -static-libstdc++
>>>> -static-libgcc  -o as-new app.o as.o atof-generic.o compress-debug.o
>>>> cond.o
>>>> depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>>> flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o
>>>> listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
>>>> stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>>> ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
>>>> libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>>>> -Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o
>>>> as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o
>>>> dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>>> flonum-konst.o
>>>> flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o
>>>> literal.o
>>>> macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o
>>>> symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>>> ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a
>>>> -L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
>>>> /usr/bin/ld: cannot find -lz
>>>>
>>>>
>>>> This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e
>>>>
>>>> Did you try to compile directly in the src tree ?
>>>>
>>>
>>> Yes, I did.  You need to add --disable-multilib,  and maybe
>>> --with-target-subdir=.
>>>
>>
>> As I said if I add  --disable-multilib, -with-target-subdir=.
>>
>> I get into the gas missing zlib error above ?
>>
>> Also I don't think it's a good idea that gdb would require options to
>> compile in it's source tree ?
>>
>> Is there a good reason for this ?
>>
>>
>
> It should be fixed now.
>

It is indeed , thanks :)

Antoine
  
Bin.Cheng April 2, 2015, 3:22 a.m. UTC | #32
On Wed, Apr 1, 2015 at 4:16 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Mar 31, 2015 at 10:18 AM, Antoine Tremblay
> <antoine.tremblay@ericsson.com> wrote:
>>
>>
>> On 03/31/2015 01:16 PM, H.J. Lu wrote:
>>>
>>> On Tue, Mar 31, 2015 at 10:12 AM, Antoine Tremblay
>>> <antoine.tremblay@ericsson.com> wrote:
>>>>>
>>>>> Also doing ./configure in binutils/zlib I get :
>>>>>
>>>>> config.status: creating Makefile
>>>>> config.status: executing default-1 commands
>>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>>> directory
>>>>>
>>>>> So configure does not exit cleanly...ideas?
>>>>>
>>>>>
>>>>
>>>> I did a bit more research on this issue and I get this if I build gdb
>>>> from
>>>> it's source directory
>>>>
>>>> in binutils-gdb
>>>> ./configure
>>>> make
>>>>
>>>> make fails with : while in zlib directory
>>>>
>>>> configure: creating ./config.status
>>>> config.status: creating Makefile
>>>> config.status: executing default-1 commands
>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>> directory
>>>>
>>>> However if I build out of tree in like binutils-gdb/build for example I
>>>> do
>>>> not get this issue.
>>>>
>>>> Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?
>>>>
>>>> Subject: [PATCH 09/76] A zlib to tarball
>>>>
>>>> I see this snippet there
>>>>
>>>> -    ./configure --target=i386-pc-linux-gnu
>>>> +    ./configure --target=i386-pc-linux-gnu \
>>>> +       --with-target-subdir=. \
>>>> +       --disable-multilib
>>>>
>>>> With these options I get around the configure problem only to fail in gas
>>>> with :
>>>> make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
>>>> /bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall
>>>> -Wstrict-prototypes
>>>> -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g -O2
>>>> -static-libstdc++
>>>> -static-libgcc  -o as-new app.o as.o atof-generic.o compress-debug.o
>>>> cond.o
>>>> depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>>> flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o
>>>> listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
>>>> stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>>> ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
>>>> libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>>>> -Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o
>>>> as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o
>>>> dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>>> flonum-konst.o
>>>> flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o
>>>> literal.o
>>>> macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o
>>>> symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>>> ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a
>>>> -L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
>>>> /usr/bin/ld: cannot find -lz
>>>>
>>>>
>>>> This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e
>>>>
>>>> Did you try to compile directly in the src tree ?
>>>>
>>>
>>> Yes, I did.  You need to add --disable-multilib,  and maybe
>>> --with-target-subdir=.
>>>
>>
>> As I said if I add  --disable-multilib, -with-target-subdir=.
>>
>> I get into the gas missing zlib error above ?
>>
>> Also I don't think it's a good idea that gdb would require options to
>> compile in it's source tree ?
>>
>> Is there a good reason for this ?
>>
>>
>
> It should be fixed now.
>
Is it possible that GDB cross build hasn't been fixed yet?  If I cross
build GDB for arm-none-linux-gnueabi(hf) or aarch64-none-linux-gnu
with below configuration:

../binutils-gdb/configure --enable-64-bit-bfd
--enable-targets=arm-none-eabi,arm-none-linux-gnueabihf,armeb-none-eabi,armeb-none-linux-gnueabihf
--target=arm-none-linux-gnueabihf --disable-doc --disable-gdbtk
--disable-nls --disable-tui --without-python --without-x ...

Yes zlib is built in build directory, and -lz is added on link command
line of as/gdb/sim, but option "-L/home/.../obj/binutils/zlib" is only
added for binutils program, not GDB/SIM.  It seems to me gdb/sim still
use the system z library, rather than the built one.  The readelf -dl
gives below information:
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libtinfo.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]


We also do cross build with "build != host == target".  In this
scenario, neither "-lz" and "-L..." option is't added in link command
line for gdb/sim.  And I got below error message:

../bfd/libbfd.a(compress.o): In function `decompress_contents':
/home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:46:
undefined reference to `inflateInit_'
/home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:56:
undefined reference to `inflateReset'
/home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:53:
undefined reference to `inflate'
/home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:58:
undefined reference to `inflateEnd'
../bfd/libbfd.a(compress.o): In function `bfd_compress_section_contents':
/home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:79:
undefined reference to `compressBound'
/home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:85:
undefined reference to `compress'
collect2: error: ld returned 1 exit status


Thanks,
bin
>
> --
> H.J.
  
Bin.Cheng April 2, 2015, 3:53 a.m. UTC | #33
On Thu, Apr 2, 2015 at 11:22 AM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Wed, Apr 1, 2015 at 4:16 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, Mar 31, 2015 at 10:18 AM, Antoine Tremblay
>> <antoine.tremblay@ericsson.com> wrote:
>>>
>>>
>>> On 03/31/2015 01:16 PM, H.J. Lu wrote:
>>>>
>>>> On Tue, Mar 31, 2015 at 10:12 AM, Antoine Tremblay
>>>> <antoine.tremblay@ericsson.com> wrote:
>>>>>>
>>>>>> Also doing ./configure in binutils/zlib I get :
>>>>>>
>>>>>> config.status: creating Makefile
>>>>>> config.status: executing default-1 commands
>>>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>>>> directory
>>>>>>
>>>>>> So configure does not exit cleanly...ideas?
>>>>>>
>>>>>>
>>>>>
>>>>> I did a bit more research on this issue and I get this if I build gdb
>>>>> from
>>>>> it's source directory
>>>>>
>>>>> in binutils-gdb
>>>>> ./configure
>>>>> make
>>>>>
>>>>> make fails with : while in zlib directory
>>>>>
>>>>> configure: creating ./config.status
>>>>> config.status: creating Makefile
>>>>> config.status: executing default-1 commands
>>>>> ./config.status: line 1190: ./../../config-ml.in: No such file or
>>>>> directory
>>>>>
>>>>> However if I build out of tree in like binutils-gdb/build for example I
>>>>> do
>>>>> not get this issue.
>>>>>
>>>>> Could this be related to 92c695a14f6a5a24b177e89624c13d7dbcbf9e1f ?
>>>>>
>>>>> Subject: [PATCH 09/76] A zlib to tarball
>>>>>
>>>>> I see this snippet there
>>>>>
>>>>> -    ./configure --target=i386-pc-linux-gnu
>>>>> +    ./configure --target=i386-pc-linux-gnu \
>>>>> +       --with-target-subdir=. \
>>>>> +       --disable-multilib
>>>>>
>>>>> With these options I get around the configure problem only to fail in gas
>>>>> with :
>>>>> make[4]: Entering directory `/home/x/src/binutils-gdb/gas'
>>>>> /bin/bash ./libtool --tag=CC   --mode=link gcc -W -Wall
>>>>> -Wstrict-prototypes
>>>>> -Wmissing-prototypes -Wshadow -Werror -I./../zlib -g -O2
>>>>> -static-libstdc++
>>>>> -static-libgcc  -o as-new app.o as.o atof-generic.o compress-debug.o
>>>>> cond.o
>>>>> depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>>>> flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o
>>>>> listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o
>>>>> stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>>>> ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a   -ldl
>>>>> libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>>>>> -Wshadow -Werror -I./../zlib -g -O2 -static-libstdc++ -static-libgcc -o
>>>>> as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o
>>>>> dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o
>>>>> flonum-konst.o
>>>>> flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o
>>>>> literal.o
>>>>> macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o
>>>>> symbols.o write.o tc-i386.o obj-elf.o atof-ieee.o
>>>>> ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a
>>>>> -L/home/x/src/binutils-gdb/zlib -lz ../libiberty/libiberty.a -ldl
>>>>> /usr/bin/ld: cannot find -lz
>>>>>
>>>>>
>>>>> This is with head as :  711a72d3d6f8cd3c3f408e718ff19aa4bfd2144e
>>>>>
>>>>> Did you try to compile directly in the src tree ?
>>>>>
>>>>
>>>> Yes, I did.  You need to add --disable-multilib,  and maybe
>>>> --with-target-subdir=.
>>>>
>>>
>>> As I said if I add  --disable-multilib, -with-target-subdir=.
>>>
>>> I get into the gas missing zlib error above ?
>>>
>>> Also I don't think it's a good idea that gdb would require options to
>>> compile in it's source tree ?
>>>
>>> Is there a good reason for this ?
>>>
>>>
>>
>> It should be fixed now.
>>
> Is it possible that GDB cross build hasn't been fixed yet?  If I cross
> build GDB for arm-none-linux-gnueabi(hf) or aarch64-none-linux-gnu
> with below configuration:
>
> ../binutils-gdb/configure --enable-64-bit-bfd
> --enable-targets=arm-none-eabi,arm-none-linux-gnueabihf,armeb-none-eabi,armeb-none-linux-gnueabihf
> --target=arm-none-linux-gnueabihf --disable-doc --disable-gdbtk
> --disable-nls --disable-tui --without-python --without-x ...
>
> Yes zlib is built in build directory, and -lz is added on link command
> line of as/gdb/sim, but option "-L/home/.../obj/binutils/zlib" is only
> added for binutils program, not GDB/SIM.  It seems to me gdb/sim still
> use the system z library, rather than the built one.  The readelf -dl
> gives below information:
>  0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
>  0x0000000000000001 (NEEDED)             Shared library: [libtinfo.so.5]
>  0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
>  0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
>  0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
>
>
> We also do cross build with "build != host == target".  In this
> scenario, neither "-lz" and "-L..." option is't added in link command
> line for gdb/sim.  And I got below error message:
>
> ../bfd/libbfd.a(compress.o): In function `decompress_contents':
> /home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:46:
> undefined reference to `inflateInit_'
> /home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:56:
> undefined reference to `inflateReset'
> /home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:53:
> undefined reference to `inflate'
> /home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:58:
> undefined reference to `inflateEnd'
> ../bfd/libbfd.a(compress.o): In function `bfd_compress_section_contents':
> /home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:79:
> undefined reference to `compressBound'
> /home/binche01/work/systematic_testing/2015/workspace/build/bfd/../../binutils-gdb.old/bfd/compress.c:85:
> undefined reference to `compress'
> collect2: error: ld returned 1 exit status
>
Sorry my bad.  My snapshot is just two commits behind the fix.  So yes
it is fixed.

Thanks,
bin
>
> Thanks,
> bin
>>
>> --
>> H.J.
  

Patch

diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 5d7f899..03b6442 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -43,9 +43,15 @@  noinst_LTLIBRARIES = libbfd.la
 libbfd_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
 endif
 
+# 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.
+ZLIB = @zlibdir@ -lz
+ZLIBINC = @zlibinc@
+
 WARN_CFLAGS = @WARN_CFLAGS@
 NO_WERROR = @NO_WERROR@
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
 if PLUGINS
 bfdinclude_HEADERS += $(INCDIR)/plugin-api.h
@@ -840,7 +846,7 @@  ofiles: stamp-ofiles ; @true
 libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
 EXTRA_libbfd_la_SOURCES = $(CFILES)
 libbfd_la_DEPENDENCIES = $(OFILES) ofiles
-libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL)
+libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB)
 libbfd_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@
 
 # libtool will build .libs/libbfd.a.  We create libbfd.a in the build
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 60d994f..92eb33d 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -79,8 +79,8 @@  am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
 	$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \
-	$(top_srcdir)/version.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/version.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -334,6 +334,8 @@  top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 wordsize = @wordsize@
+zlibdir = @zlibdir@
+zlibinc = @zlibinc@
 AUTOMAKE_OPTIONS = 1.11 no-dist foreign
 ACLOCAL_AMFLAGS = -I . -I .. -I ../config
 INCDIR = $(srcdir)/../include
@@ -349,7 +351,13 @@  libbfd_la_LDFLAGS = $(am__append_1) -release `cat libtool-soversion` \
 @INSTALL_LIBBFD_TRUE@	$(INCDIR)/bfdlink.h $(am__append_2)
 @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@
 @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la
-AM_CFLAGS = $(WARN_CFLAGS)
+
+# 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.
+ZLIB = @zlibdir@ -lz
+ZLIBINC = @zlibinc@
+AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
 @PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@
 
@@ -1113,7 +1121,7 @@  OFILES = $(BFD_BACKENDS) $(BFD_MACHINES) @COREFILE@ @bfd64_libs@
 libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
 EXTRA_libbfd_la_SOURCES = $(CFILES)
 libbfd_la_DEPENDENCIES = $(OFILES) ofiles
-libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL)
+libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB)
 
 # libtool will build .libs/libbfd.a.  We create libbfd.a in the build
 # directory so that we don't have to convert all the programs that use
diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4
index acb6419..ce6a72e 100644
--- a/bfd/acinclude.m4
+++ b/bfd/acinclude.m4
@@ -16,8 +16,6 @@  dnl along with this program; see the file COPYING3.  If not see
 dnl <http://www.gnu.org/licenses/>.
 dnl
 
-sinclude([../config/zlib.m4])
-
 dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
 AC_DEFUN([BFD_BINARY_FOPEN],
 [AC_REQUIRE([AC_CANONICAL_TARGET])
diff --git a/bfd/compress.c b/bfd/compress.c
index 993a1d3..7e498fa 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -19,14 +19,11 @@ 
    MA 02110-1301, USA.  */
 
 #include "sysdep.h"
+#include <zlib.h>
 #include "bfd.h"
 #include "libbfd.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 #include "safe-ctype.h"
 
-#ifdef HAVE_ZLIB_H
 static bfd_boolean
 decompress_contents (bfd_byte *compressed_buffer,
 		     bfd_size_type compressed_size,
@@ -72,10 +69,9 @@  decompress_contents (bfd_byte *compressed_buffer,
    successfully.  */
 
 static bfd_boolean
-bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED,
-			       sec_ptr sec ATTRIBUTE_UNUSED,
-			       bfd_byte *uncompressed_buffer ATTRIBUTE_UNUSED,
-			       bfd_size_type uncompressed_size ATTRIBUTE_UNUSED)
+bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec,
+			       bfd_byte *uncompressed_buffer,
+			       bfd_size_type uncompressed_size)
 {
   uLong compressed_size;
   bfd_byte *compressed_buffer;
@@ -127,7 +123,6 @@  bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED,
 
   return TRUE;
 }
-#endif  /* HAVE_ZLIB_H */
 
 /*
 FUNCTION
@@ -152,12 +147,10 @@  bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
 {
   bfd_size_type sz;
   bfd_byte *p = *ptr;
-#ifdef HAVE_ZLIB_H
   bfd_boolean ret;
   bfd_size_type save_size;
   bfd_size_type save_rawsize;
   bfd_byte *compressed_buffer;
-#endif
 
   if (abfd->direction != write_direction && sec->rawsize != 0)
     sz = sec->rawsize;
@@ -189,10 +182,6 @@  bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
       return TRUE;
 
     case DECOMPRESS_SECTION_SIZED:
-#ifndef HAVE_ZLIB_H
-      bfd_set_error (bfd_error_invalid_operation);
-      return FALSE;
-#else
       /* Read in the full compressed section contents.  */
       compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
       if (compressed_buffer == NULL)
@@ -232,7 +221,6 @@  bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
       free (compressed_buffer);
       *ptr = p;
       return TRUE;
-#endif
 
     case COMPRESS_SECTION_DONE:
       if (sec->contents == NULL)
@@ -337,13 +325,8 @@  DESCRIPTION
 */
 
 bfd_boolean
-bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED,
-				    sec_ptr sec ATTRIBUTE_UNUSED)
+bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
 {
-#ifndef HAVE_ZLIB_H
-  bfd_set_error (bfd_error_invalid_operation);
-  return FALSE;
-#else
   bfd_byte compressed_buffer [12];
   bfd_size_type uncompressed_size;
 
@@ -378,7 +361,6 @@  bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED,
   sec->compress_status = DECOMPRESS_SECTION_SIZED;
 
   return TRUE;
-#endif
 }
 
 /*
@@ -399,13 +381,8 @@  DESCRIPTION
 */
 
 bfd_boolean
-bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED,
-				  sec_ptr sec ATTRIBUTE_UNUSED)
+bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
 {
-#ifndef HAVE_ZLIB_H
-  bfd_set_error (bfd_error_invalid_operation);
-  return FALSE;
-#else
   bfd_size_type uncompressed_size;
   bfd_byte *uncompressed_buffer;
   bfd_boolean ret;
@@ -433,5 +410,4 @@  bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED,
 					 uncompressed_size);
 
   return ret;
-#endif
 }
diff --git a/bfd/config.in b/bfd/config.in
index 96a3e74..1ee1081 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -271,9 +271,6 @@ 
 /* Define to 1 if you have the <windows.h> header file. */
 #undef HAVE_WINDOWS_H
 
-/* Define to 1 if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
diff --git a/bfd/configure b/bfd/configure
index a328813..b8f1b2b 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -620,6 +620,8 @@  SHARED_LDFLAGS
 LIBM
 COREFLAG
 COREFILE
+zlibinc
+zlibdir
 EXEEXT_FOR_BUILD
 CC_FOR_BUILD
 BFD_HOSTPTR_T
@@ -797,7 +799,7 @@  enable_build_warnings
 enable_maintainer_mode
 enable_install_libbfd
 enable_nls
-with_zlib
+with_system_zlib
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1463,7 +1465,7 @@  Optional Packages:
   --with-pkgversion=PKG   Use PKG in the version string in place of "GNU
                           Binutils"
   --with-bugurl=URL       Direct users to URL to report a bug
-  --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-system-zlib      use installed libz
 
 Some influential environment variables:
   CC          C compiler command
@@ -11421,7 +11423,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11424 "configure"
+#line 11426 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11527,7 +11529,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11530 "configure"
+#line 11532 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13851,91 +13853,18 @@  cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-# Link in zlib if we can.  This allows us to read compressed debug sections.
-# This is used only by compress.c.
+# Use the system's zlib library.
+zlibdir=-L../zlib
+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; zlibdir=
+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
 
 
 # If we are configured native, pick a core file support file.
diff --git a/bfd/configure.ac b/bfd/configure.ac
index a1b2035..5426781 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -236,9 +236,16 @@  AC_CHECK_DECLS(snprintf)
 AC_CHECK_DECLS(vsnprintf)
 AC_CHECK_DECLS(strnlen)
 
-# Link in zlib if we can.  This allows us to read compressed debug sections.
-# This is used only by compress.c.
-AM_ZLIB
+# Use the system's zlib library.
+zlibdir=-L../zlib
+zlibinc="-I\$(srcdir)/../zlib"
+AC_ARG_WITH(system-zlib,
+[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
+zlibdir=
+zlibinc=
+)
+AC_SUBST(zlibdir)
+AC_SUBST(zlibinc)
 
 # If we are configured native, pick a core file support file.
 COREFILE=
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index 72099f1..6038113 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -75,8 +75,8 @@  am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
 	$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \
-	$(top_srcdir)/version.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/version.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
@@ -289,6 +289,8 @@  top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 wordsize = @wordsize@
+zlibdir = @zlibdir@
+zlibinc = @zlibinc@
 AUTOMAKE_OPTIONS = 1.9 cygnus
 DOCFILES = aoutx.texi  archive.texi archures.texi \
 	bfdt.texi  cache.texi coffcode.texi \