@@ -1141,7 +1141,13 @@ END
11411141{
11421142 print time_str(), " running find_typedefs ...\n " if $verbose ;
11431143
1144- find_typedefs();
1144+ my (@foundsyms );
1145+ my $source = $from_source || ' ../pgsql' ;
1146+
1147+ @foundsyms = run_log(" perl $source /src/tools/find_typedefs.pl" );
1148+
1149+ writelog(' typedefs' , \@foundsyms );
1150+ $steps_completed .= " find-typedefs" ;
11451151}
11461152
11471153# if we get here everything went fine ...
@@ -2577,196 +2583,6 @@ sub make_ecpg_check
25772583 return ;
25782584}
25792585
2580- # replace previous use of external egrep -A
2581- sub _dump_filter
2582- {
2583- my ($lines , $tag , $context ) = @_ ;
2584- my @output ;
2585- while (@$lines )
2586- {
2587- my $line = shift @$lines ;
2588- if (index ($line , $tag ) > -1)
2589- {
2590- push (@output , splice (@$lines , 0, $context ));
2591- }
2592- }
2593- return @output ;
2594- }
2595-
2596- sub find_typedefs
2597- {
2598- # work around the fact that ucrt/binutils objdump is far slower
2599- # than the one in msys/binutils
2600- local $ENV {PATH } = $ENV {PATH };
2601- $ENV {PATH } = " /usr/bin:$ENV {PATH}" if $Config {osname } eq ' msys' ;
2602-
2603- my ($hostobjdump ) = grep { / --host=/ } @$config_opts ;
2604- $hostobjdump ||= " " ;
2605- $hostobjdump =~ s / --host=(.*)/ $1 -objdump/ ;
2606- my $objdump = ' objdump' ;
2607- my $sep = $using_msvc ? ' ;' : ' :' ;
2608-
2609- # if we have a hostobjdump, find out which of it and objdump is in the path
2610- foreach my $p (split (/ $sep / , $ENV {PATH }))
2611- {
2612- last unless $hostobjdump ;
2613- last if (-e " $p /objdump" || -e " $p /objdump.exe" );
2614- if (-e " $p /$hostobjdump " || -e " $p /$hostobjdump .exe" )
2615- {
2616- $objdump = $hostobjdump ;
2617- last ;
2618- }
2619- }
2620- my @err = ` $objdump -W 2>&1` ;
2621- my @readelferr = ` readelf -w 2>&1` ;
2622- my $using_osx = (` uname` eq " Darwin\n " );
2623- my @testfiles ;
2624- my %syms ;
2625- my @dumpout ;
2626- my @flds ;
2627-
2628- if ($using_osx )
2629- {
2630-
2631- # On OS X, we need to examine the .o files
2632- # exclude ecpg/test, which pgindent does too
2633- my $obj_wanted = sub {
2634- / ^.*\. o\z /s
2635- && !($File::Find::name =~ m ! /ecpg/test/! s )
2636- && push (@testfiles , $File::Find::name );
2637- };
2638-
2639- File::Find::find($obj_wanted , $pgsql );
2640- }
2641- else
2642- {
2643-
2644- # Elsewhere, look at the installed executables and shared libraries
2645- @testfiles = (
2646- glob (" $installdir /bin/*" ),
2647- glob (" $installdir /lib/*" ),
2648- glob (" $installdir /lib/postgresql/*" )
2649- );
2650- }
2651- foreach my $bin (@testfiles )
2652- {
2653- next if $bin =~ m ! bin/(ipcclean|pltcl_)! ;
2654- next unless -f $bin ;
2655- next if -l $bin ; # ignore symlinks to plain files
2656- next if $bin =~ m ! /postmaster.exe$ ! ; # sometimes a copy not a link
2657-
2658- if ($using_osx )
2659- {
2660- # no run_log due to redirections.
2661- @dumpout = ` dwarfdump $bin 2>/dev/null` ;
2662- @dumpout = _dump_filter(\@dumpout , ' TAG_typedef' , 2);
2663- foreach (@dumpout )
2664- {
2665- # # no critic (RegularExpressions::ProhibitCaptureWithoutTest)
2666- @flds = split ;
2667- if (@flds == 3)
2668- {
2669- # old format
2670- next unless ($flds [0] eq " AT_name(" );
2671- next unless ($flds [1] =~ m / ^"(.*)"$ / );
2672- $syms {$1 } = 1;
2673- }
2674- elsif (@flds == 2)
2675- {
2676- # new format
2677- next unless ($flds [0] eq " DW_AT_name" );
2678- next unless ($flds [1] =~ m / ^\( "(.*)"\) $ / );
2679- $syms {$1 } = 1;
2680- }
2681- }
2682- }
2683- elsif (@err == 1) # Linux and sometimes windows
2684- {
2685- my $cmd = " $objdump -Wi $bin 2>/dev/null" ;
2686- @dumpout = ` $cmd ` ; # no run_log because of redirections
2687- @dumpout = _dump_filter(\@dumpout , ' DW_TAG_typedef' , 3);
2688- foreach (@dumpout )
2689- {
2690- @flds = split ;
2691- next unless (1 < @flds );
2692- next
2693- if (($flds [0] ne ' DW_AT_name' && $flds [1] ne ' DW_AT_name' )
2694- || $flds [-1] =~ / ^DW_FORM_str/ );
2695- $syms { $flds [-1] } = 1;
2696- }
2697- }
2698- elsif (@readelferr > 10)
2699- {
2700-
2701- # FreeBSD, similar output to Linux
2702- my $cmd = " readelf -w $bin 2>/dev/null" ;
2703- @dumpout = ` $cmd ` ; # no run_log due to redirections
2704- @dumpout = _dump_filter(\@dumpout , ' DW_TAG_typedef' , 3);
2705-
2706- foreach (@dumpout )
2707- {
2708- @flds = split ;
2709- next unless (1 < @flds );
2710- next if ($flds [0] ne ' DW_AT_name' );
2711- $syms { $flds [-1] } = 1;
2712- }
2713- }
2714- else
2715- {
2716- # no run_log due to redirections.
2717- @dumpout = ` $objdump --stabs $bin 2>/dev/null` ;
2718- foreach (@dumpout )
2719- {
2720- @flds = split ;
2721- next if (@flds < 7);
2722- next if ($flds [1] ne ' LSYM' || $flds [6] !~ / ([^:]+):t/ );
2723- # # no critic (RegularExpressions::ProhibitCaptureWithoutTest)
2724- $syms {$1 } = 1;
2725- }
2726- }
2727- }
2728- my @badsyms = grep { / \s / } keys %syms ;
2729- push (@badsyms , ' date' , ' interval' , ' timestamp' , ' ANY' );
2730- delete @syms {@badsyms };
2731-
2732- my @goodsyms = sort keys %syms ;
2733- my @foundsyms ;
2734-
2735- my %foundwords ;
2736-
2737- my $setfound = sub {
2738-
2739- # $_ is the name of the file being examined
2740- # its directory is our current cwd
2741-
2742- return unless (-f $_ && / ^.*\. [chly]\z / );
2743-
2744- my $src = file_contents($_ );
2745-
2746- # strip C comments
2747- # We used to use the recipe in perlfaq6 but there is actually no point.
2748- # We don't need to keep the quoted string values anyway, and
2749- # on some platforms the complex regex causes perl to barf and crash.
2750- $src =~ s { /\* .*?\* /} {} gs ;
2751-
2752- foreach my $word (split (/ \W +/ , $src ))
2753- {
2754- $foundwords {$word } = 1;
2755- }
2756- };
2757-
2758- File::Find::find($setfound , " $branch_root /pgsql" );
2759-
2760- foreach my $sym (@goodsyms )
2761- {
2762- push (@foundsyms , " $sym \n " ) if exists $foundwords {$sym };
2763- }
2764-
2765- writelog(' typedefs' , \@foundsyms );
2766- $steps_completed .= " find-typedefs" ;
2767- return ;
2768- }
2769-
27702586# meson setup for all platforms
27712587sub meson_setup
27722588{
0 commit comments