From e1c083b6d49a5855bcea3334dca59a5ae351c48d Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 13:19:13 +0900 Subject: [PATCH 1/8] DIAGNOSTIC (do not merge): Windows startup exit 133 --- .github/workflows/ci.yml | 6 +- .github/workflows/templates.yml | 3 - .github/workflows/windows-diag.yml | 116 +++++++++++++++++++++++++++++ mcpp.toml | 2 +- tests/module.cpp | 6 ++ tests/startup.cpp | 10 +++ 6 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/windows-diag.yml create mode 100644 tests/startup.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc30a6b..8051d15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,7 @@ name: CI # rules/, plugin/, src/ — the contract checks (templates/greeter == # examples/greeter, source list == upstream CMakeLists) read those. on: - push: - branches: [main] - paths-ignore: ["**.md", ".agents/**", "LICENSE"] - pull_request: - paths-ignore: ["**.md", ".agents/**", "LICENSE"] + workflow_dispatch: env: # Keep in step with the mcpp-index CI pin: this package's dependencies are diff --git a/.github/workflows/templates.yml b/.github/workflows/templates.yml index ccad559..88de5d7 100644 --- a/.github/workflows/templates.yml +++ b/.github/workflows/templates.yml @@ -1,8 +1,5 @@ name: Actual project templates on: - push: - branches: [main] - pull_request: workflow_dispatch: permissions: contents: read diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml new file mode 100644 index 0000000..41a4c95 --- /dev/null +++ b/.github/workflows/windows-diag.yml @@ -0,0 +1,116 @@ +name: Windows startup diagnosis (temporary) + +# TEMPORARY, draft PR only: why does the module test end with "exit 133" on +# Windows? Builds the tests, then runs each test program directly (raw exit +# status), under cdb (stack at the exception) and keeps the programs. +on: + pull_request: + workflow_dispatch: + +concurrency: + group: windows-diag-${{ github.ref }} + cancel-in-progress: true + +env: + MCPP_VERSION: "2026.11.18.1" + MCPP_INDEX_MIRROR: GLOBAL + +jobs: + diag: + runs-on: windows-2025 + timeout-minutes: 210 + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: | + mcpp-2026.11.18.1-windows-x86_64 + target + key: win-diag-${{ github.run_id }}-${{ github.run_attempt }} + restore-keys: win-diag- + + - name: mcpp + shell: bash + run: | + root="$PWD/mcpp-${MCPP_VERSION}-windows-x86_64" + if [ ! -f "$root/bin/mcpp.exe" ]; then + archive="mcpp-${MCPP_VERSION}-windows-x86_64.zip" + curl -L -fsS -o "$archive" "https://github.com/mcpp-community/mcpp/releases/download/v${MCPP_VERSION}/$archive" + unzip -q "$archive" + fi + echo "MCPP=$(cygpath -m "$root/bin/mcpp.exe")" >> "$GITHUB_ENV" + echo "MCPP_VENDORED_XLINGS=$(cygpath -m "$root/registry/bin/xlings")" >> "$GITHUB_ENV" + echo "MCPP_ROOT=$(cygpath -m "$root")" >> "$GITHUB_ENV" + "$root/bin/mcpp.exe" index update + + - name: mcpp test + id: test + continue-on-error: true + shell: bash + run: | + "$MCPP" --version + "$MCPP" test + + - name: Locate the test programs and tools + shell: bash + run: | + find target -iname '*.exe' -path '*test*' -printf '%s %p\n' 2>/dev/null | sort -k2 | tail -40 || true + find target -iname '*.pdb' -printf '%s %p\n' | tail -20 || true + find "$MCPP_ROOT" -iname 'lldb.exe' -o -iname 'llvm-readobj.exe' -o -iname 'llvm-symbolizer.exe' | head + ls "/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/cdb.exe" || echo "no cdb" + for t in startup module; do + exe=$(find target -iname "$t.exe" | head -1) + echo "$t=$(cygpath -w "$exe")" >> "$GITHUB_ENV" + done + # How the test programs were compiled and linked. + for nj in $(find target -name build.ninja); do + grep -n -E 'module\.exe|startup\.exe' "$nj" | head -5 && echo "^^ $nj" + done + nj=$(grep -l 'module\.exe' $(find target -name build.ninja) | head -1) + [ -n "$nj" ] && grep -n -E '^ *(cxxflags|ldflags|command|link_flags) *=' "$nj" | cut -c1-1500 | head -30 || true + + - name: Run directly (raw exit status) + shell: pwsh + env: + GRPC_VERBOSITY: DEBUG + GRPC_TRACE: api + run: | + foreach ($name in 'startup', 'module') { + $exe = (Get-Item "env:$name").Value + Write-Host "== $name : $exe" + & $exe 2>&1 | Out-Host + "{0}: exit 0x{1:X8} ({1})" -f $name, $LASTEXITCODE | Out-Host + } + exit 0 + + - name: Under cdb + shell: pwsh + run: | + $cdb = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe" + if (-not (Test-Path $cdb)) { Write-Host "no cdb"; exit 0 } + foreach ($name in 'startup', 'module') { + $exe = (Get-Item "env:$name").Value + $dir = Split-Path $exe + Write-Host "== $name under cdb" + & $cdb -lines -G -y "$dir" -c ".symopt+0x40; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; q" $exe 2>&1 | Out-Host + } + exit 0 + + - name: Debug directory of the program + if: always() + shell: bash + run: | + ro=$(find "$MCPP_ROOT" -iname 'llvm-readobj.exe' | head -1) + [ -n "$ro" ] && "$ro" --coff-debug-directory "$module" | head -30 || true + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: windows-test-programs + path: | + target/**/startup.exe + target/**/module.exe + target/**/*.pdb + if-no-files-found: warn + retention-days: 5 diff --git a/mcpp.toml b/mcpp.toml index a9a4d47..869e422 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -19,7 +19,7 @@ repo = "https://github.com/mcpplibs/grpc-m" # 1.83.0.1 (wrapper revision): compat.openssl 3.5.9 (3.5 LTS) instead of 3.5.1, # the same OpenSSL as mcpplibs.mwrap.openssl 3.5.9, so a program that uses # both links one OpenSSL. The gRPC source, modules and API are unchanged. -platforms = ["linux", "macos"] +platforms = ["linux", "macos", "windows"] # ───────────────────────────────────────────────────────────────────────────── # Single-repo build, the shape opencv-m established. diff --git a/tests/module.cpp b/tests/module.cpp index 7398430..10b0f75 100644 --- a/tests/module.cpp +++ b/tests/module.cpp @@ -22,6 +22,8 @@ import mcpplibs.mwrap.grpc; int main() { + std::setvbuf(stdout, nullptr, _IONBF, 0); + std::fputs("diag: main entered\n", stderr); // 1. A version string read from the library, not a header constant. const std::string version = grpc::Version(); std::printf("grpc::Version() = %s\n", version.c_str()); @@ -30,6 +32,7 @@ int main() { return 1; } + std::fputs("diag: step 2\n", stderr); // 2. grpc::Status, including the error path — an all-OK stub cannot pass. const grpc::Status bad(grpc::StatusCode::INVALID_ARGUMENT, "nope"); if (bad.ok() || bad.error_code() != grpc::StatusCode::INVALID_ARGUMENT || @@ -42,6 +45,7 @@ int main() { return 1; } + std::fputs("diag: step 3\n", stderr); // 3. A real channel object over a real (unconnected) target. Channels // connect lazily, so no server is needed; IDLE is the correct state // before the first RPC, and getting it means the channel is a live @@ -57,6 +61,7 @@ int main() { return 1; } + std::fputs("diag: step 4\n", stderr); // 4. Channel arguments and a resource quota — plain library objects, but // they prove those symbols link too. grpc::ChannelArguments args; @@ -66,6 +71,7 @@ int main() { grpc::ResourceQuota quota("grpc-m-test"); quota.Resize(1024 * 1024); + std::fputs("diag: step 5\n", stderr); // 5. Credentials factories, both sides. if (!grpc::InsecureChannelCredentials() || !grpc::InsecureServerCredentials()) { std::puts("FAIL: credentials factory returned null"); diff --git a/tests/startup.cpp b/tests/startup.cpp new file mode 100644 index 0000000..ef1ba18 --- /dev/null +++ b/tests/startup.cpp @@ -0,0 +1,10 @@ +// DIAGNOSTIC (temporary branch): the module imported, nothing called. +// If this one also dies, the failure is in static initialisation of what links. +#include + +import mcpplibs.mwrap.grpc; + +int main() { + std::fputs("startup: main entered\n", stderr); + return 0; +} From ecfe9b5231f9b81c6e00e3403f50acbadf98dd2e Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 13:56:29 +0900 Subject: [PATCH 2/8] DIAG: cache always, PDB, finer markers --- .github/workflows/windows-diag.yml | 17 ++++++++++++++++- mcpp.toml | 2 +- tests/module.cpp | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index 41a4c95..9be0398 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 + - uses: actions/cache/restore@v4 with: path: | mcpp-2026.11.18.1-windows-x86_64 @@ -51,10 +51,23 @@ jobs: run: | "$MCPP" --version "$MCPP" test + env: + GRPC_VERBOSITY: DEBUG + GRPC_TRACE: api + + - uses: actions/cache/save@v4 + if: always() + with: + path: | + mcpp-2026.11.18.1-windows-x86_64 + target + key: win-diag-${{ github.run_id }}-${{ github.run_attempt }} - name: Locate the test programs and tools + if: always() shell: bash run: | + set +e find target -iname '*.exe' -path '*test*' -printf '%s %p\n' 2>/dev/null | sort -k2 | tail -40 || true find target -iname '*.pdb' -printf '%s %p\n' | tail -20 || true find "$MCPP_ROOT" -iname 'lldb.exe' -o -iname 'llvm-readobj.exe' -o -iname 'llvm-symbolizer.exe' | head @@ -71,6 +84,7 @@ jobs: [ -n "$nj" ] && grep -n -E '^ *(cxxflags|ldflags|command|link_flags) *=' "$nj" | cut -c1-1500 | head -30 || true - name: Run directly (raw exit status) + if: always() shell: pwsh env: GRPC_VERBOSITY: DEBUG @@ -85,6 +99,7 @@ jobs: exit 0 - name: Under cdb + if: always() shell: pwsh run: | $cdb = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe" diff --git a/mcpp.toml b/mcpp.toml index 869e422..19f9899 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1191,7 +1191,7 @@ cxxflags = [ "-DNOMINMAX", ] cflags = ["-D_WIN32_WINNT=0x600", "-DNOMINMAX"] -ldflags = ["-lws2_32", "-lcrypt32", "-liphlpapi"] +ldflags = ["-lws2_32", "-lcrypt32", "-liphlpapi", "-g"] # DIAG: a PDB for cdb [target.'cfg(linux)'.build] ldflags = ["-lpthread", "-ldl", "-lm"] diff --git a/tests/module.cpp b/tests/module.cpp index 10b0f75..887dd49 100644 --- a/tests/module.cpp +++ b/tests/module.cpp @@ -50,7 +50,10 @@ int main() { // connect lazily, so no server is needed; IDLE is the correct state // before the first RPC, and getting it means the channel is a live // object from the library rather than a null placeholder. - auto channel = grpc::CreateChannel("127.0.0.1:1", grpc::InsecureChannelCredentials()); + auto insecure = grpc::InsecureChannelCredentials(); + std::fputs("diag: step 3b (credentials made)\n", stderr); + auto channel = grpc::CreateChannel("127.0.0.1:1", insecure); + std::fputs("diag: step 3c (channel made)\n", stderr); if (!channel) { std::puts("FAIL: CreateChannel() returned null"); return 1; From f3b6a161d816e41aba986879fce5ef42803b4161 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 14:18:01 +0900 Subject: [PATCH 3/8] DIAG: link-flag variants A (none), B (/opt:noicf), C (-g + /opt:icf) --- .github/workflows/windows-diag.yml | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index 9be0398..09622db 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -44,16 +44,32 @@ jobs: echo "MCPP_ROOT=$(cygpath -m "$root")" >> "$GITHUB_ENV" "$root/bin/mcpp.exe" index update - - name: mcpp test - id: test - continue-on-error: true + - name: Link-flag variants (relink only) shell: bash run: | + set +e "$MCPP" --version - "$MCPP" test - env: - GRPC_VERBOSITY: DEBUG - GRPC_TRACE: api + variant() { + python3 - "$1" <<'PY' + import pathlib, re, sys + p = pathlib.Path("mcpp.toml"); s = p.read_text() + s = re.sub(r'ldflags = \["-lws2_32", "-lcrypt32", "-liphlpapi"[^\]]*\].*', + 'ldflags = ["-lws2_32", "-lcrypt32", "-liphlpapi"' + sys.argv[1] + ']', s, count=1) + p.write_text(s) + PY + grep -n 'ldflags = \["-lws2_32' mcpp.toml + "$MCPP" test > "variant-$2.log" 2>&1 + echo "VARIANT $2 ($1): mcpp test rc=$?" + grep -E '^(module|startup|macros) \.\.\.|test result' "variant-$2.log" + cp target/x86_64-windows-msvc/*/bin/module.exe "module-$2.exe" 2>/dev/null + cp target/x86_64-windows-msvc/*/bin/module.pdb "module-$2.pdb" 2>/dev/null + true + } + variant '' A + variant ', "-Wl,/opt:noicf"' B + variant ', "-g", "-Wl,/opt:icf"' C + echo "module=$(cygpath -w "$PWD/module-C.exe")" >> "$GITHUB_ENV" + echo "startup=$(cygpath -w "$PWD/module-A.exe")" >> "$GITHUB_ENV" - uses: actions/cache/save@v4 if: always() @@ -107,6 +123,7 @@ jobs: foreach ($name in 'startup', 'module') { $exe = (Get-Item "env:$name").Value $dir = Split-Path $exe + if (Test-Path "$dir\module-C.pdb") { Copy-Item "$dir\module-C.pdb" "$dir\module.pdb" -Force } Write-Host "== $name under cdb" & $cdb -lines -G -y "$dir" -c ".symopt+0x40; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; q" $exe 2>&1 | Out-Host } @@ -124,8 +141,7 @@ jobs: with: name: windows-test-programs path: | - target/**/startup.exe - target/**/module.exe - target/**/*.pdb + module-*.exe + variant-*.log if-no-files-found: warn retention-days: 5 From b232996c9629ad13490ca8ebc04c215fe6116f40 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 14:50:22 +0900 Subject: [PATCH 4/8] DIAG: variants A, D (/opt:noref), E (-g + /opt:ref); cdb on A and E --- .github/workflows/windows-diag.yml | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index 09622db..b2414b2 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -66,10 +66,10 @@ jobs: true } variant '' A - variant ', "-Wl,/opt:noicf"' B - variant ', "-g", "-Wl,/opt:icf"' C - echo "module=$(cygpath -w "$PWD/module-C.exe")" >> "$GITHUB_ENV" + variant ', "-Wl,/opt:noref"' D + variant ', "-g", "-Wl,/opt:ref"' E echo "startup=$(cygpath -w "$PWD/module-A.exe")" >> "$GITHUB_ENV" + echo "module=$(cygpath -w "$PWD/module-E.exe")" >> "$GITHUB_ENV" - uses: actions/cache/save@v4 if: always() @@ -79,26 +79,6 @@ jobs: target key: win-diag-${{ github.run_id }}-${{ github.run_attempt }} - - name: Locate the test programs and tools - if: always() - shell: bash - run: | - set +e - find target -iname '*.exe' -path '*test*' -printf '%s %p\n' 2>/dev/null | sort -k2 | tail -40 || true - find target -iname '*.pdb' -printf '%s %p\n' | tail -20 || true - find "$MCPP_ROOT" -iname 'lldb.exe' -o -iname 'llvm-readobj.exe' -o -iname 'llvm-symbolizer.exe' | head - ls "/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/cdb.exe" || echo "no cdb" - for t in startup module; do - exe=$(find target -iname "$t.exe" | head -1) - echo "$t=$(cygpath -w "$exe")" >> "$GITHUB_ENV" - done - # How the test programs were compiled and linked. - for nj in $(find target -name build.ninja); do - grep -n -E 'module\.exe|startup\.exe' "$nj" | head -5 && echo "^^ $nj" - done - nj=$(grep -l 'module\.exe' $(find target -name build.ninja) | head -1) - [ -n "$nj" ] && grep -n -E '^ *(cxxflags|ldflags|command|link_flags) *=' "$nj" | cut -c1-1500 | head -30 || true - - name: Run directly (raw exit status) if: always() shell: pwsh @@ -123,9 +103,8 @@ jobs: foreach ($name in 'startup', 'module') { $exe = (Get-Item "env:$name").Value $dir = Split-Path $exe - if (Test-Path "$dir\module-C.pdb") { Copy-Item "$dir\module-C.pdb" "$dir\module.pdb" -Force } Write-Host "== $name under cdb" - & $cdb -lines -G -y "$dir" -c ".symopt+0x40; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; q" $exe 2>&1 | Out-Host + & $cdb -lines -G -y "$dir" -c ".symopt+0x40; .sympath+ D:\a\grpc-m\grpc-m; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; q" $exe 2>&1 | Out-Host } exit 0 From f8c6bcdeb7321738e9668b2c5c24f02bccbf92b1 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 15:16:44 +0900 Subject: [PATCH 5/8] DIAG: E with symbols under cdb; F (-g /opt:noref) control; absl weak publics --- .github/workflows/windows-diag.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index b2414b2..bdc9dd2 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -65,9 +65,14 @@ jobs: cp target/x86_64-windows-msvc/*/bin/module.pdb "module-$2.pdb" 2>/dev/null true } - variant '' A - variant ', "-Wl,/opt:noref"' D variant ', "-g", "-Wl,/opt:ref"' E + variant ', "-g", "-Wl,/opt:noref"' F + # E linked last-but-one; relink it so its PDB is the one beside the target exe. + variant ', "-g", "-Wl,/opt:ref"' E + # The symbols of the absl weak functions as linked, and their callers' targets. + ro=$(find "$MCPP_ROOT" -iname 'llvm-pdbutil.exe' | head -1); echo "pdbutil: $ro" + pdb=$(ls target/x86_64-windows-msvc/*/bin/module.pdb | head -1) + [ -n "$ro" ] && "$ro" dump -publics "$pdb" | grep -i -E -B1 -A3 'AbslInternal' | head -120 echo "startup=$(cygpath -w "$PWD/module-A.exe")" >> "$GITHUB_ENV" echo "module=$(cygpath -w "$PWD/module-E.exe")" >> "$GITHUB_ENV" @@ -103,8 +108,11 @@ jobs: foreach ($name in 'startup', 'module') { $exe = (Get-Item "env:$name").Value $dir = Split-Path $exe + if ($name -eq 'startup') { continue } + $exe = (Resolve-Path "target\x86_64-windows-msvc\*\bin\module.exe").Path + $dir = Split-Path $exe Write-Host "== $name under cdb" - & $cdb -lines -G -y "$dir" -c ".symopt+0x40; .sympath+ D:\a\grpc-m\grpc-m; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; q" $exe 2>&1 | Out-Host + & $cdb -lines -G -y "$dir" -c ".symopt+0x40; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; .echo ===FRAMES===; .frame /c 0; .frame /c 1; .frame /c 2; .frame /c 3; q" $exe 2>&1 | Out-Host } exit 0 From 31ed3f396cb95fb8269d4f15bc84517f73b7ca66 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 15:41:02 +0900 Subject: [PATCH 6/8] DIAG: verify compat.c-ares CARES_STATICLIB fix with default link flags; examples --- .github/workflows/windows-diag.yml | 92 ++++++++++-------------------- mcpp.toml | 2 +- tests/module.cpp | 11 +--- tests/startup.cpp | 10 ---- 4 files changed, 32 insertions(+), 83 deletions(-) delete mode 100644 tests/startup.cpp diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index bdc9dd2..e56cb18 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -44,37 +44,23 @@ jobs: echo "MCPP_ROOT=$(cygpath -m "$root")" >> "$GITHUB_ENV" "$root/bin/mcpp.exe" index update - - name: Link-flag variants (relink only) + - name: Candidate index (compat.c-ares exports CARES_STATICLIB) + shell: bash + run: | + home=$("$MCPP" self env | awk -F'= *' '/^MCPP_HOME/ && !h {h = $2} END {print h}') + test -n "$home" + git init -q "$RUNNER_TEMP/index" + git -C "$RUNNER_TEMP/index" fetch -q --depth 1 https://github.com/mcpplibs/mcpp-index d8bd66298c41b1466f96cb6954fac227556b1045 + git -C "$RUNNER_TEMP/index" checkout -q FETCH_HEAD + python3 "$RUNNER_TEMP/index/tests/prepare_builtin_index.py" --home "$home" + + - name: Build the library and run the module test (default link flags) + id: test + continue-on-error: true shell: bash run: | - set +e "$MCPP" --version - variant() { - python3 - "$1" <<'PY' - import pathlib, re, sys - p = pathlib.Path("mcpp.toml"); s = p.read_text() - s = re.sub(r'ldflags = \["-lws2_32", "-lcrypt32", "-liphlpapi"[^\]]*\].*', - 'ldflags = ["-lws2_32", "-lcrypt32", "-liphlpapi"' + sys.argv[1] + ']', s, count=1) - p.write_text(s) - PY - grep -n 'ldflags = \["-lws2_32' mcpp.toml - "$MCPP" test > "variant-$2.log" 2>&1 - echo "VARIANT $2 ($1): mcpp test rc=$?" - grep -E '^(module|startup|macros) \.\.\.|test result' "variant-$2.log" - cp target/x86_64-windows-msvc/*/bin/module.exe "module-$2.exe" 2>/dev/null - cp target/x86_64-windows-msvc/*/bin/module.pdb "module-$2.pdb" 2>/dev/null - true - } - variant ', "-g", "-Wl,/opt:ref"' E - variant ', "-g", "-Wl,/opt:noref"' F - # E linked last-but-one; relink it so its PDB is the one beside the target exe. - variant ', "-g", "-Wl,/opt:ref"' E - # The symbols of the absl weak functions as linked, and their callers' targets. - ro=$(find "$MCPP_ROOT" -iname 'llvm-pdbutil.exe' | head -1); echo "pdbutil: $ro" - pdb=$(ls target/x86_64-windows-msvc/*/bin/module.pdb | head -1) - [ -n "$ro" ] && "$ro" dump -publics "$pdb" | grep -i -E -B1 -A3 'AbslInternal' | head -120 - echo "startup=$(cygpath -w "$PWD/module-A.exe")" >> "$GITHUB_ENV" - echo "module=$(cygpath -w "$PWD/module-E.exe")" >> "$GITHUB_ENV" + "$MCPP" test - uses: actions/cache/save@v4 if: always() @@ -84,51 +70,33 @@ jobs: target key: win-diag-${{ github.run_id }}-${{ github.run_attempt }} - - name: Run directly (raw exit status) + - name: helloworld example — a real RPC over loopback if: always() - shell: pwsh - env: - GRPC_VERBOSITY: DEBUG - GRPC_TRACE: api - run: | - foreach ($name in 'startup', 'module') { - $exe = (Get-Item "env:$name").Value - Write-Host "== $name : $exe" - & $exe 2>&1 | Out-Host - "{0}: exit 0x{1:X8} ({1})" -f $name, $LASTEXITCODE | Out-Host - } - exit 0 + shell: bash + working-directory: examples/helloworld + run: '"$MCPP" run' - - name: Under cdb + - name: greeter example — the template, via the rule package if: always() - shell: pwsh - run: | - $cdb = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe" - if (-not (Test-Path $cdb)) { Write-Host "no cdb"; exit 0 } - foreach ($name in 'startup', 'module') { - $exe = (Get-Item "env:$name").Value - $dir = Split-Path $exe - if ($name -eq 'startup') { continue } - $exe = (Resolve-Path "target\x86_64-windows-msvc\*\bin\module.exe").Path - $dir = Split-Path $exe - Write-Host "== $name under cdb" - & $cdb -lines -G -y "$dir" -c ".symopt+0x40; g; .echo ===EXR===; .exr -1; .echo ===STACK===; kn 100; .echo ===REGS===; r; .echo ===CODE===; ub @rip L12; u @rip L4; .echo ===FRAMES===; .frame /c 0; .frame /c 1; .frame /c 2; .frame /c 3; q" $exe 2>&1 | Out-Host - } - exit 0 + shell: bash + working-directory: examples/greeter + run: '"$MCPP" run' - - name: Debug directory of the program + - name: advanced example — extra_dirs + mock + plan/submit if: always() shell: bash - run: | - ro=$(find "$MCPP_ROOT" -iname 'llvm-readobj.exe' | head -1) - [ -n "$ro" ] && "$ro" --coff-debug-directory "$module" | head -30 || true + working-directory: examples/advanced + run: '"$MCPP" run' + + - name: The module test passed + shell: bash + run: test "${{ steps.test.outcome }}" = success - uses: actions/upload-artifact@v4 if: always() with: name: windows-test-programs path: | - module-*.exe - variant-*.log + target/**/bin/module.exe if-no-files-found: warn retention-days: 5 diff --git a/mcpp.toml b/mcpp.toml index 19f9899..869e422 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1191,7 +1191,7 @@ cxxflags = [ "-DNOMINMAX", ] cflags = ["-D_WIN32_WINNT=0x600", "-DNOMINMAX"] -ldflags = ["-lws2_32", "-lcrypt32", "-liphlpapi", "-g"] # DIAG: a PDB for cdb +ldflags = ["-lws2_32", "-lcrypt32", "-liphlpapi"] [target.'cfg(linux)'.build] ldflags = ["-lpthread", "-ldl", "-lm"] diff --git a/tests/module.cpp b/tests/module.cpp index 887dd49..7398430 100644 --- a/tests/module.cpp +++ b/tests/module.cpp @@ -22,8 +22,6 @@ import mcpplibs.mwrap.grpc; int main() { - std::setvbuf(stdout, nullptr, _IONBF, 0); - std::fputs("diag: main entered\n", stderr); // 1. A version string read from the library, not a header constant. const std::string version = grpc::Version(); std::printf("grpc::Version() = %s\n", version.c_str()); @@ -32,7 +30,6 @@ int main() { return 1; } - std::fputs("diag: step 2\n", stderr); // 2. grpc::Status, including the error path — an all-OK stub cannot pass. const grpc::Status bad(grpc::StatusCode::INVALID_ARGUMENT, "nope"); if (bad.ok() || bad.error_code() != grpc::StatusCode::INVALID_ARGUMENT || @@ -45,15 +42,11 @@ int main() { return 1; } - std::fputs("diag: step 3\n", stderr); // 3. A real channel object over a real (unconnected) target. Channels // connect lazily, so no server is needed; IDLE is the correct state // before the first RPC, and getting it means the channel is a live // object from the library rather than a null placeholder. - auto insecure = grpc::InsecureChannelCredentials(); - std::fputs("diag: step 3b (credentials made)\n", stderr); - auto channel = grpc::CreateChannel("127.0.0.1:1", insecure); - std::fputs("diag: step 3c (channel made)\n", stderr); + auto channel = grpc::CreateChannel("127.0.0.1:1", grpc::InsecureChannelCredentials()); if (!channel) { std::puts("FAIL: CreateChannel() returned null"); return 1; @@ -64,7 +57,6 @@ int main() { return 1; } - std::fputs("diag: step 4\n", stderr); // 4. Channel arguments and a resource quota — plain library objects, but // they prove those symbols link too. grpc::ChannelArguments args; @@ -74,7 +66,6 @@ int main() { grpc::ResourceQuota quota("grpc-m-test"); quota.Resize(1024 * 1024); - std::fputs("diag: step 5\n", stderr); // 5. Credentials factories, both sides. if (!grpc::InsecureChannelCredentials() || !grpc::InsecureServerCredentials()) { std::puts("FAIL: credentials factory returned null"); diff --git a/tests/startup.cpp b/tests/startup.cpp deleted file mode 100644 index ef1ba18..0000000 --- a/tests/startup.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// DIAGNOSTIC (temporary branch): the module imported, nothing called. -// If this one also dies, the failure is in static initialisation of what links. -#include - -import mcpplibs.mwrap.grpc; - -int main() { - std::fputs("startup: main entered\n", stderr); - return 0; -} From 3eb2f4ad72a4aef802abf9b8b2e5f6b1518a82c1 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 16:08:06 +0900 Subject: [PATCH 7/8] DIAG: protoc on Windows from the candidate index; verbose tool sub-build --- .github/workflows/windows-diag.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index e56cb18..794e53b 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -14,6 +14,7 @@ concurrency: env: MCPP_VERSION: "2026.11.18.1" MCPP_INDEX_MIRROR: GLOBAL + MCPP_TOOL_BUILD_VERBOSE: "1" jobs: diag: @@ -44,13 +45,13 @@ jobs: echo "MCPP_ROOT=$(cygpath -m "$root")" >> "$GITHUB_ENV" "$root/bin/mcpp.exe" index update - - name: Candidate index (compat.c-ares exports CARES_STATICLIB) + - name: Candidate index (c-ares CARES_STATICLIB; protobuf keeps protoc on Windows) shell: bash run: | home=$("$MCPP" self env | awk -F'= *' '/^MCPP_HOME/ && !h {h = $2} END {print h}') test -n "$home" git init -q "$RUNNER_TEMP/index" - git -C "$RUNNER_TEMP/index" fetch -q --depth 1 https://github.com/mcpplibs/mcpp-index d8bd66298c41b1466f96cb6954fac227556b1045 + git -C "$RUNNER_TEMP/index" fetch -q --depth 1 https://github.com/mcpplibs/mcpp-index 68b50f09e46bb1cfd0a58ee19fbe2d4f49072d65 git -C "$RUNNER_TEMP/index" checkout -q FETCH_HEAD python3 "$RUNNER_TEMP/index/tests/prepare_builtin_index.py" --home "$home" From a1fea9aa7986aed1404c169aecfcc8af349a5bda Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Fri, 20 Nov 2026 17:26:48 +0900 Subject: [PATCH 8/8] DIAG: protoc host tool on Windows, the inner build's full output as an artifact --- .github/workflows/windows-diag.yml | 50 ++++++++---------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/.github/workflows/windows-diag.yml b/.github/workflows/windows-diag.yml index 794e53b..9e72c05 100644 --- a/.github/workflows/windows-diag.yml +++ b/.github/workflows/windows-diag.yml @@ -55,49 +55,25 @@ jobs: git -C "$RUNNER_TEMP/index" checkout -q FETCH_HEAD python3 "$RUNNER_TEMP/index/tests/prepare_builtin_index.py" --home "$home" - - name: Build the library and run the module test (default link flags) - id: test + - name: protoc host tool on Windows (helloworld), full inner output to a file + id: protoc continue-on-error: true shell: bash - run: | - "$MCPP" --version - "$MCPP" test - - - uses: actions/cache/save@v4 - if: always() - with: - path: | - mcpp-2026.11.18.1-windows-x86_64 - target - key: win-diag-${{ github.run_id }}-${{ github.run_attempt }} - - - name: helloworld example — a real RPC over loopback - if: always() - shell: bash working-directory: examples/helloworld - run: '"$MCPP" run' - - - name: greeter example — the template, via the rule package - if: always() - shell: bash - working-directory: examples/greeter - run: '"$MCPP" run' - - - name: advanced example — extra_dirs + mock + plan/submit - if: always() - shell: bash - working-directory: examples/advanced - run: '"$MCPP" run' - - - name: The module test passed - shell: bash - run: test "${{ steps.test.outcome }}" = success + run: | + set +e + "$MCPP" run > "$RUNNER_TEMP/helloworld.log" 2>&1 + rc=$? + echo "mcpp run exit $rc; $(wc -l < "$RUNNER_TEMP/helloworld.log") lines" + grep -n -E "FAILED|ninja: build stopped|: error|error:|lld-link|undefined symbol|fatal|cannot " "$RUNNER_TEMP/helloworld.log" | grep -v -i "warning" | head -80 + echo "---- last 60 lines" + tail -60 "$RUNNER_TEMP/helloworld.log" | cut -c1-400 + exit $rc - uses: actions/upload-artifact@v4 if: always() with: - name: windows-test-programs - path: | - target/**/bin/module.exe + name: protoc-windows-log + path: ${{ runner.temp }}/helloworld.log if-no-files-found: warn retention-days: 5