| 1 | # [[[ HEADER ]]] | ||
| 2 | package Perl::Inline; | ||
| 3 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | our $VERSION = 0.022_100; | ||
| 6 | |||
| 7 | # DEV NOTE, CORRELATION #rp503: can we safely ignore these warnings during Inline compile time? | ||
| 8 | # https://www.mail-archive.com/debian-bugs-rc@lists.debian.org/msg564229.html | ||
| 9 | # ... | ||
| 10 | # [[[ BEGIN 'use Inline' STAGE for 'Perl/HelperFunctions.cpp' ]]] | ||
| 11 | # validate Stage | ||
| 12 | # ... | ||
| 13 | # Starting Build Glue 3 Stage | ||
| 14 | # Finished Build Glue 3 Stage | ||
| 15 | # Starting Build Compile Stage | ||
| 16 | # Starting "perl Makefile.PL" Stage | ||
| 17 | # Have /usr/lib/x86_64-linux-gnu/perl-base | ||
| 18 | # Want /usr/lib/x86_64-linux-gnu/perl/5.30 | ||
| 19 | # Your perl and your Config.pm seem to have different ideas about the | ||
| 20 | # architecture they are running on. | ||
| 21 | # Perl thinks: [perl-base] | ||
| 22 | # Config says: [x86_64-linux-gnu-thread-multi] | ||
| 23 | # This may or may not cause problems. Please check your installation of perl | ||
| 24 | # if you have problems building this extension. | ||
| 25 | # Generating a Unix-style Makefile | ||
| 26 | # ... | ||
| 27 | |||
| 28 | #use Config; | ||
| 29 | 5 | ▶ | use English; # for $OSNAME |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | 5 | ▶ | use Perl::Config; # for $Perl::DEBUG |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | 5 | ▶ | use Alien::GMP; # prerequisite for Math::BigInt::GMP |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | 0 | ▶ | use Alien::GSL; # prerequisite for Math::GSL |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 33 | #use Alien::PCRE2; # for regex support # NEED DELETE, RPERL REFACTOR | ||
| 34 | #use Alien::JPCRE2; # for regex support # NEED DELETE, RPERL REFACTOR | ||
| 35 | use File::Spec; # for splitpath() and catpath() | ||
| 36 | use IPC::Cmd qw(can_run); | ||
| 37 | use IPC::Run3 qw(run3); | ||
| 38 | |||
| 39 | # DEV NOTE: all 'our' vars below utilized from Compiler.pm and/or generated *.pmc files | ||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | # MongoDB support | ||
| 44 | # NEED FIX: add Alien::PkgConfig & Alien::Mongo* dependencies; add error checking for missing pkg-config or bad return value | ||
| 45 | |||
| 46 | #our $mongodb_include_dir = File::Spec->catpath(q{}, q{FOO}, q{include}); # NOT USED, replaced by pkg-config at compile time as in Compiler.pm | ||
| 47 | |||
| 48 | my $pkgconfig_path = undef; | ||
| 49 | $pkgconfig_path = can_run('pkg-config'); | ||
| 50 | |||
| 51 | # NEED ENABLE: uncomment when Alien::PkgConfig dependency is added | ||
| 52 | #if ( not defined $pkgconfig_path ) { | ||
| 53 | # die 'ERROR xxxxxxx, yyy: Command `pkg-config` not found, dying' . "\n" ); | ||
| 54 | #} | ||
| 55 | |||
| 56 | my $mongodb_pkgconfig_command = $pkgconfig_path . ' --libs-only-L libmongocxx'; | ||
| 57 | my $mongodb_pkgconfig_command_stdout = q{}; | ||
| 58 | my $mongodb_pkgconfig_command_stderr = q{}; | ||
| 59 | run3( $mongodb_pkgconfig_command, \undef, \$mongodb_pkgconfig_command_stdout, \$mongodb_pkgconfig_command_stderr ); # disable STDIN w/ \undef | ||
| 60 | my $mongodb_pkgconfig_command_exit_status = $CHILD_ERROR >> 8; | ||
| 61 | |||
| 62 | #Perl::diag( 'in Perl::Inline, have $CHILD_ERROR = ' . $CHILD_ERROR . "\n" ); | ||
| 63 | #Perl::diag( 'in Perl::Inline, have $mongodb_pkgconfig_command_exit_status = ' . $mongodb_pkgconfig_command_exit_status . "\n" ); | ||
| 64 | |||
| 65 | # NEED ENABLE: uncomment when Alien::MongoDB* dependencies are added | ||
| 66 | #if ((defined $mongodb_pkgconfig_command_stderr) and ($mongodb_pkgconfig_command_stderr ne q{})) { | ||
| 67 | # die 'ERROR xxxxxxx, yyy: Command `' . $mongodb_pkgconfig_command . '` generated the following STDERR output when none was expected' . "\n\n" . $mongodb_pkgconfig_command . "\n\n" . 'dying' . "\n" ; | ||
| 68 | #} | ||
| 69 | #elsif ((not defined $mongodb_pkgconfig_command_stdout) or ($mongodb_pkgconfig_command_stdout eq q{})) { | ||
| 70 | # die 'ERROR xxxxxxx, yyy: Command `' . $mongodb_pkgconfig_command . '` generated no STDOUT output when the MongoDB C++ driver library path was expected, dying' . "\n" ; | ||
| 71 | #} | ||
| 72 | |||
| 73 | # Package libmongocxx was not found in the pkg-config search path. | ||
| 74 | # Perhaps you should add the directory containing `libmongocxx.pc' to the PKG_CONFIG_PATH environment variable | ||
| 75 | # No package 'libmongocxx' found | ||
| 76 | #our $mongodb_lib_dir = `pkg-config --libs-only-L libmongocxx`; # WRONG: causes uncontrolled STDERR output above & numerous false errors | ||
| 77 | our $mongodb_lib_dir = $mongodb_pkgconfig_command_stdout; | ||
| 78 | substr $mongodb_lib_dir, 0, 2, q{}; # trim leading '-L' | ||
| 79 | chomp $mongodb_lib_dir; # trim trailing newline | ||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | # GMP support | ||
| 85 | my $gmp_dir = Alien::GMP->dist_dir(); | ||
| 86 | our $gmp_include_dir = File::Spec->catpath(q{}, $gmp_dir, q{include}); | ||
| 87 | our $gmp_lib_dir = File::Spec->catpath(q{}, $gmp_dir, q{lib}); | ||
| 88 | #print {*STDERR} "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $gmp_dir = '}, $gmp_dir, q{'}, "\n\n"; | ||
| 89 | |||
| 90 | # GSL support | ||
| 91 | #my $gsl_dir = Alien::GSL->dist_dir(); | ||
| 92 | #print {*STDERR} "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $gsl_dir = '}, $gsl_dir, q{'}, "\n\n"; | ||
| 93 | #our $gsl_include_dir = File::Spec->catpath(q{}, $gsl_dir, q{include}); | ||
| 94 | #our $gsl_lib_dir = File::Spec->catpath(q{}, $gsl_dir, q{lib}); | ||
| 95 | |||
| 96 | # NEED DELETE, RPERL REFACTOR | ||
| 97 | # PCRE2 support | ||
| 98 | #my $pcre2_dir = Alien::PCRE2->dist_dir(); | ||
| 99 | #print {*STDERR} "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $pcre2_dir = '}, $pcre2_dir, q{'}, "\n\n"; | ||
| 100 | #our $pcre2_include_dir = File::Spec->catpath(q{}, $pcre2_dir, q{include}); | ||
| 101 | #my $pcre2_lib_dir = File::Spec->catpath(q{}, $pcre2_dir, q{lib}); | ||
| 102 | #print {*STDERR} "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $pcre2_include_dir = '}, $pcre2_include_dir, q{'}, "\n\n"; | ||
| 103 | |||
| 104 | # NEED DELETE, RPERL REFACTOR | ||
| 105 | # JPCRE2 support | ||
| 106 | #my $jpcre2_dir = Alien::JPCRE2->dist_dir(); | ||
| 107 | #print {*STDERR} "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $jpcre2_dir = '}, $jpcre2_dir, q{'}, "\n\n"; | ||
| 108 | #our $jpcre2_include_dir = File::Spec->catpath(q{}, $jpcre2_dir, q{include}); | ||
| 109 | #my $jpcre2_lib_dir = File::Spec->catpath(q{}, $jpcre2_dir, q{lib}); # NOT USED | ||
| 110 | #print {*STDERR} "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $jpcre2_include_dir = '}, $jpcre2_include_dir, q{'}, "\n\n"; | ||
| 111 | |||
| 112 | |||
| 113 | # long form | ||
| 114 | #use Inline CPP => config => classes => | ||
| 115 | #sub { | ||
| 116 | # my $class = shift; | ||
| 117 | # my @class_split = split('__', $class); | ||
| 118 | # my $class_join = join('::', @class_split); | ||
| 119 | # return($class_join); | ||
| 120 | #}; | ||
| 121 | |||
| 122 | # short form | ||
| 123 | #use Inline CPP => config => classes => sub { join('::', split('__', shift)); }; | ||
| 124 | |||
| 125 | # DEV NOTE, CORRELATION #rp011: replace -std=c++0x w/ -std=c++11 for std::string::pop_back() | ||
| 126 | # DEV NOTE: move ccflags outside %ARGS, make individual modules compose ccflags with possible cppflags right before calling Inline | ||
| 127 | #our $CCFLAGSEX = '-DNO_XSLOCKS -Wno-deprecated -std=c++0x -Wno-reserved-user-defined-literal -Wno-literal-suffix'; | ||
| 128 | #our $CCFLAGSEX = '-DNO_XSLOCKS -Wno-deprecated -std=c++11 -Wno-reserved-user-defined-literal -Wno-literal-suffix'; | ||
| 129 | # DEV NOTE: add -Wno-unused-variable to suppress warnings in GCC v4.9 | ||
| 130 | my $is_msvc_compiler = ($Config::Config{cc} =~ /cl/); | ||
| 131 | |||
| 132 | # NEED FIX INLINE: must disable -Wdelete-non-virtual-dtor warnings until Inline::C (or is it Inline::CPP?) destructor issue can be solved | ||
| 133 | # eval_XXXX_XXXX.c: In function ‘void XS_RPerl__CompileUnit__Module__Class__CPP_DESTROY(CV*)’: | ||
| 134 | # eval_XXXX_XXXX.c:yyyy:z: warning: deleting object of polymorphic class type ‘RPerl__CompileUnit__Module__Class__CPP’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor] | ||
| 135 | # delete THIS; | ||
| 136 | # ^ | ||
| 137 | |||
| 138 | our $CCFLAGSEX = $is_msvc_compiler ? '-DNO_XSLOCKS' | ||
| 139 | # : '-Wno-unused-variable -DNO_XSLOCKS -Wno-deprecated -std=c++11 -Wno-literal-suffix'; | ||
| 140 | : '-Wno-unused-variable -DNO_XSLOCKS -Wno-deprecated -std=c++11 -Wno-literal-suffix -Wall -Wextra -Wno-delete-non-virtual-dtor'; | ||
| 141 | |||
| 142 | # DEV NOTE: Perl v5.18 and older on Macintosh OS X requires -Wno-reserved-user-defined-literal to avoid error: | ||
| 143 | # "invalid suffix on literal; C++11 requires a space between literal and identifier" | ||
| 144 | #if (($OLD_PERL_VERSION <= 5.018000) and ($OSNAME eq 'darwin')) { # $OLD_PERL_VERSION introduced in Perl v5.20, $] is the non-English equivalent | ||
| 145 | if (($] <= 5.018000) and ($OSNAME eq 'darwin')) { | ||
| 146 | $CCFLAGSEX .= ' -Wno-reserved-user-defined-literal'; | ||
| 147 | } | ||
| 148 | |||
| 149 | # DEV NOTE, POSSIBLE ALTERNATIVE STRATEGY: '-L' . $Config{archlibexp} . '/CORE' | ||
| 150 | # for support of dynamic linking to libperl.so | ||
| 151 | if (defined $Config::Config{ccdlflags}) { | ||
| 152 | my $ccdlflags = $Config::Config{ccdlflags}; | ||
| 153 | |||
| 154 | # for testing paths containing space characters, for example somewhere in the '/home' directory, create a symlink '/ho\ me' which points to '/home', then use the debug code below | ||
| 155 | # ln -s /home /ho\ me | ||
| 156 | #$ccdlflags = '-Wl,-E -Wl,-rpath,/ho\ me/FOO/BAR/lib/perl5/5.22.1/x86_64-linux/CORE'; # TMP DEBUG | ||
| 157 | #print "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $ccdlflags = '}, $ccdlflags, q{'}, "\n\n"; | ||
| 158 | |||
| 159 | # subcompile dynamic linking flags, may include '-rpath' directory containing 'libperl.so'; if present, '-rpath' removes need for ldconfig; | ||
| 160 | # not enclosed by quotes, so leave backslash-escaped characters as-is | ||
| 161 | $CCFLAGSEX .= ' ' . $ccdlflags; | ||
| 162 | |||
| 163 | if ($ccdlflags =~ m/.*\-Wl,\-rpath,([\w\-\.\\\/](?:\\\ |[\w:\-\.\\\/])*)/gxms) { # find -Wl,rpath,/DIR_CONTAINING_libperl.so; allow backslash-escaped spaces | ||
| 164 | # if ($ccdlflags =~ m/.*\-Wl,\-rpath,([\w:\-\.\\\/]+)/gxms) { # find -Wl,rpath,/DIR_CONTAINING_libperl.so | ||
| 165 | my $libperl_lib_dir = $1; | ||
| 166 | if ($libperl_lib_dir =~ m/\\\ /gxms) { | ||
| 167 | $libperl_lib_dir =~ s/\\\ /\ /gxms; # replace backslash-escaped space with just space, for compatibility with double-quote enclosing -L"..." below | ||
| 168 | } | ||
| 169 | $CCFLAGSEX .= ' -L"' . $libperl_lib_dir . '"'; | ||
| 170 | #print "\n\n", q{<<< DEBUG >>> in Perl::Inline, have $libperl_lib_dir = '}, $libperl_lib_dir, q{'}, "\n\n"; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | # for regex support | ||
| 175 | #$CCFLAGSEX .= ' -L"' . $pcre2_lib_dir . '"'; # NEED DELETE, RPERL REFACTOR | ||
| 176 | |||
| 177 | my $optimize; | ||
| 178 | if ($is_msvc_compiler) { | ||
| 179 | $optimize = q{}; | ||
| 180 | } | ||
| 181 | # NEED FIX: NetBSD does not support -march=native switch for some reason, | ||
| 182 | # must wait until NetBSD OS devs fix this then test $Config::Config{osvers} to see if NetBSD is new enough to include fix | ||
| 183 | # error: bad value (native) for -march= switch | ||
| 184 | elsif ($Config::Config{osname} eq 'netbsd') { | ||
| 185 | $optimize = '-O3 -fomit-frame-pointer -g'; | ||
| 186 | } | ||
| 187 | else { | ||
| 188 | $optimize = '-O3 -fomit-frame-pointer -march=native -g'; | ||
| 189 | } | ||
| 190 | |||
| 191 | our %ARGS = ( | ||
| 192 | typemaps => "$Perl::INCLUDE_PATH/typemap.perl", | ||
| 193 | # disable default '-O2 -g' (or similar) from Perl core & Makemaker | ||
| 194 | optimize => $optimize, | ||
| 195 | |||
| 196 | # NEED UPGRADE: strip C++ incompat CFLAGS | ||
| 197 | # ccflags => $Config::Config{ccflags} . ' -DNO_XSLOCKS -Wno-deprecated -std=c++0x -Wno-reserved-user-defined-literal -Wno-literal-suffix', | ||
| 198 | # force_build => 1, # debug use only | ||
| 199 | # put . (current dir) last to avoid finding coincidentally-named file './foo' instead of '/SYSTEM/PATH/foo.h' from '#include <foo>' | ||
| 200 | # inc => '-I' . $Perl::INCLUDE_PATH . ' -Ilib -I' . $pcre2_include_dir . ' -I' . $jpcre2_include_dir . ' -I.', # NEED DELETE, RPERL REFACTOR | ||
| 201 | inc => '-I' . $Perl::INCLUDE_PATH . ' -Ilib -I.', | ||
| 202 | build_noisy => ( $ENV{PERL_DEBUG} or $Perl::DEBUG ), # suppress or display actual g++ compiler commands | ||
| 203 | clean_after_build => 0, # used by Inline::C(PP) to cache build, also used by Inline::Filters to save Filters*.c files for use in gdb debugging | ||
| 204 | warnings => (((not defined $ENV{PERL_WARNINGS}) or $ENV{PERL_WARNINGS}) and $Perl::WARNINGS), # suppress or display Inline warnings | ||
| 205 | filters => 'Preprocess', | ||
| 206 | auto_include => # DEV NOTE: include non-RPerl files using AUTO_INCLUDE so they are not parsed by the 'Preprocess' filter | ||
| 207 | [ | ||
| 208 | # DEV NOTE, CORRELATION #rp024: sync include files & other preprocessor directives in both Perl/Inline.pm and rperlstandalone.h | ||
| 209 | '#include <memory>', # smart pointers for memory management | ||
| 210 | '#include <iostream>', | ||
| 211 | '#include <string>', | ||
| 212 | '#include <sstream>', | ||
| 213 | '#include <limits>', | ||
| 214 | '#undef seed', # fix conflict between Perl's source/internal.h & libstdc++-dev's algorithm.h; 'error: macro "seed" passed 1 arguments, but takes just 0' | ||
| 215 | '#include <algorithm>', | ||
| 216 | '#include <vector>', | ||
| 217 | '#include <math.h>', | ||
| 218 | '#include <unordered_map>', # DEV NOTE: unordered_map may require '-std=c++0x' in CCFLAGS above | ||
| 219 | |||
| 220 | # NEED UPGRADE: only include when actually benchmarking | ||
| 221 | # benchmarking, for std::chrono::high_resolution_clock::now | ||
| 222 | '#include <ctime>', | ||
| 223 | '#include <ratio>', | ||
| 224 | '#include <chrono>', | ||
| 225 | |||
| 226 | # for regex support | ||
| 227 | # DEV NOTE, CORRELATION #rp024: sync include files & other preprocessor directives in both Perl/Inline.pm and rperlstandalone.h | ||
| 228 | '#undef do_open', # fix conflict between jpcre2.hpp subdep locale_facets_nonio.h & other uknown file, 'error: macro "do_open" requires 7 arguments, but only 2 given' | ||
| 229 | '#undef do_close', # fix conflict between jpcre2.hpp subdep locale_facets_nonio.h & other uknown file, 'error: macro "do_close" requires 2 arguments, but only 1 given' | ||
| 230 | |||
| 231 | # NEED DELETE, RPERL REFACTOR | ||
| 232 | # '#include "jpcre2.hpp"', | ||
| 233 | # DEV NOTE, CORRELATION #rp300: must link against all bit width libs to allow automatic selection | ||
| 234 | # 'typedef jpcre2::select<char>::Regex regex;', # automatically selects correct character bit width based on system, 8 or 16 or 32 | ||
| 235 | # 'typedef jpcre2::SIZE_T regexsize;', # used by substitution (replace) count type | ||
| 236 | ], | ||
| 237 | classes => sub { join('::', split('__', shift)); } | ||
| 238 | ); | ||
| 239 | |||
| 240 | 1; | ||