@@ -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
0 commit comments