From d8347fa610bfe51e72612504935b2aaa9885a991 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Fri, 6 Mar 2026 19:39:03 +0800 Subject: [PATCH 01/28] fix: replace XLINGS_BIN with get_xlings_bin() to avoid dangling string_view - get_home_dir() is runtime (getenv), cannot use in constexpr - string_view from temporary string would dangle after expression ends - Add get_xlings_bin() returning std::string, keep get_home_dir in original position - Update platform.cppm and xlings.cppm to use get_xlings_bin() --- src/platform.cppm | 4 ++-- src/platform/linux.cppm | 5 ++++- src/platform/macos.cppm | 5 ++++- src/platform/windows.cppm | 5 ++++- src/xlings.cppm | 12 +++++------- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/platform.cppm b/src/platform.cppm index b9ca897..79c37aa 100644 --- a/src/platform.cppm +++ b/src/platform.cppm @@ -11,7 +11,7 @@ namespace platform { static std::string gRundir = std::filesystem::current_path().string(); - export using platform_impl::XLINGS_BIN; + export using platform_impl::get_xlings_bin; export using platform_impl::XLINGS_INSTALL_CMD; export using platform_impl::clear_console; @@ -65,7 +65,7 @@ namespace platform { int status = platform::exec(std::string(XLINGS_INSTALL_CMD)); if (status == 0) { std::println("xlings 安装成功!"); - std::string xlings_path { std::filesystem::path(XLINGS_BIN).parent_path().string() }; + std::string xlings_path { std::filesystem::path(get_xlings_bin()).parent_path().string() }; char* path_env = std::getenv("PATH"); if (path_env) { std::string new_path = std::string(path_env) + ";" + xlings_path; diff --git a/src/platform/linux.cppm b/src/platform/linux.cppm index 8783617..867d185 100644 --- a/src/platform/linux.cppm +++ b/src/platform/linux.cppm @@ -12,7 +12,6 @@ import std; namespace d2x { namespace platform_impl { - export constexpr std::string_view XLINGS_BIN = "/home/xlings/.xlings_data/bin/xlings"; export constexpr std::string_view XLINGS_INSTALL_CMD = "curl -fsSL https://d2learn.org/xlings-install.sh | bash"; export std::pair run_command_capture(const std::string& cmd) { @@ -41,6 +40,10 @@ namespace platform_impl { return "."; } + export inline std::string get_xlings_bin() { + return get_home_dir() + "/.xlings/subos/current/bin/xlings"; + } + export void set_env_variable(const std::string& key, const std::string& value) { ::setenv(key.c_str(), value.c_str(), 1); } diff --git a/src/platform/macos.cppm b/src/platform/macos.cppm index 568072b..dad3508 100644 --- a/src/platform/macos.cppm +++ b/src/platform/macos.cppm @@ -12,7 +12,6 @@ import std; namespace d2x { namespace platform_impl { - export constexpr std::string_view XLINGS_BIN = "/Users/xlings/.xlings_data/bin/xlings"; export constexpr std::string_view XLINGS_INSTALL_CMD = "curl -fsSL https://d2learn.org/xlings-install.sh | bash"; export std::pair run_command_capture(const std::string& cmd) { @@ -42,6 +41,10 @@ namespace platform_impl { return "."; } + export inline std::string get_xlings_bin() { + return get_home_dir() + "/.xlings/subos/current/bin/xlings"; + } + export void set_env_variable(const std::string& key, const std::string& value) { ::setenv(key.c_str(), value.c_str(), 1); } diff --git a/src/platform/windows.cppm b/src/platform/windows.cppm index 77fde6b..9ad2402 100644 --- a/src/platform/windows.cppm +++ b/src/platform/windows.cppm @@ -12,7 +12,6 @@ import std; namespace d2x { namespace platform_impl { - export constexpr std::string_view XLINGS_BIN = "C:\\Users\\Public\\xlings\\.xlings_data\\bin\\xlings"; export constexpr std::string_view XLINGS_INSTALL_CMD = "powershell -Command \"irm https://d2learn.org/xlings-install.ps1.txt | iex\""; export std::pair run_command_capture(const std::string& cmd) { @@ -40,6 +39,10 @@ namespace platform_impl { return "."; } + export inline std::string get_xlings_bin() { + return get_home_dir() + "\\.xlings\\subos\\current\\bin\\xlings"; + } + export void set_env_variable(const std::string& key, const std::string& value) { _putenv_s(key.c_str(), value.c_str()); } diff --git a/src/xlings.cppm b/src/xlings.cppm index 07c18bb..e482eb3 100644 --- a/src/xlings.cppm +++ b/src/xlings.cppm @@ -10,17 +10,15 @@ namespace xlings { [[nodiscard]] bool has_xlings() { - // check by XLINGS_BIN - if (std::filesystem::exists(platform::XLINGS_BIN)) { + // check by xlings binary path + if (std::filesystem::exists(platform::get_xlings_bin())) { return true; } - auto [status, output] = d2x::platform::run_command_capture("xlings"); + auto [status, output] = d2x::platform::run_command_capture("xlings --version"); auto clean_output = d2x::utils::strip_ansi(output); - return status == 0 && ( - clean_output.find("xlings version") != std::string::npos || - clean_output.find("xlings 版本") != std::string::npos - ); + // match xlings x.x.x format to check if xlings is installed + return status == 0 && std::regex_match(clean_output, std::regex("xlings (\\d+\\.\\d+\\.\\d+)")); } export bool ensure_xlings_installed() { From c4b9c23814bd29b9091a60d2198a4e07c0e76d60 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Fri, 6 Mar 2026 19:42:35 +0800 Subject: [PATCH 02/28] chore: bump version to 0.1.4 --- README.md | 2 +- src/config.cppm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd4990c..13c57d4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ | --- | ```cpp -d2x version: 0.1.1 +d2x version: 0.1.4 Usage: $ d2x [command] [target] [options] diff --git a/src/config.cppm b/src/config.cppm index f7d3d49..472c75d 100644 --- a/src/config.cppm +++ b/src/config.cppm @@ -17,7 +17,7 @@ export struct EnvVars; export class Config; struct Info { - static constexpr std::string_view VERSION = "0.1.3"; + static constexpr std::string_view VERSION = "0.1.4"; static constexpr std::string_view REPO = "https://github.com/d2learn/d2x"; }; From bdaa3fa7ddc60ab093efe4e4e0bc8983f4e0ef02 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Fri, 6 Mar 2026 20:37:54 +0800 Subject: [PATCH 03/28] ci: set XLINGS_NON_INTERACTIVE=1 for xlings install in release workflow --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b273e24..e93c1e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,8 +25,11 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential + # Install script (d2learn.org/xlings-install.sh) should use XLINGS_NON_INTERACTIVE=1 to skip /dev/tty when not available (e.g. CI) - name: Install Xlings run: curl -fsSL https://d2learn.org/xlings-install.sh | bash + env: + XLINGS_NON_INTERACTIVE: 1 - name: install gcc 15.1 with Xlings run: | From 4fbba53f648a1c01b41400f13d665e218159f870 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Fri, 6 Mar 2026 20:41:30 +0800 Subject: [PATCH 04/28] ci: add workflow to build and verify d2x --version on PR/push --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c9622c5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: latest + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential + + - name: Install Xlings + run: curl -fsSL https://d2learn.org/xlings-install.sh | bash + env: + XLINGS_NON_INTERACTIVE: 1 + + - name: Install gcc 15.1 with Xlings + run: | + export PATH=/home/xlings/.xlings_data/bin:$PATH + xlings install gcc@15.1 -y + + - name: Build with xmake + run: | + export PATH=/home/xlings/.xlings_data/bin:$PATH + xmake f -m release -y + xmake -j$(nproc) + + - name: Verify d2x --version + run: | + export PATH=/home/xlings/.xlings_data/bin:$PATH + ./build/linux/x86_64/release/d2x --version From 44056a40ccdf868ec424a43a506c148045e11db9 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 01:12:31 +0800 Subject: [PATCH 05/28] ci: replace xlings gcc install with musl-gcc 15.1 toolchain Switch Linux CI and release builds to use musl-gcc 15.1 downloaded directly from xlings-res/musl-gcc releases, matching the approach used by xlings. Also switch to bundled xmake v3.0.7, ubuntu-24.04, and the raw githubusercontent Xlings install URL. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 57 +++++++++++++++++++++++------------ .github/workflows/release.yml | 54 ++++++++++++++++++++++----------- 2 files changed, 75 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9622c5..d10949d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,40 +6,59 @@ on: pull_request: branches: [main] +env: + XMAKE_VERSION: v3.0.7 + jobs: build-linux: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: latest + - name: Install system deps + run: | + sudo apt-get update -qq + sudo apt-get install -y curl git build-essential - - name: Install dependencies + - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) run: | - sudo apt-get update - sudo apt-get install -y build-essential + XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" + curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" + chmod +x xmake.bin + mkdir -p xmake/bin + mv xmake.bin xmake/bin/xmake + echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" + xmake --version - name: Install Xlings - run: curl -fsSL https://d2learn.org/xlings-install.sh | bash env: XLINGS_NON_INTERACTIVE: 1 + run: | + curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash + echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - name: Install gcc 15.1 with Xlings + - name: Install musl-gcc 15.1 run: | - export PATH=/home/xlings/.xlings_data/bin:$PATH - xlings install gcc@15.1 -y + MUSL_SDK=$HOME/.xlings/data/xpkgs/musl-gcc/15.1.0 + mkdir -p "$MUSL_SDK" + curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 + echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" + echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" + echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" + echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$MUSL_SDK/bin:$PATH" + test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" + x86_64-linux-musl-g++ --version - - name: Build with xmake + - name: Configure xmake run: | - export PATH=/home/xlings/.xlings_data/bin:$PATH - xmake f -m release -y - xmake -j$(nproc) + xmake f -c -p linux -m release --sdk="$MUSL_SDK" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y + + - name: Build with xmake + run: xmake -j$(nproc) - name: Verify d2x --version - run: | - export PATH=/home/xlings/.xlings_data/bin:$PATH - ./build/linux/x86_64/release/d2x --version + run: ./build/linux/x86_64/release/d2x --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e93c1e0..631f38c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,39 +8,59 @@ on: required: true type: string +env: + XMAKE_VERSION: v3.0.7 + jobs: build-linux: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: latest + - name: Install system deps + run: | + sudo apt-get update -qq + sudo apt-get install -y curl git build-essential - - name: Install dependencies + - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) run: | - sudo apt-get update - sudo apt-get install -y build-essential + XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" + curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" + chmod +x xmake.bin + mkdir -p xmake/bin + mv xmake.bin xmake/bin/xmake + echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" + xmake --version - # Install script (d2learn.org/xlings-install.sh) should use XLINGS_NON_INTERACTIVE=1 to skip /dev/tty when not available (e.g. CI) - name: Install Xlings - run: curl -fsSL https://d2learn.org/xlings-install.sh | bash env: XLINGS_NON_INTERACTIVE: 1 + run: | + curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash + echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - name: install gcc 15.1 with Xlings + - name: Install musl-gcc 15.1 run: | - export PATH=/home/xlings/.xlings_data/bin:$PATH - xlings install gcc@15.1 -y + MUSL_SDK=$HOME/.xlings/data/xpkgs/musl-gcc/15.1.0 + mkdir -p "$MUSL_SDK" + curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 + echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" + echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" + echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" + echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$MUSL_SDK/bin:$PATH" + test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" + x86_64-linux-musl-g++ --version + + - name: Configure xmake + run: | + xmake f -c -p linux -m release --sdk="$MUSL_SDK" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y - name: Build with xmake - run: | - export PATH=/home/xlings/.xlings_data/bin:$PATH - xmake f -m release -y - xmake -j$(nproc) + run: xmake -j$(nproc) - name: Create release package run: | From add5d529427c3cda4389565d3fc503fea188bb10 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 01:20:54 +0800 Subject: [PATCH 06/28] ci: add musl runtime setup step for musl-gcc toolchain The helper binaries (as, cc1, collect2) in the musl-gcc package have a hardcoded ELF interpreter path (/home/xlings/.xlings_data/lib/ld-musl-x86_64.so.1). Create the required symlinks so the toolchain can execute on the runner. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 11 +++++++++++ .github/workflows/release.yml | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d10949d..16855ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,17 @@ jobs: test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" x86_64-linux-musl-g++ --version + - name: Setup musl runtime + run: | + LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" + LOADER_DIR="/home/xlings/.xlings_data/lib" + sudo mkdir -p "$LOADER_DIR" + sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" + sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 + echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 + - name: Configure xmake run: | xmake f -c -p linux -m release --sdk="$MUSL_SDK" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 631f38c..ce14215 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,17 @@ jobs: test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" x86_64-linux-musl-g++ --version + - name: Setup musl runtime + run: | + LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" + LOADER_DIR="/home/xlings/.xlings_data/lib" + sudo mkdir -p "$LOADER_DIR" + sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" + sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 + echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 + - name: Configure xmake run: | xmake f -c -p linux -m release --sdk="$MUSL_SDK" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y From 410e97838d12ead68c7e1e319f2e06ce5ad01dca Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 01:37:02 +0800 Subject: [PATCH 07/28] ci: fix musl-gcc xpkg path to xim-x-musl-gcc Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16855ac..5a8a7fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: - name: Install musl-gcc 15.1 run: | - MUSL_SDK=$HOME/.xlings/data/xpkgs/musl-gcc/15.1.0 + MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 mkdir -p "$MUSL_SDK" curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce14215..68aff87 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: - name: Install musl-gcc 15.1 run: | - MUSL_SDK=$HOME/.xlings/data/xpkgs/musl-gcc/15.1.0 + MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 mkdir -p "$MUSL_SDK" curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" From 0017b70322896b6e9589a23876fbaca8cb1e1be8 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 01:50:45 +0800 Subject: [PATCH 08/28] ci: add --sysroot to xmake config for musl-gcc package builds Without --sysroot, xmake cannot find musl headers (they live under $MUSL_SDK/x86_64-linux-musl/, not $MUSL_SDK/), so cmake-based packages fall back to /usr/include (glibc headers), causing incompatible bits/wordsize.h errors when compiling with musl-gcc. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a8a7fc..5e20b15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: - name: Configure xmake run: | - xmake f -c -p linux -m release --sdk="$MUSL_SDK" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y + xmake f -c -p linux -m release --sdk="$MUSL_SDK" --sysroot="$MUSL_SDK/x86_64-linux-musl" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y - name: Build with xmake run: xmake -j$(nproc) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 68aff87..10baf08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: - name: Configure xmake run: | - xmake f -c -p linux -m release --sdk="$MUSL_SDK" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y + xmake f -c -p linux -m release --sdk="$MUSL_SDK" --sysroot="$MUSL_SDK/x86_64-linux-musl" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y - name: Build with xmake run: xmake -j$(nproc) From f11462a2ae71f042422bba24570d26f559eb2359 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 01:54:24 +0800 Subject: [PATCH 09/28] ci: use static linking instead of musl-gcc for Linux builds Switch Linux static portability strategy from musl-gcc cross-compilation (incompatible with xmake v3.0.7 package builds) to -static ldflags in xmake.lua. xmake builds all dependencies (libcurl, ftxui, cmdline) as static libs by default, so -static produces a fully self-contained binary using the system gcc toolchain. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 54 ++++------------------------------- .github/workflows/release.yml | 54 ++++------------------------------- xmake.lua | 2 +- 3 files changed, 13 insertions(+), 97 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e20b15..db6ba5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,6 @@ on: pull_request: branches: [main] -env: - XMAKE_VERSION: v3.0.7 - jobs: build-linux: runs-on: ubuntu-24.04 @@ -19,54 +16,15 @@ jobs: - name: Install system deps run: | sudo apt-get update -qq - sudo apt-get install -y curl git build-essential + sudo apt-get install -y build-essential - - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) - run: | - XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" - curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" - chmod +x xmake.bin - mkdir -p xmake/bin - mv xmake.bin xmake/bin/xmake - echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" - xmake --version - - - name: Install Xlings - env: - XLINGS_NON_INTERACTIVE: 1 - run: | - curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash - echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" - echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - - name: Install musl-gcc 15.1 - run: | - MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 - mkdir -p "$MUSL_SDK" - curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 - echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" - echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" - echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" - echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$MUSL_SDK/bin:$PATH" - test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" - x86_64-linux-musl-g++ --version - - - name: Setup musl runtime - run: | - LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" - LOADER_DIR="/home/xlings/.xlings_data/lib" - sudo mkdir -p "$LOADER_DIR" - sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" - sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 - echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: latest - name: Configure xmake - run: | - xmake f -c -p linux -m release --sdk="$MUSL_SDK" --sysroot="$MUSL_SDK/x86_64-linux-musl" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y + run: xmake f -p linux -m release -y - name: Build with xmake run: xmake -j$(nproc) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10baf08..5fb63f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,9 +8,6 @@ on: required: true type: string -env: - XMAKE_VERSION: v3.0.7 - jobs: build-linux: runs-on: ubuntu-24.04 @@ -21,54 +18,15 @@ jobs: - name: Install system deps run: | sudo apt-get update -qq - sudo apt-get install -y curl git build-essential - - - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) - run: | - XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" - curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" - chmod +x xmake.bin - mkdir -p xmake/bin - mv xmake.bin xmake/bin/xmake - echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" - xmake --version - - - name: Install Xlings - env: - XLINGS_NON_INTERACTIVE: 1 - run: | - curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash - echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" - echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + sudo apt-get install -y build-essential - - name: Install musl-gcc 15.1 - run: | - MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 - mkdir -p "$MUSL_SDK" - curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 - echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" - echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" - echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" - echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$MUSL_SDK/bin:$PATH" - test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" - x86_64-linux-musl-g++ --version - - - name: Setup musl runtime - run: | - LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" - LOADER_DIR="/home/xlings/.xlings_data/lib" - sudo mkdir -p "$LOADER_DIR" - sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" - sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 - echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: latest - name: Configure xmake - run: | - xmake f -c -p linux -m release --sdk="$MUSL_SDK" --sysroot="$MUSL_SDK/x86_64-linux-musl" --cross=x86_64-linux-musl- --cc="$CC" --cxx="$CXX" -y + run: xmake f -p linux -m release -y - name: Build with xmake run: xmake -j$(nproc) diff --git a/xmake.lua b/xmake.lua index d8fde2f..d32a11f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -24,6 +24,6 @@ target("d2x") add_linkdirs(llvm_prefix .. "/lib/c++") add_ldflags("-Wl,-rpath," .. llvm_prefix .. "/lib/c++", {force = true}) elseif is_plat("linux") then - add_ldflags("-static-libstdc++", "-static-libgcc", {force = true}) + add_ldflags("-static", {force = true}) end From 6cc91b5b85a09032d6559049b479f48e3f278da8 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 01:58:25 +0800 Subject: [PATCH 10/28] ci: fix musl-gcc sysroot for cmake package builds cmake adds -isystem /usr/include which gcc --sysroot remaps to $SYSROOT/usr/include. Create usr/include and usr/lib symlinks in the musl sysroot so the remapping resolves to musl headers instead of falling through to glibc headers. Pass --sysroot via --cflags/--cxxflags (xmake f has no --sysroot flag) and also export CFLAGS/CXXFLAGS so cmake package builds inherit it. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 68 +++++++++++++++++++++++++++++++---- .github/workflows/release.yml | 68 +++++++++++++++++++++++++++++++---- 2 files changed, 124 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db6ba5d..879aa53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [main] +env: + XMAKE_VERSION: v3.0.7 + jobs: build-linux: runs-on: ubuntu-24.04 @@ -16,15 +19,68 @@ jobs: - name: Install system deps run: | sudo apt-get update -qq - sudo apt-get install -y build-essential + sudo apt-get install -y curl git build-essential - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: latest + - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) + run: | + XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" + curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" + chmod +x xmake.bin + mkdir -p xmake/bin + mv xmake.bin xmake/bin/xmake + echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" + xmake --version + + - name: Install Xlings + env: + XLINGS_NON_INTERACTIVE: 1 + run: | + curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash + echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + + - name: Install musl-gcc 15.1 + run: | + MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 + mkdir -p "$MUSL_SDK" + curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 + echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" + echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" + echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" + echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$MUSL_SDK/bin:$PATH" + test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" + x86_64-linux-musl-g++ --version + # Create usr/{include,lib} symlinks so gcc --sysroot remaps cmake's + # -isystem /usr/include to the musl sysroot instead of glibc headers + mkdir -p "$MUSL_SDK/x86_64-linux-musl/usr" + ln -sfn "$MUSL_SDK/x86_64-linux-musl/include" "$MUSL_SDK/x86_64-linux-musl/usr/include" + ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib" "$MUSL_SDK/x86_64-linux-musl/usr/lib" + + - name: Setup musl runtime + run: | + LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" + LOADER_DIR="/home/xlings/.xlings_data/lib" + sudo mkdir -p "$LOADER_DIR" + sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" + sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 + echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 - name: Configure xmake - run: xmake f -p linux -m release -y + run: | + SYSROOT="$MUSL_SDK/x86_64-linux-musl" + export CFLAGS="--sysroot=$SYSROOT" + export CXXFLAGS="--sysroot=$SYSROOT" + xmake f -c -p linux -m release \ + --sdk="$MUSL_SDK" \ + --cross=x86_64-linux-musl- \ + --cc="$CC" --cxx="$CXX" \ + --cflags="--sysroot=$SYSROOT" \ + --cxxflags="--sysroot=$SYSROOT" \ + -y - name: Build with xmake run: xmake -j$(nproc) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fb63f5..39fae7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,9 @@ on: required: true type: string +env: + XMAKE_VERSION: v3.0.7 + jobs: build-linux: runs-on: ubuntu-24.04 @@ -18,15 +21,68 @@ jobs: - name: Install system deps run: | sudo apt-get update -qq - sudo apt-get install -y build-essential + sudo apt-get install -y curl git build-essential - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: latest + - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) + run: | + XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" + curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" + chmod +x xmake.bin + mkdir -p xmake/bin + mv xmake.bin xmake/bin/xmake + echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" + xmake --version + + - name: Install Xlings + env: + XLINGS_NON_INTERACTIVE: 1 + run: | + curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash + echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + + - name: Install musl-gcc 15.1 + run: | + MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 + mkdir -p "$MUSL_SDK" + curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 + echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" + echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" + echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" + echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" + export PATH="$MUSL_SDK/bin:$PATH" + test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" + x86_64-linux-musl-g++ --version + # Create usr/{include,lib} symlinks so gcc --sysroot remaps cmake's + # -isystem /usr/include to the musl sysroot instead of glibc headers + mkdir -p "$MUSL_SDK/x86_64-linux-musl/usr" + ln -sfn "$MUSL_SDK/x86_64-linux-musl/include" "$MUSL_SDK/x86_64-linux-musl/usr/include" + ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib" "$MUSL_SDK/x86_64-linux-musl/usr/lib" + + - name: Setup musl runtime + run: | + LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" + LOADER_DIR="/home/xlings/.xlings_data/lib" + sudo mkdir -p "$LOADER_DIR" + sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" + sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 + echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 + sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 - name: Configure xmake - run: xmake f -p linux -m release -y + run: | + SYSROOT="$MUSL_SDK/x86_64-linux-musl" + export CFLAGS="--sysroot=$SYSROOT" + export CXXFLAGS="--sysroot=$SYSROOT" + xmake f -c -p linux -m release \ + --sdk="$MUSL_SDK" \ + --cross=x86_64-linux-musl- \ + --cc="$CC" --cxx="$CXX" \ + --cflags="--sysroot=$SYSROOT" \ + --cxxflags="--sysroot=$SYSROOT" \ + -y - name: Build with xmake run: xmake -j$(nproc) From b2f81597cd0d6694df0e0379858d8c1bf98461bd Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 02:17:17 +0800 Subject: [PATCH 11/28] ci: simplify Linux build via xlings install xmake and gcc Install xmake@3.0.7 and gcc@15 through xlings instead of manual musl-gcc cross-compilation setup. xlings handles toolchain management and exposes binaries via subos/current/bin. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 64 ++++------------------------------- .github/workflows/release.yml | 64 ++++------------------------------- 2 files changed, 12 insertions(+), 116 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 879aa53..b19ae4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,6 @@ on: pull_request: branches: [main] -env: - XMAKE_VERSION: v3.0.7 - jobs: build-linux: runs-on: ubuntu-24.04 @@ -21,69 +18,20 @@ jobs: sudo apt-get update -qq sudo apt-get install -y curl git build-essential - - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) - run: | - XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" - curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" - chmod +x xmake.bin - mkdir -p xmake/bin - mv xmake.bin xmake/bin/xmake - echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" - xmake --version - - name: Install Xlings env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash - echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" + curl -fsSL https://d2learn.org/xlings-install.sh | bash echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - name: Install musl-gcc 15.1 - run: | - MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 - mkdir -p "$MUSL_SDK" - curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 - echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" - echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" - echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" - echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$MUSL_SDK/bin:$PATH" - test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" - x86_64-linux-musl-g++ --version - # Create usr/{include,lib} symlinks so gcc --sysroot remaps cmake's - # -isystem /usr/include to the musl sysroot instead of glibc headers - mkdir -p "$MUSL_SDK/x86_64-linux-musl/usr" - ln -sfn "$MUSL_SDK/x86_64-linux-musl/include" "$MUSL_SDK/x86_64-linux-musl/usr/include" - ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib" "$MUSL_SDK/x86_64-linux-musl/usr/lib" - - - name: Setup musl runtime - run: | - LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" - LOADER_DIR="/home/xlings/.xlings_data/lib" - sudo mkdir -p "$LOADER_DIR" - sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" - sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 - echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 - - - name: Configure xmake - run: | - SYSROOT="$MUSL_SDK/x86_64-linux-musl" - export CFLAGS="--sysroot=$SYSROOT" - export CXXFLAGS="--sysroot=$SYSROOT" - xmake f -c -p linux -m release \ - --sdk="$MUSL_SDK" \ - --cross=x86_64-linux-musl- \ - --cc="$CC" --cxx="$CXX" \ - --cflags="--sysroot=$SYSROOT" \ - --cxxflags="--sysroot=$SYSROOT" \ - -y + - name: Install xmake and gcc via Xlings + run: xlings install xmake@3.0.7 gcc@15 -y - name: Build with xmake - run: xmake -j$(nproc) + run: | + xmake f -m release -y + xmake -j$(nproc) - name: Verify d2x --version run: ./build/linux/x86_64/release/d2x --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 39fae7d..ef04f4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,9 +8,6 @@ on: required: true type: string -env: - XMAKE_VERSION: v3.0.7 - jobs: build-linux: runs-on: ubuntu-24.04 @@ -23,69 +20,20 @@ jobs: sudo apt-get update -qq sudo apt-get install -y curl git build-essential - - name: Install xmake (bundled ${{ env.XMAKE_VERSION }}) - run: | - XMAKE_URL="https://github.com/xmake-io/xmake/releases/download/${{ env.XMAKE_VERSION }}/xmake-bundle-${{ env.XMAKE_VERSION }}.linux.x86_64" - curl -fsSL -o xmake.bin "$XMAKE_URL" -H "Accept: application/octet-stream" - chmod +x xmake.bin - mkdir -p xmake/bin - mv xmake.bin xmake/bin/xmake - echo "PATH=$GITHUB_WORKSPACE/xmake/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$GITHUB_WORKSPACE/xmake/bin:$PATH" - xmake --version - - name: Install Xlings env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash - echo "XLINGS_HOME=$HOME/.xlings" >> "$GITHUB_ENV" + curl -fsSL https://d2learn.org/xlings-install.sh | bash echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - name: Install musl-gcc 15.1 - run: | - MUSL_SDK=$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/15.1.0 - mkdir -p "$MUSL_SDK" - curl -fSL# https://github.com/xlings-res/musl-gcc/releases/download/15.1.0/musl-gcc-15.1.0-linux-x86_64.tar.gz | tar xz -C "$MUSL_SDK" --strip-components=1 - echo "MUSL_SDK=$MUSL_SDK" >> "$GITHUB_ENV" - echo "CC=x86_64-linux-musl-gcc" >> "$GITHUB_ENV" - echo "CXX=x86_64-linux-musl-g++" >> "$GITHUB_ENV" - echo "PATH=$MUSL_SDK/bin:$PATH" >> "$GITHUB_ENV" - export PATH="$MUSL_SDK/bin:$PATH" - test -f "$MUSL_SDK/x86_64-linux-musl/include/c++/15.1.0/bits/std.cc" - x86_64-linux-musl-g++ --version - # Create usr/{include,lib} symlinks so gcc --sysroot remaps cmake's - # -isystem /usr/include to the musl sysroot instead of glibc headers - mkdir -p "$MUSL_SDK/x86_64-linux-musl/usr" - ln -sfn "$MUSL_SDK/x86_64-linux-musl/include" "$MUSL_SDK/x86_64-linux-musl/usr/include" - ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib" "$MUSL_SDK/x86_64-linux-musl/usr/lib" - - - name: Setup musl runtime - run: | - LIBC_SO="$MUSL_SDK/x86_64-linux-musl/lib/libc.so" - LOADER_DIR="/home/xlings/.xlings_data/lib" - sudo mkdir -p "$LOADER_DIR" - sudo ln -sfn "$LIBC_SO" "$LOADER_DIR/ld-musl-x86_64.so.1" - sudo ln -sfn "$LIBC_SO" /lib/ld-musl-x86_64.so.1 - echo "$MUSL_SDK/x86_64-linux-musl/lib" | sudo tee /etc/ld-musl-x86_64.path > /dev/null - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libstdc++.so.6" /lib/libstdc++.so.6 - sudo ln -sfn "$MUSL_SDK/x86_64-linux-musl/lib/libgcc_s.so.1" /lib/libgcc_s.so.1 - - - name: Configure xmake - run: | - SYSROOT="$MUSL_SDK/x86_64-linux-musl" - export CFLAGS="--sysroot=$SYSROOT" - export CXXFLAGS="--sysroot=$SYSROOT" - xmake f -c -p linux -m release \ - --sdk="$MUSL_SDK" \ - --cross=x86_64-linux-musl- \ - --cc="$CC" --cxx="$CXX" \ - --cflags="--sysroot=$SYSROOT" \ - --cxxflags="--sysroot=$SYSROOT" \ - -y + - name: Install xmake and gcc via Xlings + run: xlings install xmake@3.0.7 gcc@15 -y - name: Build with xmake - run: xmake -j$(nproc) + run: | + xmake f -m release -y + xmake -j$(nproc) - name: Create release package run: | From c438a3461f303af9f64e1a3976d5f6b7bf2caabb Mon Sep 17 00:00:00 2001 From: SPeak Shen Date: Sat, 7 Mar 2026 07:10:22 +0800 Subject: [PATCH 12/28] update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b19ae4d..b4abb0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Build with xmake run: | - xmake f -m release -y + xmake f -m release -vv -y xmake -j$(nproc) - name: Verify d2x --version From 7c86ea9b3e98eb99833b2f5cd74e46afc90ef940 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 22:08:44 +0800 Subject: [PATCH 13/28] update --- .github/workflows/ci.yml | 26 +++++++++++++++++++++++++- .github/workflows/release.yml | 17 +++++++++-------- xmake.lua | 5 +---- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4abb0f..c1e7e3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install xmake and gcc via Xlings - run: xlings install xmake@3.0.7 gcc@15 -y + run: xlings install xmake@3.0.7 gcc@15 openssl@3.1.5 -y - name: Build with xmake run: | @@ -35,3 +35,27 @@ jobs: - name: Verify d2x --version run: ./build/linux/x86_64/release/d2x --version + + build-macos: + runs-on: macos-14 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Xlings + env: + XLINGS_NON_INTERACTIVE: 1 + run: | + curl -fsSL https://d2learn.org/xlings-install.sh | bash + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + + - name: Install xmake and llvm@20 via Xlings + run: xlings install xmake@3.0.7 llvm@20 -y + + - name: Build with xmake + run: | + xmake f -m release -vv -y + xmake -j$(nproc) + + - name: Verify d2x --version + run: ./build/macosx/arm64/release/d2x --version \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef04f4c..90b7998 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install xmake and gcc via Xlings - run: xlings install xmake@3.0.7 gcc@15 -y + run: xlings install xmake@3.0.7 gcc@15 openssl@3.1.5 -y - name: Build with xmake run: | @@ -53,14 +53,15 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install system deps - run: brew install xmake llvm@20 - - - name: Build with xmake (LLVM 20 toolchain) + - name: Install Xlings + env: + XLINGS_NON_INTERACTIVE: 1 run: | - export PATH=/opt/homebrew/opt/llvm@20/bin:$PATH - xmake f -p macosx -m release --toolchain=llvm --sdk=/opt/homebrew/opt/llvm@20 -y - xmake -j$(sysctl -n hw.ncpu) + curl -fsSL https://d2learn.org/xlings-install.sh | bash + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + + - name: Install xmake and llvm@20 via Xlings + run: xlings install xmake@3.0.7 llvm@20 -y - name: Verify no LLVM runtime dependency run: | diff --git a/xmake.lua b/xmake.lua index d32a11f..470ffc3 100644 --- a/xmake.lua +++ b/xmake.lua @@ -19,10 +19,7 @@ target("d2x") -- platform specific settings if is_plat("macosx") then - - local llvm_prefix = os.getenv("LLVM_PREFIX") or "/opt/homebrew/opt/llvm@20" - add_linkdirs(llvm_prefix .. "/lib/c++") - add_ldflags("-Wl,-rpath," .. llvm_prefix .. "/lib/c++", {force = true}) + set_toolchains("llvm") elseif is_plat("linux") then add_ldflags("-static", {force = true}) end From 27eec96a89337d1e732a0e3ea1bf0a5a703c58b6 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 22:22:49 +0800 Subject: [PATCH 14/28] update --- xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake.lua b/xmake.lua index 470ffc3..aab0947 100644 --- a/xmake.lua +++ b/xmake.lua @@ -5,7 +5,7 @@ set_languages("c++23") add_repositories("mcpplibs-index https://github.com/mcpplibs/mcpplibs-index.git") add_requires("llmapi 0.0.2") -add_requires("cmdline 0.0.1") +add_requires("cmdline 0.0.2") add_requires("ftxui 6.1.9") target("d2x") From dfa3423de6a1dcc05c4e2d28928c50481099aa7c Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 7 Mar 2026 23:09:57 +0800 Subject: [PATCH 15/28] add macos min version for build's binary --- xmake.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xmake.lua b/xmake.lua index aab0947..dd91e79 100644 --- a/xmake.lua +++ b/xmake.lua @@ -20,6 +20,9 @@ target("d2x") -- platform specific settings if is_plat("macosx") then set_toolchains("llvm") + add_cflags("-mmacosx-version-min=11.0") + add_cxxflags("-mmacosx-version-min=11.0") + add_ldflags("-mmacosx-version-min=11.0") elseif is_plat("linux") then add_ldflags("-static", {force = true}) end From a143906d3d53daa5ab695baf0e0a466b257df832 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 00:20:43 +0800 Subject: [PATCH 16/28] update xlings install script's link --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1e7e3c..70dcc79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://d2learn.org/xlings-install.sh | bash + curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.sh | bash echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install xmake and llvm@20 via Xlings diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 90b7998..50b990c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,7 +57,7 @@ jobs: env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://d2learn.org/xlings-install.sh | bash + curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.sh | bash echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install xmake and llvm@20 via Xlings From 2433431105dc81bc2e5da292e1aef99e9ab9af85 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 01:09:03 +0800 Subject: [PATCH 17/28] update config.xlings to .xlings.json --- .xlings.json | 8 ++++++++ config.xlings | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 .xlings.json delete mode 100644 config.xlings diff --git a/.xlings.json b/.xlings.json new file mode 100644 index 0000000..3fb332f --- /dev/null +++ b/.xlings.json @@ -0,0 +1,8 @@ +{ + "workspace": { + "xmake": "3.0.7", + "gcc": { "linux": "15.1.0" }, + "openssl": { "linux": "3.1.5" }, + "llvm": { "macos": "20" } + } +} \ No newline at end of file diff --git a/config.xlings b/config.xlings deleted file mode 100644 index ea3a52e..0000000 --- a/config.xlings +++ /dev/null @@ -1,8 +0,0 @@ --- https://github.com/d2learn/xlings - -xname = "d2x" - -xim = { - xmake = "3.0.4", - cpp = "", -} \ No newline at end of file From e2a428b74d93dbc7c9617dc4bf0e29330c4571f2 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 03:43:33 +0800 Subject: [PATCH 18/28] update ci, download xlings directly --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++------- .github/workflows/release.yml | 30 +++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70dcc79..359fcd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [main] +env: + XLINGS_VERSION: v0.4.0 + jobs: build-linux: runs-on: ubuntu-24.04 @@ -22,11 +25,17 @@ jobs: env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://d2learn.org/xlings-install.sh | bash + VERSION_NUM="${XLINGS_VERSION#v}" + TARBALL="xlings-${VERSION_NUM}-linux-x86_64.tar.gz" + curl -fSL -o "$RUNNER_TEMP/$TARBALL" "https://github.com/d2learn/xlings/releases/download/${XLINGS_VERSION}/${TARBALL}" + tar -xzf "$RUNNER_TEMP/$TARBALL" -C "$RUNNER_TEMP" + EXTRACT_DIR=$(find "$RUNNER_TEMP" -maxdepth 1 -type d -name "xlings-*" | head -1) + chmod +x "$EXTRACT_DIR/bin/xlings" + "$EXTRACT_DIR/bin/xlings" self install echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - name: Install xmake and gcc via Xlings - run: xlings install xmake@3.0.7 gcc@15 openssl@3.1.5 -y + - name: Install Project Dependencies via Xlings + run: xlings install - name: Build with xmake run: | @@ -46,11 +55,18 @@ jobs: env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.sh | bash + VERSION_NUM="${XLINGS_VERSION#v}" + TARBALL="xlings-${VERSION_NUM}-macosx-arm64.tar.gz" + curl -fSL -o "$RUNNER_TEMP/$TARBALL" "https://github.com/d2learn/xlings/releases/download/${XLINGS_VERSION}/${TARBALL}" + tar -xzf "$RUNNER_TEMP/$TARBALL" -C "$RUNNER_TEMP" + EXTRACT_DIR=$(find "$RUNNER_TEMP" -maxdepth 1 -type d -name "xlings-*" | head -1) + xattr -dr com.apple.quarantine "$EXTRACT_DIR" 2>/dev/null || true + chmod +x "$EXTRACT_DIR/bin/xlings" + "$EXTRACT_DIR/bin/xlings" self install echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - - name: Install xmake and llvm@20 via Xlings - run: xlings install xmake@3.0.7 llvm@20 -y + + - name: Install Project Dependencies via Xlings + run: xlings install - name: Build with xmake run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50b990c..102acd2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,9 @@ on: required: true type: string +env: + XLINGS_VERSION: v0.4.0 + jobs: build-linux: runs-on: ubuntu-24.04 @@ -24,11 +27,17 @@ jobs: env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://d2learn.org/xlings-install.sh | bash + VERSION_NUM="${XLINGS_VERSION#v}" + TARBALL="xlings-${VERSION_NUM}-linux-x86_64.tar.gz" + curl -fSL -o "$RUNNER_TEMP/$TARBALL" "https://github.com/d2learn/xlings/releases/download/${XLINGS_VERSION}/${TARBALL}" + tar -xzf "$RUNNER_TEMP/$TARBALL" -C "$RUNNER_TEMP" + EXTRACT_DIR=$(find "$RUNNER_TEMP" -maxdepth 1 -type d -name "xlings-*" | head -1) + chmod +x "$EXTRACT_DIR/bin/xlings" + "$EXTRACT_DIR/bin/xlings" self install echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - name: Install xmake and gcc via Xlings - run: xlings install xmake@3.0.7 gcc@15 openssl@3.1.5 -y + - name: Install Project Dependencies via Xlings + run: xlings install - name: Build with xmake run: | @@ -57,11 +66,18 @@ jobs: env: XLINGS_NON_INTERACTIVE: 1 run: | - curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.sh | bash + VERSION_NUM="${XLINGS_VERSION#v}" + TARBALL="xlings-${VERSION_NUM}-macosx-arm64.tar.gz" + curl -fSL -o "$RUNNER_TEMP/$TARBALL" "https://github.com/d2learn/xlings/releases/download/${XLINGS_VERSION}/${TARBALL}" + tar -xzf "$RUNNER_TEMP/$TARBALL" -C "$RUNNER_TEMP" + EXTRACT_DIR=$(find "$RUNNER_TEMP" -maxdepth 1 -type d -name "xlings-*" | head -1) + xattr -dr com.apple.quarantine "$EXTRACT_DIR" 2>/dev/null || true + chmod +x "$EXTRACT_DIR/bin/xlings" + "$EXTRACT_DIR/bin/xlings" self install echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - - - name: Install xmake and llvm@20 via Xlings - run: xlings install xmake@3.0.7 llvm@20 -y + + - name: Install Project Dependencies via Xlings + run: xlings install - name: Verify no LLVM runtime dependency run: | From 40a056d7f81b312164f9bd1424b4c81186f977ac Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 04:09:20 +0800 Subject: [PATCH 19/28] update --- .github/workflows/ci.yml | 8 ++++++-- .github/workflows/release.yml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 359fcd1..4349d23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,9 @@ jobs: echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install Project Dependencies via Xlings - run: xlings install + run: | + xlings install + xmake --version - name: Build with xmake run: | @@ -66,7 +68,9 @@ jobs: echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install Project Dependencies via Xlings - run: xlings install + run: | + xlings install + xmake --version - name: Build with xmake run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 102acd2..f82b1ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,9 @@ jobs: echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install Project Dependencies via Xlings - run: xlings install + run: | + xlings install + xmake --version - name: Build with xmake run: | @@ -77,7 +79,9 @@ jobs: echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - name: Install Project Dependencies via Xlings - run: xlings install + run: | + xlings install + xmake --version - name: Verify no LLVM runtime dependency run: | From 53f16a6de4f86a345be32a94958e025a8d0f7fdc Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 04:34:52 +0800 Subject: [PATCH 20/28] update --- .github/workflows/ci.yml | 4 ++++ .github/workflows/release.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4349d23..296cf90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + ls -al $HOME/.xlings/subos/current/bin xmake --version - name: Build with xmake @@ -70,6 +72,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + ls -al $HOME/.xlings/subos/current/bin xmake --version - name: Build with xmake diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f82b1ee..67fdce4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + ls -al $HOME/.xlings/subos/current/bin xmake --version - name: Build with xmake @@ -81,6 +83,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install + echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" + ls -al $HOME/.xlings/subos/current/bin xmake --version - name: Verify no LLVM runtime dependency From c342b941c423d085adb59a2a4024e4bdd2a8a35b Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 04:50:46 +0800 Subject: [PATCH 21/28] fix subos bin dir --- .github/workflows/ci.yml | 10 ++++------ .github/workflows/release.yml | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 296cf90..0ef83e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,9 +37,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install - echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - ls -al $HOME/.xlings/subos/current/bin - xmake --version + CURRENT_DIR=$(pwd) + echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" - name: Build with xmake run: | @@ -72,9 +71,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install - echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - ls -al $HOME/.xlings/subos/current/bin - xmake --version + CURRENT_DIR=$(pwd) + echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" - name: Build with xmake run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67fdce4..35e4571 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,9 +39,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install - echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - ls -al $HOME/.xlings/subos/current/bin - xmake --version + CURRENT_DIR=$(pwd) + echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" - name: Build with xmake run: | @@ -83,9 +82,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | xlings install - echo "PATH=$HOME/.xlings/subos/current/bin:$PATH" >> "$GITHUB_ENV" - ls -al $HOME/.xlings/subos/current/bin - xmake --version + CURRENT_DIR=$(pwd) + echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" - name: Verify no LLVM runtime dependency run: | From f7db076b46d95c33126adcfaefed8ebf086eb6d2 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 04:58:01 +0800 Subject: [PATCH 22/28] update --- .github/workflows/ci.yml | 13 +++++++------ .github/workflows/release.yml | 11 +++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ef83e6..46eb404 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,9 +36,10 @@ jobs: - name: Install Project Dependencies via Xlings run: | - xlings install - CURRENT_DIR=$(pwd) - echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" + #xlings install + cd .. + xlings install xmake@3.0.7 gcc@15 openssl@3.1.5 -y + - name: Build with xmake run: | @@ -70,9 +71,9 @@ jobs: - name: Install Project Dependencies via Xlings run: | - xlings install - CURRENT_DIR=$(pwd) - echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" + cd .. + xlings install xmake@3.0.7 llvm@20 -y + - name: Build with xmake run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 35e4571..c08606a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,9 +38,8 @@ jobs: - name: Install Project Dependencies via Xlings run: | - xlings install - CURRENT_DIR=$(pwd) - echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" + cd .. + xlings install xmake@3.0.7 gcc@15 openssl@3.1.5 -y - name: Build with xmake run: | @@ -81,9 +80,9 @@ jobs: - name: Install Project Dependencies via Xlings run: | - xlings install - CURRENT_DIR=$(pwd) - echo "PATH=$CURRENT_DIR/.xlings/subos/_/bin:$PATH" >> "$GITHUB_ENV" + cd .. + xlings install xmake@3.0.7 llvm@20 -y + - name: Verify no LLVM runtime dependency run: | From 1ecfa64a3fd02a479a834a05f2754f4b9349aeee Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 05:08:04 +0800 Subject: [PATCH 23/28] add windows ci --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46eb404..b1b7fd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,4 +81,23 @@ jobs: xmake -j$(nproc) - name: Verify d2x --version - run: ./build/macosx/arm64/release/d2x --version \ No newline at end of file + run: ./build/macosx/arm64/release/d2x --version + + build-windows: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: latest + + - name: Build with xmake + run: | + xmake f -m release -y + xmake -j$env:NUMBER_OF_PROCESSORS + + - name: Verify d2x --version + run: build\windows\x64\release\d2x.exe --version \ No newline at end of file From 60495c9c792f94cfbc3d90b601b41316d7b3d482 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 07:48:36 +0800 Subject: [PATCH 24/28] update --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1b7fd5..9880ba4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: run: ./build/linux/x86_64/release/d2x --version build-macos: - runs-on: macos-14 + runs-on: [macos-latest] steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c08606a..78a8a8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: path: d2x-${{ inputs.version }}-linux-x86_64.tar.gz build-macos: - runs-on: macos-14 + runs-on: [macos-latest] steps: - name: Checkout code uses: actions/checkout@v4 From 7ecd6e492e41e7be8727fcd370b1dc246d01ccfe Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 07:59:04 +0800 Subject: [PATCH 25/28] update --- .github/workflows/ci.yml | 1 + .github/workflows/release.yml | 1 + xmake.lua | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9880ba4..fe86e0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,6 +73,7 @@ jobs: run: | cd .. xlings install xmake@3.0.7 llvm@20 -y + clang --version - name: Build with xmake diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 78a8a8c..4f5493d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,7 @@ jobs: run: | cd .. xlings install xmake@3.0.7 llvm@20 -y + clang --version - name: Verify no LLVM runtime dependency diff --git a/xmake.lua b/xmake.lua index dd91e79..e91ce3b 100644 --- a/xmake.lua +++ b/xmake.lua @@ -20,9 +20,14 @@ target("d2x") -- platform specific settings if is_plat("macosx") then set_toolchains("llvm") - add_cflags("-mmacosx-version-min=11.0") - add_cxxflags("-mmacosx-version-min=11.0") - add_ldflags("-mmacosx-version-min=11.0") + local llvm_prefix = os.getenv("LLVM_PREFIX") + if llvm_prefix then -- if LLVM_PREFIX is set, we assume it's a recent version of LLVM that provides its own libc++ with C++23 support + -- 静态链接 LLVM 自带的 libc++,避免依赖系统 libc++.dylib 中缺失的 C++23 符号 + -- (std::println 等 C++23 特性需要 macOS 15+ 的 libc++,静态链接后可在 macOS 11+ 运行) + add_ldflags("-nostdlib++", {force = true}) + add_ldflags(llvm_prefix .. "/lib/libc++.a", {force = true}) + add_ldflags(llvm_prefix .. "/lib/libc++abi.a", {force = true}) + end elseif is_plat("linux") then add_ldflags("-static", {force = true}) end From 908867d1c4c5098c0a5d1d0f48d074b09ff633e9 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 08:10:39 +0800 Subject: [PATCH 26/28] update --- .github/workflows/ci.yml | 3 ++- .github/workflows/release.yml | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe86e0f..69439ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,8 @@ jobs: - name: Build with xmake run: | - xmake f -m release -vv -y + export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.0.7 + xmake f -m release --toolchain=llvm --sdk=$LLVM_PREFIX -vv -y xmake -j$(nproc) - name: Verify d2x --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f5493d..d00a02f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,6 +84,11 @@ jobs: xlings install xmake@3.0.7 llvm@20 -y clang --version + - name: Build with xmake + run: | + export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.0.7 + xmake f -m release --toolchain=llvm --sdk=$LLVM_PREFIX -vv -y + xmake -j$(nproc) - name: Verify no LLVM runtime dependency run: | From 16fcc449852c9fde281cc89da740ffbbe768f072 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 08:15:54 +0800 Subject: [PATCH 27/28] update --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69439ef..67a547c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,6 +79,7 @@ jobs: - name: Build with xmake run: | export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.0.7 + ls -al $LLVM_PREFIX xmake f -m release --toolchain=llvm --sdk=$LLVM_PREFIX -vv -y xmake -j$(nproc) From 29dd030bc2a294bc1bdeb472955db9193a297907 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 8 Mar 2026 08:17:54 +0800 Subject: [PATCH 28/28] update --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67a547c..e9ceef4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: - name: Build with xmake run: | - export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.0.7 + export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.1.7 ls -al $LLVM_PREFIX xmake f -m release --toolchain=llvm --sdk=$LLVM_PREFIX -vv -y xmake -j$(nproc) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d00a02f..d7c9d45 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,7 +86,7 @@ jobs: - name: Build with xmake run: | - export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.0.7 + export LLVM_PREFIX=$HOME/.xlings/data/xpkgs/xim-x-llvm/20.1.7 xmake f -m release --toolchain=llvm --sdk=$LLVM_PREFIX -vv -y xmake -j$(nproc)