Skip to content

Commit cc671dc

Browse files
committed
Fix fuzz/bench Linux build paths and modules
1 parent 2c0936a commit cc671dc

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

tools/bench-runner

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ EMIT_C_CC_FLAGS = [
2222
"-Wall",
2323
"-Wextra",
2424
"-Wpedantic",
25+
"-Wno-pedantic",
2526
"-Werror",
2627
"-Wno-unused-function",
28+
"-D_POSIX_C_SOURCE=200809L",
29+
"-D_GNU_SOURCE",
2730
"-x",
2831
"c",
2932
]
@@ -60,7 +63,7 @@ def emit_c_compile_once(case_path: str, out_dir: Path, out_name: str) -> tuple[b
6063
return (False, 0.0, bin_path)
6164

6265
cc = subprocess.run(
63-
["cc", *EMIT_C_CC_FLAGS, str(c_path), "-o", str(bin_path)],
66+
["cc", *EMIT_C_CC_FLAGS, str(c_path), "-o", str(bin_path), "-lm"],
6467
cwd=str(ROOT),
6568
stdout=subprocess.PIPE,
6669
stderr=subprocess.PIPE,
@@ -169,6 +172,27 @@ def main() -> int:
169172
parser.add_argument("--superlinear-factor", type=float, default=4.0, help="Max growth ratio for 2x scale tests.")
170173
args = parser.parse_args()
171174

175+
modules_tmp: str | None = None
176+
if not os.environ.get("PS_MODULE_PATH"):
177+
modules_tmp = tempfile.mkdtemp(prefix="ps_bench_modules_")
178+
os.environ["PS_MODULE_PATH"] = modules_tmp
179+
build_script = ROOT / "scripts" / "build_modules.sh"
180+
if build_script.exists():
181+
build = subprocess.run(
182+
[str(build_script)],
183+
cwd=str(ROOT),
184+
stdout=subprocess.PIPE,
185+
stderr=subprocess.PIPE,
186+
text=True,
187+
)
188+
if build.returncode != 0:
189+
print("ERROR: failed to build test modules", file=sys.stderr)
190+
sys.stderr.write(build.stdout)
191+
sys.stderr.write(build.stderr)
192+
if modules_tmp:
193+
shutil.rmtree(modules_tmp, ignore_errors=True)
194+
return 2
195+
172196
repeats = 2 if args.quick or not args.full else 5
173197
ensure_c_bins()
174198
REPORT_DIR.mkdir(parents=True, exist_ok=True)
@@ -299,6 +323,8 @@ def main() -> int:
299323
)
300324

301325
print(f"Summary: PASS={pass_count} FAIL={fail_count} TOTAL={pass_count + fail_count}")
326+
if modules_tmp:
327+
shutil.rmtree(modules_tmp, ignore_errors=True)
302328
return 0 if fail_count == 0 else 1
303329

304330

tools/fuzz-runner

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import subprocess
99
import sys
1010
import time
1111
from pathlib import Path
12+
import platform
1213

1314

1415
ROOT = Path(__file__).resolve().parent.parent
1516
REPORT_DIR = ROOT / "reports" / "fuzz"
1617
BIN_DIR = ROOT / "tests" / "fuzz" / "bin"
1718
FINDINGS_RAW = ROOT / "tests" / "fuzz" / "findings" / "raw"
1819
MCPP_LIB = ROOT / "third_party" / "mcpp" / "lib" / "libmcpp.a"
20+
if platform.system() == "Linux":
21+
MCPP_LIB = ROOT / "third_party" / "mcpp" / "lib64" / "libmcpp.a"
1922

2023

2124
TARGETS = [
@@ -88,6 +91,7 @@ def build_target(target: dict[str, Path | str], clang: str, cflags: list[str], l
8891
*COMMON_SRCS,
8992
str(MCPP_LIB),
9093
"-ldl",
94+
"-lm",
9195
"-o",
9296
str(bin_path),
9397
]
@@ -125,6 +129,8 @@ def main() -> int:
125129
"-fsanitize=fuzzer,address,undefined",
126130
"-Wall",
127131
"-Wextra",
132+
"-D_POSIX_C_SOURCE=200809L",
133+
"-D_GNU_SOURCE",
128134
]
129135

130136
pass_count = 0

0 commit comments

Comments
 (0)