Skip to content

Instantly share code, notes, and snippets.

Last active Jan 21, 2018
What would you like to do?
#!/usr/bin/env perl
use 5.10.1;
use strict;
use warnings;
my @flags = qw(
-fcprop-registers -fdefer-pop -fguess-branch-probability -fif-conversion
-fif-conversion2 -finline -fipa-pure-const -fipa-reference
-fmerge-constants -fomit-frame-pointer -fsplit-wide-types
-ftoplevel-reorder -ftree-ccp -ftree-ch -ftree-copy-prop
-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre
-ftree-sink -ftree-sra -ftree-ter
my $GCC_CMD = q{
gcc -c
-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe
-Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"0.280301\"
-DXS_VERSION=\"0.280301\" -fPIC "-I/usr/lib64/perl5/CORE" CommonMarkGFM.c
$GCC_CMD =~ s/\s+/ /gs;
sub gcc_cmd {
my (@add) = @_;
my $cmd = $GCC_CMD;
$cmd =~ s/-O2/@add/;
return $cmd;
my $done = 0;
while (not $done) {
my $gcc_rc = system(gcc_cmd(@flags) . " &>/dev/null");
my $make_rc = system("make install &>/dev/null");
die "failure\n" unless $gcc_rc == 0 && $make_rc == 0;
if (system('perl t/03_render.t') == 0) {
$done = 1;
warn "GOOD flags:\n\t@flags\n";
else {
warn "BAD flags:\n\t@flags\n";
pop @flags;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment