From 5d89f4f0e6f1b41ad4391ea05e3170d577045507 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Tue, 22 Jul 2025 14:53:14 +0800 Subject: [PATCH] Check compiler version --- .github/workflows/build-on-Windows.yml | 7 ++++++- .github/workflows/build-on-macOS.yml | 12 +++++++++++- Makefile | 14 +++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-on-Windows.yml b/.github/workflows/build-on-Windows.yml index 0677ca2..f82cf9d 100644 --- a/.github/workflows/build-on-Windows.yml +++ b/.github/workflows/build-on-Windows.yml @@ -51,7 +51,12 @@ jobs: - name: 为 Android 构建 run: | - mingw32-make.exe build-in-ci-release-mode CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android21-clang + compiler=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android21-clang + + # 检查编译器版本 + $compiler --version + + mingw32-make.exe build-in-ci-release-mode CC=$compiler CROSS_BUILD_WINDOWS_FOR_ANDROID=1 mv chsrc-ci-release.exe chsrc-arm64-android - name: List files diff --git a/.github/workflows/build-on-macOS.yml b/.github/workflows/build-on-macOS.yml index 5d80b1f..1cd24ce 100644 --- a/.github/workflows/build-on-macOS.yml +++ b/.github/workflows/build-on-macOS.yml @@ -4,7 +4,7 @@ # Contributors : Nul None # | # Created On : <2023-09-15> -# Last Modified : <2025-06-20> +# Last Modified : <2025-07-22> # # Build chsrc on macOS and upload it to GitHub: the 'pre' release # --------------------------------------------------------------- @@ -22,6 +22,11 @@ jobs: - name: 检出代码 uses: actions/checkout@v4 + - name: 检查编译器版本 + run: | + clang --version + gcc --version + - name: 为 arm64 (AArch64) 构建 run: | make build-in-ci-release-mode @@ -47,6 +52,11 @@ jobs: - name: 检出代码 uses: actions/checkout@v4 + - name: 检查编译器版本 + run: | + clang --version + gcc --version + - name: 为 x64 构建 run: | make build-in-ci-release-mode diff --git a/Makefile b/Makefile index 2193582..ffbe7a7 100755 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ endif #======== Default Tooling ============ ifeq ($(On-Windows), 1) - # MSYS2 环境 + # MSYS2 环境 CC = cc else ifeq ($(On-macOS), 1) CC = clang @@ -101,10 +101,14 @@ ifeq ($(MAKECMDGOALS), build-in-ci-release-mode) endif ifeq ($(On-macOS), 1) - # 太糟糕了,到现在 (2025-07-22) GitHub Actions 的 macOS (13、15) 中的 LLVM 版本还太低 - # 我们代码里有 raw string literal 扩展的用法,所以只能切到 GCC 去 - # 但是用户自己编译等情况下,依旧让他们用 Clang,因为他们环境的 LLVM 版本可能比较新 - CC = gcc + ifeq ($(CC), clang) + CFLAGS += -fraw-string-literals + endif + endif + + # 在 Windows 上交叉编译 Android 时,用的是 clang + ifdef CROSS_BUILD_WINDOWS_FOR_ANDROID + CFLAGS += -fraw-string-literals endif endif