Bug #7279

Zlib load error on HP-UX

Added by Alex Harvey over 1 year ago. Updated about 1 year ago.

Assignee:Nobuyoshi Nakada
Target version:next minor
ruby -v:ruby 1.8.7 (2012-06-29 patchlevel 370) [hppa2.0w-hpux11.11] Backport:


This was apparently a known issue on HP-UX and it is preventing me from compiling zlib

To reproduce -



gcc 4.2.3 gcc
libgcc 4.2.3 libgcc
m4 1.4.16 m4
make 3.82 make

/usr/local/bin/ruby extconf.rb --with-zlib-include=/usr/local/include --with-zlib-lib=/usr/local/lib

checking for deflateReset() in -lz... no
checking for deflateReset() in -llibz... no
checking for deflateReset() in -lzlib1... no
checking for deflateReset() in -lzlib... no
checking for deflateReset() in -lzdll... no

file /usr/local/lib/libz.sl

/usr/local/lib/libz.sl: PA-RISC1.1 shared library

file /usr/local/include/zlib.h

/usr/local/include/zlib.h: c program text

I have attached the mkmf.log.

mkmf.log (5.47 KB) Alex Harvey, 11/05/2012 09:51 PM

bug-7279.diff Magnifier (730 Bytes) Nobuyoshi Nakada, 01/28/2013 05:17 PM

Related issues

Duplicated by ruby-trunk - Bug #7737: problem with generated rbconfig.rb for Haiku Closed 01/23/2013


#1 Updated by Alex Harvey over 1 year ago

I found a workaround.

There is some documentation of HP-UX PA-RISC compiler here

(There's probably a better one somewhere but that's the one I used.)

The +b option is used by the linker to embed a library path list in the executable for use at run time. However, if passing these options via CC or GCC then the option should be -Wl,+b. The mkmf.log file shows, however, that an unknown option +b is being passed directly to gcc.

After running configure I made the following change in config.status -

mv config.status config.status.orig
sed -e 's/^.*RPATHFLAG.*$/S["RPATHFLAG"]=" -Wl,+b%1$-s"/' config.status.orig >config.status
chmod +x config.status

This results in /usr/local/lib/ruby/1.8/hppa2.0w-hpux11.11/rbconfig.rb having

# grep RPATHFLAG /usr/local/lib/ruby/1.8/hppa2.0w-hpux11.11/rbconfig.rb
  CONFIG["RPATHFLAG"] = " -Wl,+b%1$-s"

However, the make step still doesn't run properly because now -Wl,+b gets passed to ld, which is also wrong.

Thus after the make step has finished I made another change -

cd ext/zlib
mv Makefile Makefile.orig
sed -e 's#^LIBPATH.*$#LIBPATH =  -L. -L$(topdir) -L/usr/local/lib +b/usr/local/lib#' Makefile.orig >Makefile
cd ../..

That works fine. Then cd ../.. and make install and the zlib extension is installed.

Someone who understands how all this stuff works better than I do can hopefully turn this into an actual patch.

#2 Updated by Nobuyoshi Nakada about 1 year ago

  • Project changed from Ruby 1.8 to ruby-trunk
  • Status changed from Open to Feedback
  • Assignee set to Nobuyoshi Nakada

Could you try this patch?

diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index c9e738a..fe6f771 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -317,9 +317,9 @@ def linkcommand(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
- 'LIBPATH' => libpathflag(libpath),
LIBS' => "#$LOCALLIBS #$libs",
STATIC #{opt} #$LIBS")
+ conf['LIBPATH'] = libpath.map {|s| LIBPATHFLAG % RbConfig::expand(s.dup, conf).quote}.join("")
Config::expand(TRY_LINK.dup, conf)

#3 Updated by Nobuyoshi Nakada about 1 year ago

  • File bug-7279.diffMagnifier added
  • Category set to build
  • Target version set to 2.0.0

#4 Updated by Yusuke Endoh about 1 year ago

  • Target version changed from 2.0.0 to next minor

#5 Updated by Alex Harvey about 1 year ago

Hi Nobuyoshi,

Yes the patch works.

For people viewing this in the archives, it's worth knowing that patch and diff are different on HP-UX. To apply this patch -

cp -p lib/mkmf.rb lib/mkmf.rb.orig
cat <<'EOF' >mkmf.hpux.patch

*** lib/mkmf.rb.orig Sat Dec 4 17:34:10 2010
--- lib/mkmf.rb Wed Feb 13 16:29:18 2013

*** 317,325 ****
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
- 'LIBPATH' => libpathflag(libpath),
'LOCALLIBS' => "#$LOCALLIBS #$libs",
LINK.dup, conf)

--- 317,325 ----
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
'LOCALLIBS' => "#$LOCALLIBS #$libs",
+ conf['LIBPATH'] = libpath.map {|s| LIBPATHFLAG % RbConfig::expand(s.dup, conf).quote}.join("")
LINK.dup, conf)
patch lib/mkmf.rb <mkmf.hpux.patch

Also available in: Atom PDF