From 5b3ff6f67c97a77809072065e4cafe544609922c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 4 Sep 2022 07:44:41 +0000 Subject: Makefile.PL: check for execinfo on FreeBSD 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. --- Makefile.PL | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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 < +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, ( -- cgit v1.2.3-24-ge0c7