From c9e752c9d705fbbbdca474a9ce8e112bde9cc8e0 Mon Sep 17 00:00:00 2001 From: Benjamin Wegener Date: Thu, 8 May 2025 10:22:45 +0200 Subject: [PATCH] Fix build error with GCC by forcing Clang compiler in CMake on android/aarch64 (#242) GCC does not recognize Clang-specific warning flags like -Wunreachable-code-break and -Wunreachable-code-return, which are passed by upstream submodules (e.g., ggml). This patch forces CMake to use Clang via command-line arguments, avoiding the need to patch nested submodules. This resolves compiler errors without modifying submodule source code. --- setup_env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup_env.py b/setup_env.py index 8011872..dfad6c3 100644 --- a/setup_env.py +++ b/setup_env.py @@ -199,7 +199,7 @@ def compile(): logging.error(f"Arch {arch} is not supported yet") exit(0) logging.info("Compiling the code using CMake.") - run_command(["cmake", "-B", "build", *COMPILER_EXTRA_ARGS[arch], *OS_EXTRA_ARGS.get(platform.system(), [])], log_step="generate_build_files") + run_command(["cmake", "-B", "build", *COMPILER_EXTRA_ARGS[arch], *OS_EXTRA_ARGS.get(platform.system(), []), "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"], log_step="generate_build_files") # run_command(["cmake", "--build", "build", "--target", "llama-cli", "--config", "Release"]) run_command(["cmake", "--build", "build", "--config", "Release"], log_step="compile") @@ -229,4 +229,4 @@ if __name__ == "__main__": args = parse_args() Path(args.log_dir).mkdir(parents=True, exist_ok=True) logging.basicConfig(level=logging.INFO) - main() \ No newline at end of file + main()