[erlang-patches] Patch to fix compilation on OpenIndiana

Trond Norbye trond.norbye@REDACTED
Tue Jun 14 14:48:04 CEST 2011


On 10. juni 2011, at 15.20, Raimo Niskanen wrote:

> Hi - an update.
> 
> We can not use the patch as it is today since it causes
> a build error on Solaris 10; uname -a:
> SunOS fenris 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V245
> 
> Seems to be a library yet to find by configure...
> 

According to the manual page for dlpi_open, you should build your program using dlpi with the following command line:

cc [ flag ... ] file ... -ldlpi [ library ... ]

During configure I'm trying to detect dlpi_open in libdlpi, so we're instructing configure to compile the following program:

 char dlpi_open ();
 int
 main ()
 {
 return dlpi_open ();
 }

When I try to build this with the Solaris Studio compiler with "cc a.c -ldlpi" everything work as expected, but when I try to run the same with gcc I'm getting:

trond@REDACTED:2004> /opt/gcc/bin/gcc a.c -ldlpi
ld: warning: file libdladm.so.1: required by /usr/lib/libdlpi.so, not found
Undefined                       first referenced
 symbol                             in file
dladm_close                         /usr/lib/libdlpi.so
dladm_dev2linkid                    /usr/lib/libdlpi.so
dladm_phys_info                     /usr/lib/libdlpi.so
dladm_walk                          /usr/lib/libdlpi.so
dladm_open                          /usr/lib/libdlpi.so
dladm_parselink                     /usr/lib/libdlpi.so
ld: fatal: symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

If you look at the output from configure you'll see this with:

checking for libdlpi.h... yes
[ ... cut ...]
checking for dlpi_open in -ldlpi... no

If you look at /usr/lib/libdlpi.so with "dump -Lv", you'll see that it needs:
trond@REDACTED:2010> dump -Lv /usr/lib/libdlpi.so.1

/usr/lib/libdlpi.so.1:

  **** DYNAMIC SECTION INFORMATION ****
.dynamic:
[INDEX] Tag         Value
[1]     NEEDED          libc.so.1
[2]     POSFLAG_1       LAZYLOAD
[3]     NEEDED          libinetutil.so.1
[4]     POSFLAG_1       LAZYLOAD
[5]     NEEDED          libdladm.so.1

From looking at the arguments gcc and cc sends to the linker (both use the one in /usr/ccs/bin), gcc don't add /lib.

On my System I see that they try to set up the following search paths for  the linker:
gcc: -Y P,/usr/ccs/lib:/usr/lib 
cc: -Y P,/opt/solstudio12.2/prod/lib:/usr/ccs/lib:/lib:/usr/lib

To me it looks like gcc ignores the run path on the system when it tries to unroll all of the nested dependencies (but I have not checked the source code for gcc or Solaris studio to see how they determine the path or if it is hardcoded ;)). Most of the libraries on the system is installed in both /usr/lib and /lib, but libdladm.so.1 is only installed in /lib. That _shouldn't_ be a problem, because /lib is part of the default runtime path (you may verify this by running crle:

Default configuration file (/var/ld/ld.config) not found
  Platform:     32-bit LSB 80386
  Default Library Path (ELF):   /lib:/usr/lib  (system default)
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

)

I would _guess_ that libdladm.so is just a "helper library" for the operating system, because _none_ of the functions it exports are documented...

To work around the problem you need to tell gcc (with friends) to search for libraries in /lib as well.. The easiest way is probably to set LD_LIBRARY_PATH=/lib, or create a symbolic link to /lib/libdladm.so.1 from /usr/lib (or perhaps use -L/lib in LDFLAGS?)

Trond


> Make log ending:
> 00350: gcc -o /ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/bin/sparc-sun-solaris2.10/beam.smp \
> 00351: 	 -m64   obj/sparc-sun-solaris2.10/opt/smp/erl_main.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/preload.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_pbifs.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/benchmark.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_alloc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_mtrace.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_alloc_util.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_goodfit_alloc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bestfit_alloc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_afit_alloc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_instrument.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_init.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_atom_table.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_table.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_ddll.o   \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_guard.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_info.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_op.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_os.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_lists.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_trace.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_wrap.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_trace.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/copy.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/utils.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/bif.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/io.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_printf_term.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_debug.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_md5.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_message.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_process.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_process_dict.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_process_lock.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_port_task.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_arith.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/time.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_time_sup.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/external.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/dist.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/binary.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_db.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_db_util.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_db_hash.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_db_tree.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/fix_alloc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/big.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/hash.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/index.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/atom.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/module.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/export.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/register.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/break.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_async.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_lock_check.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_gc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_lock_count.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_nmgc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_posix_str.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bits.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_math.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_fun.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_port.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_term.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_node_tables.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_monitors.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_process_dump.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_timer.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_cpu_topology.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_drv_thread.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_chksum.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_re.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_unicode.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/packet_parser.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/safe_hash.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_zlib.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_nif.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_bif_binary.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_emu.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_opcodes.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_load.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_bif_load.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_debug.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_bp.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/beam_catches.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/sys.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/driver_tab.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/unix_efile.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/gzio.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/elib_memmove.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/sys_float.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/sys_time.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_poll.kp.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_check_io.kp.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_poll.nkp.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_check_io.nkp.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_mseg.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_unix_sys_ddll.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_mtrace_sys_wrap.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/erl_sys_common_misc.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/efile_drv.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/inet_drv.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/zlib_drv.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/ram_file_drv.o \
> 	obj/sparc-sun-solaris2.10/opt/smp/ttsl_drv.o \
> 	-ldl -lm -lsocket -lnsl -lcurses -L../lib/internal/sparc-sun-solaris2.10 -lkstat \
> 	/ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/erts/emulator/zlib/obj/sparc-sun-solaris2.10/opt/libz.a \
> 	/ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/erts/emulator/pcre/obj/sparc-sun-solaris2.10/opt/libepcre.a \
> 	-lethread -lerts_internal_r -lpthread -lkstat -lrt
> 00352: Undefined			first referenced
> 00353:  symbol  			    in file
> 00354: dlpi_info                           obj/sparc-sun-solaris2.10/opt/smp/inet_drv.o
> 00355: dlpi_open                           obj/sparc-sun-solaris2.10/opt/smp/inet_drv.o
> 00356: dlpi_get_physaddr                   obj/sparc-sun-solaris2.10/opt/smp/inet_drv.o
> 00357: dlpi_close                          obj/sparc-sun-solaris2.10/opt/smp/inet_drv.o
> 00358: ld: fatal: Symbol referencing errors. No output written to /ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/bin/sparc-sun-solaris2.10/beam.smp
> 00359: collect2: ld returned 1 exit status
> 00360: gmake[3]: *** [/ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/bin/sparc-sun-solaris2.10/beam.smp] Error 1
> 00361: gmake[3]: Leaving directory `/ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/erts/emulator'
> 00362: gmake[2]: *** [opt] Error 2
> 00363: gmake[2]: Leaving directory `/ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/erts/emulator'
> 00364: gmake[1]: *** [smp] Error 2
> 00365: gmake[1]: Leaving directory `/ldisk/daily_build/r14b04_opu_o.2011-06-09_20/otp_src_R14B04/erts'
> 00366: gmake: *** [emulator] Error 2
> 
> 
> 
> On Fri, May 06, 2011 at 11:22:48AM +0200, Henrik Nord wrote:
>> Hi Trond!
>> Here is a more detailed review of the patch
>> 
>> 
>> On 05/06/2011 11:10 AM, Raimo Niskanen wrote:
>> 
>> We want the functionality, but we have just deprecated (at least
>> disrecommended) inet:getiflist/0 and inet:ifget/2. This functionality
>> should go into inet:getifaddrs/0, but there it will be harder to fit it in.
>> 
>> We might accept this patch (despite improving a deprecated interface)
>> to keep as a coding example for later improving inet:getifaddrs/0
>> (but would of course prefer to get it right from the start) if
>> the test inet_SUITE:getif/1, function do_getif/1 that checks if
>> os:type/0 returns {unix,sunos} and if so does not check for a hardware
>> address covers this operating system. The test has to be narrowed so it
>> checks for hardware address when the patch is supposed to work.
>> I guess os:version() can tell if this is openindiana...
>> 
>> -- 
>> /Henrik Nord Erlang/OTP
>> 
>> _______________________________________________
>> erlang-patches mailing list
>> erlang-patches@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-patches
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB




More information about the erlang-patches mailing list