]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper_cxx: -O2 optimize read-only files by default
authorEric Wong <e@80x24.org>
Mon, 12 Feb 2024 21:28:03 +0000 (21:28 +0000)
committerEric Wong <e@80x24.org>
Wed, 14 Feb 2024 07:25:54 +0000 (07:25 +0000)
While fast build times from -O0 is critical to my sanity when
actively working on C++, the files installed via package
managers or `make install' aren't likely to change frequently.

In that case, expensive -O2 optimizations make sense since the
10-20s saved from a single large --join more than covers the
cost of waiting on g++ to optimize.

lib/PublicInbox/XapHelperCxx.pm

index 6bd165b8a6c795bf4c1b6d5c67d79c7a2412481e..eafe61a85cf9da7d88b38be4c65d3e72538f3895 100644 (file)
@@ -30,6 +30,7 @@ my $xflags = ($ENV{CXXFLAGS} // '-Wall -ggdb3 -pipe') . ' ' .
        ' -DXH_SPEC="'.join('',
                map { s/=.*/:/; $_ } @PublicInbox::Search::XH_SPEC) . '" ' .
        ($ENV{LDFLAGS} // $ldflags);
+substr($xflags, 0, 0, '-O2 ') if !defined($ENV{CXXFLAGS}) && !-w __FILE__;
 my $xap_modversion;
 
 sub xap_cfg (@) {