test_compiler.py: Detect mlgo status at runtime

So we don't need to rely on passing the correct --no-mlgo argument
when testing an existing clang prebuilt.

Bug: 345306194
Test: run test_compiler.py
Change-Id: Ibdc4e38aff7eea3eda89768b5ed7c5485a233ebd
diff --git a/do_test_compiler.py b/do_test_compiler.py
index 65cb136..53027d6 100755
--- a/do_test_compiler.py
+++ b/do_test_compiler.py
@@ -401,6 +401,12 @@
     return extract_dir / f'clang-{build_id}'
 
 
+def is_clang_built_with_mlgo(clang_dir: Path):
+    clang = clang_dir / 'bin' / 'clang'
+    output = utils.check_output([str(clang), '--version'])
+    return '+mlgo' in output
+
+
 def main():
     logging.basicConfig(level=logging.DEBUG)
 
@@ -436,6 +442,8 @@
     clang_version = extract_clang_version(clang_path)
     copy_clang(Path(args.android_path), clang_path)
 
+    no_mlgo = not is_clang_built_with_mlgo(clang_path)
+
     if args.build_only:
         if args.profile:
             profiler = PgoProfileHandler()
@@ -446,7 +454,7 @@
 
         build_target(Path(args.android_path), clang_version, args.target,
                      modules, args.jobs,
-                     args.enable_fallback, args.with_tidy, args.no_mlgo, profiler)
+                     args.enable_fallback, args.with_tidy, no_mlgo, profiler)
 
         if profiler is not None:
             profiler.mergeProfiles()
@@ -459,7 +467,7 @@
             result = test_device(Path(args.android_path), clang_version, device,
                                  modules, args.jobs, args.clean_built_target,
                                  Path(args.flashall_path) if args.flashall_path else None,
-                                 args.enable_fallback, args.with_tidy, args.no_mlgo)
+                                 args.enable_fallback, args.with_tidy, no_mlgo)
             if not result and not args.keep_going:
                 break