develooper Front page | perl.perl5.porters | Postings from February 2016

[perl #127543] dtrace/-DDEBUGGING builds now fail on Solaris

Thread Next
From:
Tony Cook via RT
Date:
February 29, 2016 08:14
Subject:
[perl #127543] dtrace/-DDEBUGGING builds now fail on Solaris
Message ID:
rt-4.0.18-19092-1456733652-416.127543-15-0@perl.org
On Tue Feb 23 06:45:43 2016, davem wrote:
> 
> I now have a simple standalone example of this failure:
> 
> With these source files:
> 
>     ==> dtrace.d <==
>     provider foo { probe bar(int); };
> 
>     ==> inline.h <==
>     #include "dtrace.h"
>     static void f1() { FOO_BAR(0); }
> 
>     ==> a.c <==
>     #include "inline.h"
>     void f2() { }
> 
>     ==> main.c <==
>     #include "inline.h"
>     int main(int argc, char**argv) { return 0; }
> 
>     ==> build <==
>     #!/bin/sh
>     CC=/opt/solarisstudio12.3/bin/cc
>     set -xe
>     dtrace -h -s dtrace.d -o dtrace.h
>     $CC -c -O -g -KPIC a.c
>     $CC -c -O -g -KPIC main.c
>     dtrace -G -s dtrace.d -o dtrace.o  a.o main.o
>     $CC -o liba.so -G a.o dtrace.o
>     $CC -o main main.o liba.so
>     #$CC -o main main.o a.o dtrace.o  # this works
>     LD_LIBRARY_PATH=. ./main
> 
> running ./build gives:
> 
>     ld.so.1: main: fatal: relocation error: file ./liba.so: symbol
>     $dtrace5277462.f1: referenced symbol not found
> 
> Looking at symbol tables:
> 
> $ for i in *.o *.so main; do echo $i; nm $i | grep '$dtrace'; done
> a.o
> [23]    |        16|        38|FUNC |GLOB |6    |2      |$dtrace5277444.f1
> dtrace.o
> [46]    |         0|         0|FUNC |GLOB |0    |UNDEF  |$dtrace5277444.f1
> [47]    |         0|         0|FUNC |GLOB |0    |UNDEF  |$dtrace5277462.f1
> main.o
> [25]    |        16|        38|FUNC |GLOB |6    |2      |$dtrace5277462.f1
> liba.so
> [61]    |         0|         0|FUNC |GLOB |0    |UNDEF  |$dtrace5277462.f1
> main
> 
> replacing the dynamic link of main in build with
>     $CC -o main main.o a.o dtrace.o  # this works
> works. 'nm main' still doesn't show any $dtrace symbols.
> 
> Note that the failure doesn't reply on the equivalent of -DDEBUGGING being
> enabled; nor does it require the static function to be "too big".

The "too big" is in reference to inline functions, your f1() is always static, so the compiler always includes it in the object (though it would be nice if it discarded the unused static function instead.)

Solaris is using "static inline":

tony@nereid:~/dev/perl/git/perl$ grep static_inline config.sh
d_static_inline='define'
perl_static_inline='static inline'

So my theory was that the extra asserts made S_cx_pushsub() and S_cx_popsub() too large for them to be inlined, so they were built as static per your example.

> What seems to happen is that going from main.o to main loses the
> $dtrace5277462.f1, so the undef $dtrace5277462.f1 in liba.so can't
> subsequently be resolved. Perhaps there's something extra that needs to be
> done when building 'main'?
> 
> I'm a bit stumped at this point.

Unfortunately Oracle's documentation of the how linking and dtrace work is very limited, all I'm aware of is:

http://docs.oracle.com/cd/E19253-01/817-6223/chp-usdt-2/index.html

which doesn't discuss the mechanisms.

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=127543

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About