diff options
author | Eric Wong <mwrap-perl@80x24.org> | 2022-09-04 07:44:41 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-09-15 17:39:01 +0000 |
commit | 5b3ff6f67c97a77809072065e4cafe544609922c (patch) | |
tree | c5c03dc8d56c3255a9f291f547844997df2fd880 | |
parent | e701ba4399d3ed2c71d3bff0af285011b3c301d5 (diff) | |
download | mwrap-5b3ff6f67c97a77809072065e4cafe544609922c.tar.gz |
This is required for it to work reliably in FreeBSD if we hit a code path which calls backtrace_symbols before BOOT:. This will allow the next commit to setup `totals' rculfhash earlier in the constructor, rather than BOOT, allowing allocations to be tracked as early as possible.
-rw-r--r-- | Makefile.PL | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Makefile.PL b/Makefile.PL index c3caf6c..7ea7929 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -32,6 +32,37 @@ END chomp(my $INC = `$pkg_config --cflags liburcu-cds liburcu-bp`); my @writemakefile_args = (); +use IO::Handle; +STDOUT->autoflush(1); +require ExtUtils::CBuilder; +require File::Temp; +my $cb = ExtUtils::CBuilder->new(quiet => $ENV{V} ? 0 : 1); +my $d = File::Temp->newdir('mwrap-perl-build-XXXX'); +my $olderr; +print '# checking for -lexecinfo... '; +{ + use autodie; + open my $fh, '>', "$d/execinfo.c"; + print $fh <<EOM; +#include <execinfo.h> +int main(void) { return backtrace_symbols ? 1 : 0; } +EOM + close $fh; + open $olderr, '+>&', *STDERR{IO}; + open STDERR, '>', "$d/err.log"; +} +eval { + my $obj = $cb->compile(source => "$d/execinfo.c"); + $cb->link(objects => $obj, extra_linker_flags => '-lexecinfo'); + $LIBS .= ' -lexecinfo'; + say " yes on $^O"; +}; +say " no on $^O" if $@; +{ + use autodie; + open STDERR, '+>&', $olderr or die "dup stderr: $!"; +} + # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. push @writemakefile_args, ( |