diff options
author | David Mitchell <davem@iabyn.com> | 2016-03-08 11:31:22 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-03-18 23:48:15 +0000 |
commit | efc4bddfd4d47b3da29e913dc3f9196023f1d421 (patch) | |
tree | 0eb20ba977c20446b052de5d43f1e479e4549912 /ext | |
parent | 98d35ab7c5b2ec87369ebf4a88451247d2169d08 (diff) | |
download | perl-efc4bddfd4d47b3da29e913dc3f9196023f1d421.tar.gz |
fix up dtrace compile/link for Solaris
[perl #127543]
On some platforms, the use of dtrace / SystemTap requires generating an
extra .o file from a list of .o files before linking. For example,
cc -o foo a.o b.o c.o
has to be replaced with
dtrace -G -s dtrace.d -o dtrace.o a.o b.o c.o # creates dtrace.o
cc -o foo dtrace.o a.o b.o c.o
On Solaris in particular, "dtrace -G" modifies the *.o files that it's
passed as well as creating dtrace.o, and all the new/updated .o files need
to be linked together at the same time from the same single use of "dtrace
-G".
This complicates matters when building all of miniperl, libperl and perl,
and the reason for this commit is that once a dtrace probe made its way
into an inline static function via the recent context work, Solaris
stopped building under -Dusedtrace -Duseshrplib.
The fix that seems to work under both Solaris and Linux, for all
4 permutations of -Dusedtrace +/- -Duseshrplib, is (approx):
# compile all the *.o's, then:
# build miniperl:
$ dtrace ... -o dtrace_mini.o a.o b.o c.o perlminimain.o
$ cc -o miniperl dtrace_mini.o a.o b.o c.o perlminimain.o
# build libperl.a or .so:
$ dtrace ... -o dtrace_perllib.o a.o b.o c.o
$ ar rcu libperl.a dtrace_perllib.o a.o b.o c.o
# build perl:
$ dtrace ... -o dtrace_main.o perlmain.o
$ cc -o perl dtrace_main.o -lperl
This is has only recently arisen because we switched from PUSHSUB()
etc macros to S_cx_pushsub() etc inline functions, which contain
probes. Since the inline static functions, and hence the probes, are now
included in every source file, and since Solaris isn't smart enough to
remove inline static fns that aren't used in a particular compilation
unit, the probes end up getting used in every source file (at least where
PERL_CORE is true).
It also required fixing up XS-APItest's Makefile.PL, since one object
file is compiled using PERL_CORE.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/XS-APItest/Makefile.PL | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ext/XS-APItest/Makefile.PL b/ext/XS-APItest/Makefile.PL index 173e5c97c5..5b4d100659 100644 --- a/ext/XS-APItest/Makefile.PL +++ b/ext/XS-APItest/Makefile.PL @@ -3,6 +3,8 @@ use ExtUtils::MakeMaker; use ExtUtils::Constant 0.11 'WriteConstants'; use Config; +my $dtrace_o = $Config{dtraceobject} ? ' dtrace$(OBJ_EXT)' : ''; + WriteMakefile( 'NAME' => 'XS::APItest', 'VERSION_FROM' => 'APItest.pm', # finds $VERSION @@ -10,7 +12,7 @@ WriteMakefile( ABSTRACT_FROM => 'APItest.pm', # retrieve abstract from module AUTHOR => 'Tim Jenness <t.jenness@jach.hawaii.edu>, Christian Soeller <csoelle@mph.auckland.ac.nz>, Hugo van der Sanden <hv@crypt.compulink.co.uk>, Andrew Main (Zefram) <zefram@fysh.org>', 'C' => ['exception.c', 'core.c', 'notcore.c'], - 'OBJECT' => '$(BASEEXT)$(OBJ_EXT) XSUB-undef-XS_VERSION$(OBJ_EXT) XSUB-redefined-macros$(OBJ_EXT) $(O_FILES)', + 'OBJECT' => '$(BASEEXT)$(OBJ_EXT) XSUB-undef-XS_VERSION$(OBJ_EXT) XSUB-redefined-macros$(OBJ_EXT) $(O_FILES)'. $dtrace_o, realclean => {FILES => 'const-c.inc const-xs.inc'}, ($Config{gccversion} && $Config{d_attribute_deprecated} ? (CCFLAGS => $Config{ccflags} . ' -Wno-deprecated-declarations') : ()), @@ -40,3 +42,24 @@ WriteConstants( ); sub MY::install { "install ::\n" }; + + +sub MY::postamble +{ + package MY; + my $post = shift->SUPER::postamble(@_); + use Config; + return $post unless $Config{dtraceobject}; + + # core.o is build using PERL_CORE, so picks up any dtrace probes + + $post .= <<POSTAMBLE; + +DTRACE_D = ../../perldtrace.d + +dtrace\$(OBJ_EXT): \$(DTRACE_D) core\$(OBJ_EXT) + $Config{dtrace} -G -s \$(DTRACE_D) -o dtrace\$(OBJ_EXT) core\$(OBJ_EXT) +POSTAMBLE + + return $post; +} |