Add macOS support for AddressSanitizer memory limit (#7308)
This commit is contained in:
parent
b9c8560d12
commit
ee7ec08cf5
|
|
@ -213,14 +213,22 @@ sub ulimit_stack_unlimited {
|
|||
# AddressSanitizer doesn't work with 'ulimit -s unlimted'
|
||||
if (`${\(verilator_bin())} --get-supported DEV_ASAN` eq "1\n") {
|
||||
# Use host 'physical memory / #cores / 8' instead
|
||||
open(my $fh, "<", "/proc/meminfo") || die "Can't read host memory for asan";
|
||||
while (<$fh>) {
|
||||
if (m/MemTotal:\s+(\d+)\s+kB/) {
|
||||
$limit = int(int($1)/`nproc`/8);
|
||||
last;
|
||||
if ($^O eq "darwin") {
|
||||
my $membytes = `sysctl -n hw.memsize`;
|
||||
chomp $membytes;
|
||||
my $ncpu = `sysctl -n hw.ncpu`;
|
||||
chomp $ncpu;
|
||||
$limit = int(int($membytes / 1024) / $ncpu / 8);
|
||||
} else {
|
||||
open(my $fh, "<", "/proc/meminfo") || die "Can't read host memory for asan";
|
||||
while (<$fh>) {
|
||||
if (m/MemTotal:\s+(\d+)\s+kB/) {
|
||||
$limit = int(int($1)/`nproc`/8);
|
||||
last;
|
||||
}
|
||||
}
|
||||
close($fh);
|
||||
}
|
||||
close($fh);
|
||||
}
|
||||
system("ulimit -s $limit 2>/dev/null");
|
||||
my $status = $?;
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ Lukasz Dalek
|
|||
Maarten De Braekeleer
|
||||
Maciej Sobkowski
|
||||
Marcel Chang
|
||||
Marco Bartoli
|
||||
Marco Widmer
|
||||
Mariusz Glebocki
|
||||
Markus Krause
|
||||
|
|
|
|||
Loading…
Reference in New Issue