Skip to content

Commit c9e752c

Browse files
Fix build error with GCC by forcing Clang compiler in CMake on android/aarch64 (ggml-org#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.
1 parent 1792346 commit c9e752c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

setup_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def compile():
199199
logging.error(f"Arch {arch} is not supported yet")
200200
exit(0)
201201
logging.info("Compiling the code using CMake.")
202-
run_command(["cmake", "-B", "build", *COMPILER_EXTRA_ARGS[arch], *OS_EXTRA_ARGS.get(platform.system(), [])], log_step="generate_build_files")
202+
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")
203203
# run_command(["cmake", "--build", "build", "--target", "llama-cli", "--config", "Release"])
204204
run_command(["cmake", "--build", "build", "--config", "Release"], log_step="compile")
205205

@@ -229,4 +229,4 @@ def signal_handler(sig, frame):
229229
args = parse_args()
230230
Path(args.log_dir).mkdir(parents=True, exist_ok=True)
231231
logging.basicConfig(level=logging.INFO)
232-
main()
232+
main()

0 commit comments

Comments
 (0)