Permalink
Browse files

Merge pull request #309 from ilmari/ubsan

Add UBSAN support to Configure.pl
  • Loading branch information...
FROGGS committed Dec 8, 2015
2 parents 170ca53 + 6913bf4 commit d0e9bd1372c46050ca7586ff2d48cb3ea2084aa7
Showing with 13 additions and 3 deletions.
  1. +13 −3 Configure.pl
View
@@ -34,7 +34,7 @@
static has-libtommath has-libatomic_ops
has-dyncall has-libffi
build=s host=s big-endian jit! enable-jit lua=s has-dynasm
prefix=s bindir=s libdir=s mastdir=s make-install asan),
prefix=s bindir=s libdir=s mastdir=s make-install asan ubsan),
'no-optimize|nooptimize' => sub { $args{optimize} = 0 },
'no-debug|nodebug' => sub { $args{debug} = 0 }
) or die "See --help for further information\n";
@@ -80,6 +80,7 @@
$args{'has-libatomic_ops'} //= 0;
$args{'has-dynasm'} //= 0;
$args{'asan'} //= 0;
$args{'ubsan'} //= 0;
# jit is default
$args{'jit'} //= 1;
@@ -272,6 +273,7 @@
(map { sprintf $config{ldusr}, $_; } @{$config{usrlibs}}),
(map { sprintf $config{ldsys}, $_; } @{$config{syslibs}});
$config{ldlibs} = ' -lasan ' . $config{ldlibs} if $args{asan};
$config{ldlibs} = ' -lubsan ' . $config{ldlibs} if $args{ubsan};
# macro defs
$config{ccdefflags} = join ' ', map { $config{ccdef} . $_ } @{$config{defs}};
@@ -290,7 +292,9 @@
push @cflags, $config{ccwarnflags};
push @cflags, $config{ccdefflags};
push @cflags, $config{ccshared} unless $args{static};
push @cflags, '-fno-omit-frame-pointer -fsanitize=address' if $args{asan};
push @cflags, '-fno-omit-frame-pointer' if $args{asan} or $args{ubsan};
push @cflags, '-fsanitize=address' if $args{asan};
push @cflags, '-fsanitize=undefined' if $args{ubsan};
push @cflags, $ENV{CFLAGS} if $ENV{CFLAGS};
push @cflags, $ENV{CPPFLAGS} if $ENV{CPPFLAGS};
$config{cflags} = join ' ', @cflags;
@@ -328,6 +332,8 @@
$config{libdir} = '@prefix@/lib' if ! $args{libdir};
}
$config{mainlibs} = '-lubsan ' . $config{mainlibs} if $args{ubsan};
# some toolchains generate garbage
my @auxfiles = @{ $defaults{-auxfiles} };
$config{auxclean} = @auxfiles ? '$(RM) ' . join ' ', @auxfiles : '@:';
@@ -715,7 +721,7 @@ =head1 SYNOPSIS
[--static] [--prefix]
[--has-libtommath] [--has-sha] [--has-libuv]
[--has-libatomic_ops] [--has-dynasm]
[--lua <lua>] [--asan] [--no-jit]
[--lua <lua>] [--asan] [--ubsan] [--no-jit]
./Configure.pl --build <build-triple> --host <host-triple>
[--ar <ar>] [--cc <cc>] [--ld <ld>] [--make <make>]
@@ -799,6 +805,10 @@ =head1 OPTIONS
A full list of options is displayed if you set C<ASAN_OPTIONS> to C<help=1>.
=item --ubsan
Build with Undefined Behaviour sanitizer support.
=item --ld <ld>
Explicitly set the linker without affecting other configuration

0 comments on commit d0e9bd1

Please sign in to comment.