Operating System - HP-UX
1748031 Members
5265 Online
108757 Solutions
New Discussion

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

 
SOLVED
Go to solution
Carla_C
Visitor

Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B3910B A

I set my env as:

PATH=$PATH:"/opt/aCC/bin"; export PATH
SHLIB_PATH=$SHLIB_PATH:`cat /etc/SHLIB_PATH`; export SHLIB_PATH
CC=cc; export CC
CFLAGS="+O2 -D_XOPEN_SOURCE_EXTENDED"; export CFLAGS

I ran configure as:
./configure  --without-gmp --enable-load-relative --prefix=/opt/oracle/puppetlabs

I edited the resulting Makefile only to echo the link line (since it only writes "linking miniruby" which isn't much help),

and ran it as:
make

and got this:
$ make
CC = cc
LD = ld
LDSHARED = ld -b
CFLAGS = +O2 -D_XOPEN_SOURCE_EXTENDED
XCFLAGS = -DRUBY_EXPORT
CPPFLAGS = -I. -I.ext/include/ia64-hpux11.31 -I./include -I.
DLDFLAGS = -E -Wl,-E
SOLIBS =
linking miniruby
@ cc +O2 -D_XOPEN_SOURCE_EXTENDED -L. -Wl,-E main.o dmydln.o miniinit.o miniprelude.o array.o bignum.o class.o compar.o complex.o dir.o dln_find.o encoding.o enum.o enumerator.o error.o eval.o load.o proc.o file.o gc.o hash.o inits.o io.o marshal.o math.o node.o numeric.o object.o pack.o parse.o process.o random.o range.o rational.o re.o regcomp.o regenc.o regerror.o regexec.o regparse.o regsyntax.o ruby.o safe.o signal.o sprintf.o st.o strftime.o string.o struct.o time.o transcode.o util.o variable.o version.o compile.o debug.o iseq.o vm.o vm_dump.o vm_backtrace.o vm_trace.o thread.o cont.o ascii.o us_ascii.o unicode.o utf_8.o newline.o isinf.o strlcpy.o strlcat.o setproctitle.o ia64.o addr2line.o dmyext.o -lpthread -ldld -ldl -lm -o miniruby
ld: Unsatisfied hidden symbol "__milli_clz". Symbol was referenced from file bignum.o
ld: Unsatisfied hidden symbol "__milli_clz". Symbol was referenced from file numeric.o
2 errors.
*** Error exit code 1

Stop.

Any help, suggestions, ideas, or solutions are appreciated. 
I am open to using different compiler versions and/or OS versions, if that would fix my link problem.
I have been unable to discover where __milli_clz is (or should be) defined.

Thank you,
Carla Curtis

7 REPLIES 7
ranganath ramachandra
Esteemed Contributor

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

Looks like a bug in the compiler package. A quick fix could be to modify the configure script:

18056c18056,18057
< __builtin_clz(0);
---
>   int r1 = 0;
> __builtin_clz(r1);

The call to "__builtin_clz" from nlz_int in internal.h is replaced by a call to "__milli_clz" by the compiler. This is expected to be resolved at link time by a definition in /usr/lib/hpux32/milli.a (silently added by the linker) but the definition is missing. During configure, the call to __builtin_clz with 0 is optimized out and hence the link error is not seen. so you get a conf.h with

#define HAVE_BUILTIN___BUILTIN_CLZ 1
#define HAVE_BUILTIN___BUILTIN_CLZL 1
#define HAVE_BUILTIN___BUILTIN_CLZLL 1

This is avoided when the 0 is replaced by a variable. The new configure script would now use the following code to test support for __builtin_clz:

int
main ()
{
  int r1 = 0;
__builtin_clz(r1);
  ;
  return 0;
}

This program will reproduce the link failure and can serve as the case to file a compiler bug.

BTW in my build attempt, while miniruby got linked, it crashed with a SEGV_MAPERR ...

Core was generated by `miniruby'.
Program terminated with signal 11, Segmentation fault.
SEGV_MAPERR - Address not mapped to object
#0  mark_locations_array () at gc.c:3298
3298            gc_mark_maybe(objspace, v);
(gdb) x/i $pc
0x419ecc0:0 <mark_locations_array+0x70>:
          ld4              r44=[r33],r38                                     MMI
(gdb) p/x $r33
$1 = 0x1000
 
--
ranga
[i work for hpe]

Accept or Kudo

ranganath ramachandra
Esteemed Contributor
Solution

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

PHSS_42981 delivers the milli.a with definitions for the __millli_clz* routines. You could try a build with that patch installed.

 
--
ranga
[i work for hpe]

Accept or Kudo

Carla_C
Visitor

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

Thank you for the quick response, Ranganath!
I will try the patch on my box today, and let you know the results.

Thanks,

Carla

Carla_C
Visitor

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

Quick update, I'm waiting on sysadmin help, on my end, to download the patch.
I don't have download access on HP's patch site.  Tnx.

Carla_C
Visitor

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

The patch is installed, and I was able to build miniruby without the symbol errors.  So I think this thread can be closed.

I'll add, that miniruby crashes on startup - looks like it's doing its own memory management here.
This doesn't seem related to the symbol errors, so I"m not expecting someone to pop up with an answer. 
But I wanted to share where I'm at, because I had started debugging and realized I needed to follow up, here, first.

Debugger says:
(gdb) where
#0  mark_locations_array () at gc.c:3298
#1  0x41a0d00:0 in mark_current_machine_context () at gc.c:3311
#2  0x419f8e0:0 in gc_mark_roots () at gc.c:3610
#3  0x419c540:0 in gc_marks_body () at gc.c:4157
#4  0x419c350:0 in gc_marks () at gc.c:4510
#5  0x419bd60:0 in garbage_collect_body () at gc.c:5024
#6  0x43186a0:0 in heap_prepare_freepage () at gc.c:1189
#7  0x4318490:0 in heap_get_freeobj () at gc.c:1237
#8  0x4172430:0 in newobj_of () at gc.c:1303
#9  0x4172310:0 in rb_newobj_of () at gc.c:1356
#10 0x42909a0:0 in rb_hash_new () at hash.c:309
#11 0x4160c80:0 in Init_BareVM () at vm.c:2822
#12 0x41608f0:0 in ruby_init () at eval.c:54
#13 0x415fb10:0 in main () at main.c:35
(gdb) list
3293    mark_locations_array(rb_objspace_t *objspace, register VALUE *x, register long n)
3294    {
3295        VALUE v;
3296        while (n--) {
3297            v = *x;
3298            gc_mark_maybe(objspace, v);
3299            x++;
3300        }
3301    }
3302

I built with default options - next step is to enable debug symbols, turn off optimization, and see if I can figure out what's going on.

In any case, thanks for your help!

Carla

Carla_C
Visitor

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

Yep - same result.

ranganath ramachandra
Esteemed Contributor

Re: Unresolved symbol __milli_clz when building Ruby 2.1.9 on HP-UX B.11.31 using cc: HP C/aC++ B391

For that one, mark_locations_array needs a NULL check for x.

Next up, a SIGBUS around compile.c:1021 - new_callinfo; my guess is that the conditional definition of STRICT_ALIGNMENT needs to be extended to cover __ia64, somewhat like:

#if ((defined(__sparc) && defined(__GNUC__)) || (defined(__ia64)) && SIZEOF_VOIDP == 4)
  #define STRICT_ALIGNMENT
#endif

After this the build seems to fail because of LOAD_PATH not being set properly when calling miniruby to generate some intermediate stuff; if this is only happening on hp-ux, you could try a diff of the sources for the latest hp-ux (PA-RISC) port available at hpux.connectorg.uk with the corresponding version of upstream sources.

 
--
ranga
[i work for hpe]

Accept or Kudo