@@ -391,6 +391,27 @@ def copy_fuzzing_engine(fuzzing_engine: str) -> Path:
391391 return fuzzing_engine_dir
392392
393393
394+ def _get_latest_gcc_version () -> str :
395+ """Finds the latest GCC version installed.
396+
397+ Defaults to '9' for backward compatibility if detection fails.
398+
399+ Returns:
400+ The latest GCC version found, or the default.
401+ """
402+ gcc_base = Path ('/usr/lib/gcc/x86_64-linux-gnu' )
403+ if gcc_base .exists ():
404+ versions = []
405+ for d in gcc_base .iterdir ():
406+ if d .is_dir () and d .name .isdigit ():
407+ versions .append (int (d .name ))
408+
409+ if versions :
410+ return str (max (versions ))
411+
412+ return '9'
413+
414+
394415def build_project (
395416 targets_to_index : Sequence [str ] | None = None ,
396417 compile_args : Sequence [str ] | None = None ,
@@ -415,6 +436,7 @@ def build_project(
415436 )
416437
417438 fuzzing_engine_dir = copy_fuzzing_engine (DEFAULT_FUZZING_ENGINE )
439+ gcc_version = _get_latest_gcc_version ()
418440 build_fuzzing_engine_command = [
419441 f'{ _CLANG_TOOLCHAIN } /bin/clang++' ,
420442 '-c' ,
@@ -433,11 +455,11 @@ def build_project(
433455 f'{ OUT } /cdb' ,
434456 '-Qunused-arguments' ,
435457 f'-isystem { _CLANG_TOOLCHAIN } /lib/clang/{ clang_version } ' ,
436- '/usr/lib/gcc/x86_64-linux-gnu/9 /../../../../include/c++/9 ' ,
458+ f '/usr/lib/gcc/x86_64-linux-gnu/{ gcc_version } /../../../../include/c++/{ gcc_version } ' ,
437459 '-I' ,
438- '/usr/lib/gcc/x86_64-linux-gnu/9 /../../../../include/x86_64-linux-gnu/c++/9 ' ,
460+ f '/usr/lib/gcc/x86_64-linux-gnu/{ gcc_version } /../../../../include/x86_64-linux-gnu/c++/{ gcc_version } ' ,
439461 '-I' ,
440- '/usr/lib/gcc/x86_64-linux-gnu/9 /../../../../include/c++/9 /backward' ,
462+ f '/usr/lib/gcc/x86_64-linux-gnu/{ gcc_version } /../../../../include/c++/{ gcc_version } /backward' ,
441463 '-I' ,
442464 f'{ _CLANG_TOOLCHAIN } /lib/clang/{ clang_version } /include' ,
443465 '-I' ,
0 commit comments