You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ji...@apache.org on 2026/08/11 17:20:12 UTC

(openoffice) branch msys2-dev-prototype created (now c193fac602)

This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a change to branch msys2-dev-prototype
in repository https://gitbox.apache.org/repos/asf/openoffice.git


      at c193fac602 Add an MSYS2 environment probe for the alternative Windows build

This branch includes the following new commits:

     new 701dec8746 Add feasibility assessment for an MSYS2/clang Windows build
     new fec32e0c27 Baseline the MSYS2 build at x86_64 and note the CCNUMVER gate hazard
     new fefcf25cec Record the --with-system-* audit and correct where ATL comes from
     new c193fac602 Add an MSYS2 environment probe for the alternative Windows build

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(openoffice) 04/04: Add an MSYS2 environment probe for the alternative Windows build

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch msys2-dev-prototype
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit c193fac6023d516a8163f71c7486482d6c01f60e
Author: Jim Jagielski <ji...@gmail.com>
AuthorDate: Tue Aug 11 13:19:56 2026 -0400

    Add an MSYS2 environment probe for the alternative Windows build
    
    Settles on a real machine what the feasibility document can only assert:
    whether clang accepts the tree's MSVC extensions, where ATL lives, and which
    system libraries MSYS2 can supply. Exits non-zero only on findings that
    invalidate the approach rather than merely resize a phase.
---
 msys2-probe.sh | 522 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 522 insertions(+)

diff --git a/msys2-probe.sh b/msys2-probe.sh
new file mode 100755
index 0000000000..405b321776
--- /dev/null
+++ b/msys2-probe.sh
@@ -0,0 +1,522 @@
+#!/usr/bin/env bash
+#**************************************************************
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+#**************************************************************
+#
+# Environment probe for the proposed MSYS2/clang Windows build of Apache
+# OpenOffice.  See MSYS2-WINDOWS-BUILD-FEASIBILITY.md.
+#
+# This script does not build anything.  It answers the questions that
+# feasibility document lists as asserted-but-unverified, so that the plan's
+# effort estimates rest on measurements rather than on assumptions.
+#
+# Run it from an MSYS2 **CLANG64** shell on a Windows 10+ x86_64 machine:
+#
+#     ./msys2-probe.sh                 # probe only
+#     ./msys2-probe.sh --install       # pacman -S the toolchain first, then probe
+#     ./msys2-probe.sh --atl-include=/c/path/to/atlmfc/include
+#
+# Exit status: 0 if no CRITICAL probe failed, 1 otherwise.
+
+set -uo pipefail
+
+DO_INSTALL=0
+ATL_INCLUDE_OVERRIDE=""
+KEEP_TMP=0
+
+for arg in "$@"; do
+    case "$arg" in
+        --install)            DO_INSTALL=1 ;;
+        --atl-include=*)      ATL_INCLUDE_OVERRIDE="${arg#*=}" ;;
+        --keep-tmp)           KEEP_TMP=1 ;;
+        -h|--help)
+            sed -n '23,37p' "$0" | sed 's/^# \{0,1\}//'
+            exit 0 ;;
+        *)
+            echo "unknown option: $arg (try --help)" >&2
+            exit 2 ;;
+    esac
+done
+
+# ---------------------------------------------------------------- reporting --
+
+PASS_N=0; FAIL_N=0; WARN_N=0; INFO_N=0
+CRITICAL_FAILED=0
+declare -a SUMMARY
+
+_record() {  # _record <status> <severity> <label> <detail>
+    local status="$1" sev="$2" label="$3" detail="$4"
+    SUMMARY+=("$status|$sev|$label|$detail")
+    case "$status" in
+        PASS) PASS_N=$((PASS_N+1)) ;;
+        FAIL) FAIL_N=$((FAIL_N+1))
+              [ "$sev" = "CRITICAL" ] && CRITICAL_FAILED=1 ;;
+        WARN) WARN_N=$((WARN_N+1)) ;;
+        INFO) INFO_N=$((INFO_N+1)) ;;
+    esac
+}
+
+pass() { echo "  [ PASS ] $1${2:+  -- $2}"; _record PASS "${3:-}" "$1" "${2:-}"; }
+fail() { echo "  [ FAIL ] $1${2:+  -- $2}"; _record FAIL "${3:-HIGH}" "$1" "${2:-}"; }
+warn() { echo "  [ WARN ] $1${2:+  -- $2}"; _record WARN "${3:-}" "$1" "${2:-}"; }
+info() { echo "  [ info ] $1${2:+  -- $2}"; _record INFO "${3:-}" "$1" "${2:-}"; }
+head1() { echo; echo "=============================================================="; echo "$1"; echo "=============================================================="; }
+head2() { echo; echo "-- $1"; }
+
+TMP="$(mktemp -d 2>/dev/null || echo "./msys2-probe-tmp.$$")"
+mkdir -p "$TMP"
+cleanup() { [ "$KEEP_TMP" -eq 1 ] && echo "temp kept at $TMP" || rm -rf "$TMP"; }
+trap cleanup EXIT
+
+# Compile (and optionally run) a snippet.  Echoes compiler output on failure.
+#   try_compile <name> <ext> <extra-flags> <source...>   (source on stdin)
+try_compile() {
+    local name="$1" ext="$2" flags="$3" mode="${4:-compile}"
+    local src="$TMP/$name.$ext" exe="$TMP/$name.exe" log="$TMP/$name.log"
+    cat > "$src"
+    local cc; [ "$ext" = "c" ] && cc="${CC:-clang}" || cc="${CXX:-clang++}"
+    if [ "$mode" = "run" ]; then
+        # shellcheck disable=SC2086
+        if ! $cc $flags "$src" -o "$exe" > "$log" 2>&1; then return 1; fi
+        "$exe" >> "$log" 2>&1 || return 2
+    else
+        # shellcheck disable=SC2086
+        if ! $cc $flags -c "$src" -o "$TMP/$name.o" > "$log" 2>&1; then return 1; fi
+    fi
+    return 0
+}
+
+show_log() { [ -s "$TMP/$1.log" ] && sed -n '1,6p' "$TMP/$1.log" | sed 's/^/           | /'; }
+
+# ---------------------------------------------------------------- preflight --
+
+head1 "0. Preflight"
+
+UNAME_S="$(uname -s 2>/dev/null || echo unknown)"
+case "$UNAME_S" in
+    *NT*|MSYS*|MINGW*|CLANG*) : ;;
+    *) echo "This script must run inside MSYS2 on Windows (uname -s = $UNAME_S)." >&2
+       exit 2 ;;
+esac
+
+MSYSTEM_VAL="${MSYSTEM:-<unset>}"
+if [ "$MSYSTEM_VAL" = "CLANG64" ]; then
+    pass "MSYSTEM=CLANG64"
+else
+    fail "MSYSTEM is $MSYSTEM_VAL, expected CLANG64" \
+         "start the 'MSYS2 CLANG64' shell, not MINGW64/UCRT64/MSYS" CRITICAL
+    echo
+    echo "  Why CLANG64 specifically: the tree needs __try/__except, __uuidof and"
+    echo "  __declspec(uuid), none of which GCC-mingw implements.  MINGW64 and"
+    echo "  UCRT64 are GCC.  See the 'UCRT vs MSVCRT' section of the plan."
+fi
+
+ARCH="$(uname -m 2>/dev/null || echo unknown)"
+if [ "$ARCH" = "x86_64" ]; then
+    pass "architecture x86_64"
+else
+    fail "architecture is $ARCH, expected x86_64" \
+         "this build mode is x86_64-only; arm64 Windows is deferred" CRITICAL
+fi
+
+WINVER="$(cmd.exe /c ver 2>/dev/null | tr -d '\r' | grep -o '[0-9][0-9.]*' | head -1)"
+info "Windows version" "${WINVER:-unknown}"
+
+# ----------------------------------------------------------------- packages --
+
+# Base MSYS2 tools (MSYS namespace) needed to run configure/dmake/build.pl.
+MSYS_PKGS=(
+    perl make autoconf automake-wrapper libtool patch diffutils findutils
+    gawk sed grep tar unzip zip dos2unix bison flex gperf git pkgconf
+)
+# CLANG64 toolchain and libraries.  Package existence is verified below rather
+# than assumed -- some of these may not exist under the clang64 prefix.
+CLANG_PKGS=(
+    mingw-w64-clang-x86_64-toolchain
+    mingw-w64-clang-x86_64-cmake
+    mingw-w64-clang-x86_64-pkgconf
+)
+# Candidate system libraries, matching AOO's --with-system-* options.
+SYSLIB_PKGS=(
+    boost curl expat icu libxml2 libxslt nss openssl zlib libjpeg-turbo
+    hunspell graphite2 redland python mdds cairo poppler libtiff
+    nspr sqlite3 lcms2 harfbuzz freetype fontconfig
+)
+
+head1 "1. MSYS2 packages"
+
+if ! command -v pacman >/dev/null 2>&1; then
+    fail "pacman not found" "not a working MSYS2 installation" CRITICAL
+else
+    if [ "$DO_INSTALL" -eq 1 ]; then
+        head2 "installing base MSYS2 tools"
+        pacman -S --needed --noconfirm "${MSYS_PKGS[@]}" || \
+            warn "some base packages failed to install"
+        head2 "installing CLANG64 toolchain"
+        pacman -S --needed --noconfirm "${CLANG_PKGS[@]}" || \
+            warn "some toolchain packages failed to install"
+    else
+        info "run with --install to install packages" "probing current state only"
+    fi
+
+    head2 "base tools present?"
+    for t in perl make autoconf libtool patch gawk sed zip unzip bison flex gperf pkgconf git; do
+        if command -v "$t" >/dev/null 2>&1; then
+            pass "$t" "$(command -v "$t")"
+        else
+            fail "$t missing" "pacman -S $t" MEDIUM
+        fi
+    done
+
+    head2 "toolchain present?"
+    for t in clang clang++ lld llvm-ar llvm-strip windres widl; do
+        if command -v "$t" >/dev/null 2>&1; then
+            pass "$t" "$(command -v "$t")"
+        else
+            case "$t" in
+                clang|clang++) sev=CRITICAL ;;
+                *)             sev=MEDIUM ;;
+            esac
+            fail "$t missing" "pacman -S mingw-w64-clang-x86_64-toolchain" "$sev"
+        fi
+    done
+fi
+
+# ---------------------------------------------------------------- toolchain --
+
+head1 "2. Toolchain facts"
+
+if command -v clang >/dev/null 2>&1; then
+    CLANG_VER="$(clang --version 2>/dev/null | head -1)"
+    info "clang version" "$CLANG_VER"
+
+    TRIPLE="$(clang -dumpmachine 2>/dev/null)"
+    case "$TRIPLE" in
+        x86_64-w64-windows-gnu|x86_64-w64-mingw32)
+            pass "target triple $TRIPLE" "GNU/Itanium C++ ABI as the plan assumes" ;;
+        *msvc*)
+            fail "target triple $TRIPLE" \
+                 "this is the MSVC ABI (clang-cl); the plan targets the GNU ABI" CRITICAL ;;
+        *)
+            fail "unexpected target triple: ${TRIPLE:-<none>}" "" CRITICAL ;;
+    esac
+
+    # -dumpversion under COM=GCC: see section B5a of the plan.
+    DUMPVER="$(clang -dumpversion 2>/dev/null)"
+    info "clang -dumpversion" "${DUMPVER:-<none>} -- configure.ac:2301 reads this as a GCC version when COM=GCC (plan B5a)"
+
+    head2 "C++ standard library"
+    if try_compile stdlib cxx "" compile <<'EOF'
+#include <version>
+#if defined(_LIBCPP_VERSION)
+#  error MARKER_LIBCPP
+#elif defined(__GLIBCXX__)
+#  error MARKER_LIBSTDCXX
+#else
+#  error MARKER_UNKNOWN
+#endif
+EOF
+    then :; fi
+    if grep -q MARKER_LIBCPP "$TMP/stdlib.log" 2>/dev/null; then
+        pass "libc++" "as expected for CLANG64; a divergence from the libstdc++ Linux build"
+    elif grep -q MARKER_LIBSTDCXX "$TMP/stdlib.log" 2>/dev/null; then
+        warn "libstdc++, not libc++" "unexpected for CLANG64 -- check which environment is active"
+    else
+        warn "could not determine the C++ standard library"
+    fi
+
+    head2 "C runtime"
+    if try_compile crt c "" compile <<'EOF'
+#include <stdio.h>
+#if defined(_UCRT)
+#  error MARKER_UCRT
+#else
+#  error MARKER_MSVCRT
+#endif
+EOF
+    then :; fi
+    if grep -q MARKER_UCRT "$TMP/crt.log" 2>/dev/null; then
+        pass "UCRT" "in-box on Windows 10+, no redistributable"
+    elif grep -q MARKER_MSVCRT "$TMP/crt.log" 2>/dev/null; then
+        warn "MSVCRT, not UCRT" "the plan recommends UCRT; see 'UCRT vs MSVCRT'"
+    else
+        warn "could not determine the C runtime"
+    fi
+fi
+
+# ------------------------------------------------------- MSVC-ism compiling --
+
+head1 "3. MSVC extensions the tree depends on"
+
+echo "  These decide CLANG64 vs the GCC environments.  A failure here does not"
+echo "  mean 'try GCC instead' -- it means source changes at the sites listed."
+
+head2 "SEH (__try/__except) -- 17 sites in vcl/win, sal/osl/w32, dtrans"
+if try_compile seh c "-O1" run <<'EOF'
+#include <windows.h>
+static int probe(void) {
+    int r = 0;
+    __try { r = 1; }
+    __except (EXCEPTION_EXECUTE_HANDLER) { r = 2; }
+    return r;
+}
+int main(void) { return probe() == 1 ? 0 : 1; }
+EOF
+    then pass "__try/__except compiles and runs"
+    else fail "__try/__except unusable" "would require rewriting ~15 SEH sites" CRITICAL
+         show_log seh
+    fi
+
+head2 "__uuidof -- 13 production files (sal, dtrans, fpicker, extensions/ole)"
+if try_compile uuidof cxx "-fms-extensions" compile <<'EOF'
+#include <windows.h>
+#include <unknwn.h>
+const GUID* g = &__uuidof(IUnknown);
+EOF
+    then pass "__uuidof compiles" "with -fms-extensions"
+    else fail "__uuidof unusable" "would require explicit IID_* GUIDs across 13 files" CRITICAL
+         show_log uuidof
+    fi
+
+head2 "__declspec(uuid) -- avmedia/source/win/interface.hxx"
+if try_compile declspec_uuid cxx "-fms-extensions" compile <<'EOF'
+#include <windows.h>
+#include <unknwn.h>
+struct __declspec(uuid("65BD0710-24D2-4ff7-9324-ED2E5D3ABAFA")) IProbe : public IUnknown {
+    virtual void STDMETHODCALLTYPE probe() = 0;
+};
+const GUID* g = &__uuidof(IProbe);
+EOF
+    then pass "__declspec(uuid) compiles"
+    else fail "__declspec(uuid) unusable" "avmedia/source/win would need rework" CRITICAL
+         show_log declspec_uuid
+    fi
+
+# ------------------------------------------------- cross-DLL exception flow --
+
+head1 "4. Cross-DLL typed exceptions (early signal for the UNO bridge)"
+
+echo "  The bridge must let an exception thrown in one DLL be caught by type in"
+echo "  another.  This is a much-reduced stand-in for that requirement -- it does"
+echo "  not exercise RTTI synthesis or the Win64 marshalling, which remain the"
+echo "  real Phase 1 work."
+
+cat > "$TMP/exc.hxx" <<'EOF'
+struct ExcBase { virtual ~ExcBase(); int a; };
+struct ExcDerived : public ExcBase { int b; };
+EOF
+cat > "$TMP/thrower.cxx" <<'EOF'
+#include "exc.hxx"
+ExcBase::~ExcBase() {}
+extern "C" __declspec(dllexport) void do_throw() { ExcDerived d; d.a = 1; d.b = 2; throw d; }
+EOF
+cat > "$TMP/catcher.cxx" <<'EOF'
+#include "exc.hxx"
+#include <cstdio>
+extern "C" __declspec(dllimport) void do_throw();
+int main() {
+    try { do_throw(); }
+    catch (ExcDerived&) { std::printf("EXACT\n"); return 0; }
+    catch (ExcBase&)    { std::printf("BASE\n");  return 0; }
+    catch (...)         { std::printf("ELLIPSIS\n"); return 1; }
+    return 1;
+}
+EOF
+if (cd "$TMP" && clang++ -shared -o thrower.dll thrower.cxx -Wl,--out-implib,libthrower.a > exc.log 2>&1 \
+    && clang++ -o catcher.exe catcher.cxx -L. -lthrower >> exc.log 2>&1); then
+    EXC_OUT="$(cd "$TMP" && ./catcher.exe 2>&1)"
+    case "$EXC_OUT" in
+        EXACT) pass "exception caught as exact derived type across a DLL boundary" ;;
+        BASE)  warn "caught as base only" "type matching is degraded across images" ;;
+        *)     fail "caught only by catch(...)" \
+                    "typed exceptions do not cross DLLs -- a serious problem for the bridge" HIGH ;;
+    esac
+else
+    fail "cross-DLL exception harness did not build" "" MEDIUM
+    sed -n '1,8p' "$TMP/exc.log" | sed 's/^/           | /'
+fi
+
+# ----------------------------------------------------------------- Win32 API --
+
+head1 "5. mingw-w64 Win32 API coverage"
+
+probe_header() {  # probe_header <header> <severity> <what-it-is-for>
+    local h="$1" sev="$2" what="$3" name
+    name="hdr_$(echo "$h" | tr './' '__')"
+    if printf '#include <%s>\nint main(void){return 0;}\n' "$h" | \
+        try_compile "$name" c "-fms-extensions" compile; then
+        pass "$h" "$what"
+    else
+        fail "$h not usable" "$what" "$sev"
+    fi
+}
+
+probe_header windows.h    CRITICAL "core Win32"
+probe_header unknwn.h     CRITICAL "COM"
+probe_header shlobj.h     MEDIUM   "shell extensions"
+probe_header uxtheme.h    MEDIUM   "vcl theming"
+probe_header comdef.h     MEDIUM   "_com_ptr_t -- connectivity/source/drivers/ado"
+probe_header d3d9.h       LOW      "canvas/source/directx"
+probe_header strmif.h     LOW      "avmedia/source/win (DirectShow)"
+probe_header adoint.h     LOW      "ADO driver -- expected to need the Windows SDK, not mingw-w64"
+
+# ----------------------------------------------------------------------- ATL --
+
+head1 "6. ATL  (the highest-value probe in this script)"
+
+echo "  If ATL cannot be compiled by clang, the de-ATL port of winaccessibility,"
+echo "  extensions/source/ole and embedserv comes back: roughly 6-10 extra weeks,"
+echo "  moving the project from ~3.5-6 to ~5-9 person-months."
+echo
+echo "  Note: modern ATL ships with Visual Studio / VS Build Tools under"
+echo "  VC/Tools/MSVC/<ver>/atlmfc, NOT with the standalone Windows SDK.  The"
+echo "  feasibility document assumes the standalone SDK carries it; this probe"
+echo "  is what settles that."
+
+ATL_DIR=""
+if [ -n "$ATL_INCLUDE_OVERRIDE" ]; then
+    ATL_DIR="$ATL_INCLUDE_OVERRIDE"
+else
+    for cand in \
+        /c/Program\ Files/Microsoft\ Visual\ Studio/*/*/VC/Tools/MSVC/*/atlmfc/include \
+        /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/*/*/VC/Tools/MSVC/*/atlmfc/include \
+        /c/Program\ Files\ \(x86\)/Windows\ Kits/10/Include/*/atl \
+        /c/Program\ Files/Windows\ Kits/10/Include/*/atl ; do
+        if [ -f "$cand/atlbase.h" ]; then ATL_DIR="$cand"; break; fi
+    done
+fi
+
+if [ -z "$ATL_DIR" ]; then
+    warn "no ATL installation found" \
+         "install 'C++ ATL' via VS Build Tools, or pass --atl-include=<dir>" HIGH
+    info "searched" "Visual Studio VC/Tools/MSVC/*/atlmfc/include and Windows Kits/10/Include/*/atl"
+else
+    info "ATL headers" "$ATL_DIR"
+    if try_compile atl cxx "-fms-extensions -fms-compatibility -I\"$ATL_DIR\"" compile <<'EOF'
+#include <atlbase.h>
+#include <atlcom.h>
+CComModule _Module;
+struct Probe { CComPtr<IUnknown> p; CComBSTR s; };
+EOF
+        then pass "ATL compiles under clang" "the plan's Phase 3 estimate holds"
+        else fail "ATL does not compile under clang" \
+                  "reinstates the de-ATL port; re-estimate Phase 3 at 6-10 weeks" HIGH
+             show_log atl
+        fi
+fi
+
+# --------------------------------------------------------------- host tools --
+
+head1 "7. Packaging and host tools"
+
+find_win_tool() {  # find_win_tool <exe> <severity> <what-for>
+    local exe="$1" sev="$2" what="$3" p
+    if p="$(command -v "$exe" 2>/dev/null)"; then
+        pass "$exe" "$p"
+        return
+    fi
+    p="$(find "/c/Program Files (x86)/Windows Kits/10/bin" "/c/Program Files/Windows Kits/10/bin" \
+         -maxdepth 3 -iname "$exe" 2>/dev/null | head -1)"
+    if [ -n "$p" ]; then
+        warn "$exe not on PATH" "found at $p -- add its directory to PATH"
+    else
+        fail "$exe not found" "$what" "$sev"
+    fi
+}
+
+head2 "MSI construction (installer/control.pm:105)"
+find_win_tool msidb.exe   HIGH   "Windows SDK component; required to build the MSI"
+find_win_tool msitran.exe HIGH   "Windows SDK component; required to build the MSI"
+find_win_tool msiinfo.exe HIGH   "Windows SDK component; required to build the MSI"
+find_win_tool uuidgen.exe HIGH   "Windows SDK component"
+find_win_tool makecab.exe MEDIUM "ships with Windows itself"
+find_win_tool expand.exe  MEDIUM "ships with Windows itself"
+
+head2 "code signing (optional)"
+find_win_tool signtool.exe LOW "only needed for signed builds"
+
+head2 "Java"
+if command -v javac >/dev/null 2>&1; then
+    pass "javac" "$(javac -version 2>&1 | head -1)"
+    info "JAVA_HOME" "${JAVA_HOME:-<unset>}"
+else
+    warn "javac not found" "install a native Windows JDK; MSYS2 ships none"
+fi
+
+# ------------------------------------------------------- system-lib packages --
+
+head1 "8. --with-system-* package availability"
+
+echo "  AOO exposes 37 --with-system-* options and none is gated off on Windows,"
+echo "  so every library MSYS2 can supply is one less bundled build to maintain."
+echo "  system-python in particular avoids building bundled CPython under mingw."
+
+if command -v pacman >/dev/null 2>&1; then
+    AVAILABLE=0; MISSING=""
+    for p in "${SYSLIB_PKGS[@]}"; do
+        full="mingw-w64-clang-x86_64-$p"
+        if pacman -Si "$full" >/dev/null 2>&1; then
+            if pacman -Qi "$full" >/dev/null 2>&1; then
+                echo "  [ have ] $full"
+            else
+                echo "  [ avail] $full  (not installed)"
+            fi
+            AVAILABLE=$((AVAILABLE+1))
+        else
+            echo "  [ none ] $full"
+            MISSING="$MISSING $p"
+        fi
+    done
+    info "system libraries available in CLANG64" "$AVAILABLE of ${#SYSLIB_PKGS[@]}"
+    [ -n "$MISSING" ] && info "no CLANG64 package (would stay bundled)" "$(echo "$MISSING" | sed 's/^ //')"
+fi
+
+# ------------------------------------------------------------------ summary --
+
+head1 "Summary"
+
+printf '  %-6s %-9s %s\n' STATUS SEVERITY PROBE
+printf '  %-6s %-9s %s\n' ------ -------- -----
+for row in "${SUMMARY[@]}"; do
+    IFS='|' read -r st sev lbl det <<< "$row"
+    [ "$st" = "INFO" ] && continue
+    printf '  %-6s %-9s %s\n' "$st" "${sev:--}" "$lbl"
+    [ -n "$det" ] && printf '  %-6s %-9s   %s\n' "" "" "$det"
+done
+
+echo
+echo "  pass $PASS_N   fail $FAIL_N   warn $WARN_N"
+echo
+
+if [ "$CRITICAL_FAILED" -eq 1 ]; then
+    echo "  RESULT: a CRITICAL probe failed.  The approach as planned does not hold"
+    echo "  on this machine -- resolve those before any Phase 0 work."
+    exit 1
+fi
+
+echo "  RESULT: no CRITICAL failures."
+echo
+echo "  Next, in order:"
+echo "    1. If the ATL probe failed or found nothing, settle that first -- it is"
+echo "       the difference between a ~3.5-6 and a ~5-9 person-month project."
+echo "    2. Prototype the Win64 GNU-ABI UNO bridge (plan section B1).  That is the"
+echo "       real go/no-go gate and needs no working AOO build to start."
+echo "    3. Only then begin Phase 0 build-system work."
+exit 0


(openoffice) 01/04: Add feasibility assessment for an MSYS2/clang Windows build

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch msys2-dev-prototype
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 701dec87464d0ce6f48eadb1858c292758acfc4d
Author: Jim Jagielski <ji...@gmail.com>
AuthorDate: Tue Aug 11 13:01:20 2026 -0400

    Add feasibility assessment for an MSYS2/clang Windows build
---
 MSYS2-WINDOWS-BUILD-FEASIBILITY.md | 339 +++++++++++++++++++++++++++++++++++++
 1 file changed, 339 insertions(+)

diff --git a/MSYS2-WINDOWS-BUILD-FEASIBILITY.md b/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
new file mode 100644
index 0000000000..5bb9af9c7d
--- /dev/null
+++ b/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
@@ -0,0 +1,339 @@
+# MSYS2 / clang as an alternative Windows build for Apache OpenOffice
+
+Scope: x86_64 only, Windows 10+, **additive** — the existing MSVC path stays the
+default and is not modified. Assessment against `trunk` as of 2026-08-11.
+
+Goal, restated: *reduce and contain* the Microsoft dependency, not eliminate it. Use
+the Windows SDK where it is genuinely the cheapest correct answer; use mingw-w64 and
+MSYS2 packages everywhere else. Optimise for a build that is easy to set up, easy to
+run, and cheap to maintain.
+
+## Verdict
+
+Feasible. With the Windows SDK allowed back in for the few things it uniquely provides,
+the project reduces to roughly **3.5–6 person-months**, and all but one phase is
+routine build-system work.
+
+The single hard blocker remains: **there is no C++/UNO bridge for the Win64 calling
+convention under the Itanium C++ ABI, and one must be written from scratch.** Everything
+else is now either already in the tree, available as an MSYS2 package, or obtainable
+from a standalone Windows SDK install.
+
+The maintenance argument is the strongest one for doing this at all. The current MSVC
+path is pinned to `COMEX` ≤ 12 — VS2008 (`set_soenv.in:715-723`, `configure.ac:2245`).
+An MSYS2 build tracks a rolling, self-updating toolchain and depends on the Windows SDK
+only as a small, explicitly-declared set of components that installs standalone without
+Visual Studio.
+
+## Where each dependency comes from
+
+| Need | Source | Notes |
+|---|---|---|
+| C/C++ compiler, linker, ar, strip | **MSYS2 CLANG64** | No MSVC, no MASM, no MSBuild, no VS install |
+| Win32 API headers and import libs | **mingw-w64** | Covers the overwhelming majority of the API surface |
+| C runtime | **UCRT** | In-box on Windows 10+; see the MSVCRT question below |
+| Shell, perl, make, autotools, pkg-config | **MSYS2** | Replaces the Cygwin dependency |
+| Most bundled third-party libraries | **MSYS2 packages** via `--with-system-*` | 38 such options already exist in `configure.ac` |
+| **ATL** | **Windows SDK** | mingw-w64 has none and no free ATL exists |
+| **MSI database tools** (`msidb`, `msitran`, `msiinfo`, `uuidgen`) | **Windows SDK** | `msitools`/WiX are not worth the effort |
+| **`signtool`** | **Windows SDK** | Only if producing signed builds |
+| ADO headers (`adoint.h`, `adodef.h`, …) | **Windows SDK** | Keeps the ADO database driver alive |
+| `makecab`, `expand` | **Windows itself** | In-box, no SDK needed |
+| IDL compilation | **mingw-w64 `widl`** | Easier than `midl.exe`, which wants `cl.exe` as its preprocessor |
+| DirectShow / Direct3D headers | **mingw-w64** | Legacy DirectX SDK not needed |
+| JDK | **native Windows JDK** | MSYS2 ships none |
+
+Net effect: **no Microsoft compiler or build tooling at all**, and the Windows SDK
+reduced to four discrete, auditable items. That is the dependency reduction that
+actually matters — the SDK is a stable, versioned, standalone download, whereas the
+current dependency is on a specific ancient Visual Studio.
+
+## The UCRT vs MSVCRT question
+
+**Recommendation: stay on UCRT (CLANG64). Do not move to MSVCRT.** The chain of
+reasoning is forced by the source tree, not by preference.
+
+Production code — not tests — uses two MSVC C++ extensions that GCC-mingw does not
+implement at all:
+
+- `__uuidof` in 13 production files: `sal/inc/systools/win32/comptr.hxx`,
+  `fpicker/source/win32/filepicker/{comptr.hxx,PreviewCtrl.cxx}`,
+  `dtrans/source/win32/{dtobj,dnd,mtaole}/*` (6 files), `extensions/source/ole/*`
+  (3 files), `extensions/source/activex/main/SOActiveX.cpp`.
+- `__declspec(uuid(...))` in `avmedia/source/win/interface.hxx:30,79,96`.
+
+Plus MSVC structured exception handling (`__try`/`__except`) at 17 sites in `vcl/win`,
+`sal/osl/w32`, `dtrans` and the MSVC bridges — again supported by clang on mingw
+targets, not by GCC.
+
+And now that we are deliberately consuming the SDK's ATL, a third reason appears: ATL
+headers are MSVC C++ and need `-fms-extensions` / `-fms-compatibility` to parse. Clang
+has those; GCC does not. This is precisely why the old
+`external/mingwheaders/mingw_atl_headers.patch` had to be 1654 lines — it was patching
+ATL to survive *GCC*. Under clang that patch should shrink to a small shim or vanish.
+
+So clang is required three times over. And MSYS2's x86_64 clang environment is
+**CLANG64, which is UCRT-only** — there is no clang + MSVCRT environment (MINGW64 is
+GCC + MSVCRT, UCRT64 is GCC + UCRT). Choosing MSVCRT therefore means choosing GCC,
+which means:
+
+1. Rewriting ~15 SEH sites;
+2. Replacing every `__uuidof` / `__declspec(uuid)` with explicit `IID_*` GUID
+   references across 14 production files;
+3. Abandoning SDK ATL and going back to a full de-ATL port of `winaccessibility`,
+   `extensions/source/ole` and `embedserv` — the 6–10 week item this revision was
+   meant to delete.
+
+Independently of all that, UCRT is simply the better target here. It is the in-box CRT
+on Windows 10+ (no redistributable), and modern Windows SDK components including ATL
+are themselves built against UCRT + vcruntime. Pairing SDK-provided ATL with an
+MSVCRT-based runtime would be a CRT mismatch — exactly the class of bug that is
+painful to diagnose. **Increasing our use of the Windows SDK argues for UCRT, not
+against it.**
+
+MSVCRT is documented here as a rejected option with a known cost, not as a fallback we
+are holding in reserve. If it is ever forced, the three items above are the bill.
+
+## What already exists in the tree
+
+| Artifact | State |
+|---|---|
+| `solenv/inc/wntgcci.mk` | 211-line MinGW platform makefile, 32-bit |
+| `solenv/gbuild/platform/winmingw.mk` | 753 lines, gbuild path |
+| `bridges/source/cpp_uno/mingw_intel/` | 1932 LOC, **x86 32-bit only** |
+| `configure.ac` `--with-mingwin` | Present, assumes Cygwin and `gcc -mno-cygwin` |
+| `set_soenv.in` | `OUTPATH=wntgcci`, `COM=GCC`, MinGW lib/include probing |
+| `sal/inc/sal/types.h:155` | Already handles `__MINGW32__` (`sal_Unicode` = `sal_uInt16`) |
+| `__MINGW32__` conditionals | 100 files across the tree |
+| `solenv/bin/addsym-mingw.sh`, `_tg_def.mk` MinGW branches | Export/`.def` handling present |
+| ~20 external modules | Already have `WNT` + `COM=GCC` build recipes |
+| `--with-system-*` | 38 options, none gated off on Windows |
+
+All of it is 32-bit and none has had functional work in years — every recent commit
+touching these files is whitespace or mechanical. But the build system already
+understands the concept of a GCC-flavoured Windows compiler, and `solenv/inc/wnt.mk:38`
+shows exactly where the 64-bit gap is: dispatch exists for `GCCWNTI` only.
+
+Set **`COM=GCC`** (not `COM=CLANG`) for the MSYS2 build. The CLANG64 driver is
+GCC-compatible, and `COM=GCC` reuses the existing `COM=="GCC"` branches in openssl,
+nss, icu, curl, libxml2, libxslt, libxmlsec, graphite and python at no cost. Setting
+`COM=CLANG`, as macOS does, would mean editing every one of them.
+
+## Remaining work
+
+### B1 — Win64 GNU-ABI UNO bridge (the only hard blocker)
+
+`bridges/source/cpp_uno/` has `msvc_win64_x86-64` (Win64 calling convention, MSVC C++
+ABI, MASM `call.asm`, MSVC RTTI/EH internals) and `gcc3_linux_x86-64` (SysV AMD64
+calling convention, Itanium ABI). The MSYS2 target needs the cross product: Win64
+calling convention with Itanium C++ ABI and clang unwinding. Neither can be reused
+as-is.
+
+LibreOffice dropped MinGW Windows support around 2013 and never had a 64-bit MinGW
+bridge, so there is nothing upstream to port.
+
+Composition, ~2000 LOC:
+
+- `uno2cpp.cxx` / `cpp2uno.cxx` — Win64 register allocation (RCX/RDX/R8/R9, XMM0–3,
+  32-byte shadow space, structs > 8 bytes by hidden pointer). Structurally closer to
+  `msvc_win64_x86-64` than to the Linux bridge.
+- `call.s` — GAS syntax rather than MASM; port the shape of `call.asm` (257 lines).
+- `except.cxx` — Itanium `__cxa_throw` and dynamically-synthesised `_ZTI` type_info.
+  `mingw_intel/except.cxx` (309 LOC) is the one genuinely reusable piece of the old
+  32-bit bridge.
+
+Direct precedent exists in this tree: the `s5abi_macosx_aarch64` bridge was the same
+class of problem — new calling convention, Itanium ABI, RTTI visibility quirks — and is
+done and shipped.
+
+**Risk: high. This is the go/no-go gate; prototype it before committing to the rest.**
+
+### B2 — ATL from the Windows SDK
+
+Four production modules need ATL: `winaccessibility/source/UAccCOM` (IAccessible2,
+i.e. NVDA/JAWS support), `extensions/source/ole` (UNO ↔ OLE Automation),
+`embedserv` (OLE embedding), `extensions/source/activex` (ActiveX control).
+
+With the SDK allowed, these are **kept, not ported**. Work reduces to:
+
+- A lean replacement for `external/mingwheaders` that adds the SDK's `include/atl` to
+  the include path and applies whatever residual shims clang still needs. Expect this
+  to be far smaller than the old 1654-line GCC-targeted patch; possibly empty.
+- Compiling those four modules with `-fms-extensions -fms-compatibility`.
+- Confirming ATL's static lib links cleanly against the UCRT-based mingw runtime.
+
+`shell/source/win32/shlxthandler` and `desktop/win32/source/setup` reference
+`MFC_INCLUDE` only for **resource compilation** — zero MFC code usage. Include-path
+fixes, not ports.
+
+`extensions/source/activex` (IE-era ActiveX control) remains a reasonable candidate to
+exclude from this configuration if it fights back, since the MSVC build still produces
+it.
+
+**Risk: medium — hinges on how cleanly clang parses current SDK ATL headers. Verify
+early; it is cheap to test and it re-opens the 6–10 week de-ATL port if it fails.**
+
+### B3 — cli_ure / .NET bindings (unavoidable, and acceptable)
+
+`cli_ure` requires C++/CLI (`/clr`), which clang cannot compile. It is already gated
+`w,vc7` in `cli_ure/prj/build.lst`, so it self-excludes under `COM=GCC` with no changes
+needed. Same mechanism excludes `testtools/.../bridgetest/cli`.
+
+Since the MSVC build remains the default, official .NET-capable binaries still come
+from that path. Document as a limitation of the MSYS2 configuration.
+
+### B4 — Externals via MSYS2 packages
+
+The biggest simplification available, and the one that most directly serves "easier and
+more straightforward". `configure.ac` already exposes `--with-system-*` for nss,
+openssl, icu, python, expat, libxml, libxslt, curl, boost, hunspell, hyphen, mythes,
+graphite, redland, zlib, jpeg, mdds, vigra, libtextcat, cairo, coinmp and more — none
+gated off on Windows, all pkg-config driven, and MSYS2 provides pkg-config and packages
+for essentially all of them.
+
+This deletes most of what was going to be a 4–8 week phase, and in particular sidesteps
+the worst single risk in the original assessment: **building the bundled Python 3 under
+mingw.** CPython upstream does not support mingw builds; MSYS2 carries its own patch
+set. Using `--with-system-python` avoids the problem entirely.
+
+Two consequences to plan for:
+
+- The installer must redistribute the MSYS2 DLLs it links against, plus CLANG64's
+  `libc++` and `libunwind`. Licensing is fine (all permissive or compatible), but the
+  packaging file lists need extending.
+- Static linking against MSYS2's `.a` files is an alternative that shrinks the
+  redistribution list at the cost of binary size. Decide per library.
+
+Where a system package proves unsuitable, the existing `COM=GCC` bundled-build branches
+are still there as a fallback.
+
+**Risk: low. Effort: moderate, mostly packaging.**
+
+### B5 — Host environment and configure
+
+- `configure.ac:1076` keys Windows detection on `build_os` matching `cygwin`. MSYS2's
+  `config.guess` reports `x86_64-pc-msys`; a parallel `msys*` branch is needed there
+  and at `configure.ac:1146` and `2274`.
+- The `gcc -mno-cygwin` detection (`configure.ac:1709-1721`, `2258`) is dead. MSYS2
+  compiler detection is a fresh code path, not a reuse of that one.
+- `cygpath` exists in MSYS2, so `set_soenv.in` and the installer Perl modules that call
+  it largely carry over — but MSYS2 path-translation semantics differ from Cygwin's and
+  each call site needs checking.
+- The Info-ZIP `zip.exe` check (`configure.ac:6037`) explicitly demands the Cygwin
+  build; needs an MSYS2 equivalent.
+- `solenv/bin/guw.pl` exists to wrap MSVC tools with Unix paths; irrelevant here.
+- `dmake` is built in-tree from source; MSYS2 can do this.
+
+Add a **single, explicit SDK entry point** — one `--with-windows-sdk=<path>` variable
+plus a documented minimal component list — so the Microsoft dependency is declared in
+one place and can be audited, version-pinned, and eventually shrunk further.
+
+**Risk: low-medium. Effort: moderate, touches many files.**
+
+### B6 — Odds and ends
+
+- IDL: replace `midl.exe` with mingw-w64 `widl` in `extensions/source/activex/msidl`
+  and `winaccessibility/source/UAccCOMIDL`. Chosen over `midl` because `midl` wants
+  `cl.exe` as its preprocessor, which would drag the MSVC compiler back in for no gain.
+- `fpicker/source/win32/filepicker/platform_vista.h` uses `#pragma comment(linker,
+  "/manifestdependency:...")` for the common-controls v6 manifest. Clang-mingw ignores
+  it; embed the manifest as an `RT_MANIFEST` resource instead, or themed controls
+  silently regress.
+- `connectivity/source/drivers/ado`: `comdef.h`/`_com_ptr_t` should come from
+  mingw-w64; the ADO headers themselves come from the SDK. Verify.
+- `canvas/source/directx`, `avmedia/source/win`: use mingw-w64's d3d9/dshow headers;
+  the legacy DirectX SDK dependency should be droppable. Verify.
+- Resources: `windres` or `llvm-rc` for `.rc`.
+- STLport already defaults off, so libc++ is not fighting a bundled STL. It *is* a
+  divergence from the proven libstdc++ Linux build — expect some strictness fallout in
+  old C++ code.
+
+## Making it easy to run
+
+Deliverables that should be part of the work, not afterthoughts:
+
+1. A `pacman -S` one-liner package list, checked into the tree.
+2. A bootstrap/build script following the pattern of the existing
+   `build_aoo64bit_on_macosarm.sh`, so a new machine is one script away from a build.
+3. A documented minimal Windows SDK component selection (ATL + MSI tools + signtool),
+   with the standalone-installer link — no Visual Studio.
+4. A single canonical `./configure` invocation for the MSYS2 build, favouring
+   `--with-system-*` by default.
+
+## Additive architecture
+
+Every item below is a new file or a new branch keyed on a new `COM`/`CPU`/OUTPATH
+triple, so the MSVC build is untouched by construction:
+
+1. New configure switch, e.g. `--enable-msys2-build`, orthogonal to `--with-mingwin`
+   (leave the legacy 32-bit switch alone rather than overloading it).
+2. New `OUTPATH=wntgccx` / `INPATH=wntgccx.pro`, with `CPU=X`, `CPUNAME=X86_64`,
+   `COM=GCC`, `GUI=WNT`.
+3. New `solenv/inc/wntgccx.mk`, dispatched from `solenv/inc/wnt.mk` on
+   `$(COM)$(OS)$(CPU)` == `GCCWNTX`. Model the clang/Itanium side on
+   `unxmacc.mk`/`unxlngx.mk` and the Windows link/export side on `wntgcci.mk`.
+4. New bridge directory `bridges/source/cpp_uno/mingw_x86-64/`.
+5. New `solenv/gbuild/platform/winclang.mk` for gbuild-converted modules — branch from
+   `winmingw.mk` rather than editing it, since that file is 32-bit-shaped.
+6. Replace `external/mingwheaders` with a minimal SDK-ATL include shim rather than
+   reviving its PSDK header-copying.
+
+## Phasing and effort
+
+| Phase | Content | Effort |
+|---|---|---|
+| 0 | Host env, `msys*` detection in configure, `set_soenv.in`, `wntgccx.mk`, dmake bootstrap, SDK entry point | 2–3 weeks |
+| 1 | **Win64 GNU-ABI UNO bridge** + sal/cppu/cppuhelper building and `bridgetest` passing | 6–10 weeks |
+| 2 | Externals via `--with-system-*`; packaging file lists for MSYS2 + libc++ runtime DLLs | 2–4 weeks |
+| 3 | Windows integration modules against SDK ATL; `widl` migration; manifest fix | 2–4 weeks |
+| 4 | Installer using SDK MSI tools; signing | 2–3 weeks |
+
+**Roughly 3.5–6 person-months**, down from 6–12 in the SDK-free version. Phase 1
+dominates and is the go/no-go gate. Phase 3's estimate assumes SDK ATL compiles under
+clang with minimal shimming — cheap to test in a day, and worth testing during Phase 0
+because failure reinstates a 6–10 week de-ATL port.
+
+## Capability delta versus the MSVC build
+
+Permanently absent:
+- .NET/CLI UNO bindings (`cli_ure`, `climaker`) — no C++/CLI in clang. Mitigated by
+  the MSVC build remaining the default.
+
+Retained by using SDK ATL (these were the at-risk items in the SDK-free plan):
+- IAccessible2 accessibility bridge — screen-reader support.
+- UNO ↔ OLE Automation bridge.
+- OLE embedding server.
+- ActiveX control, unless deliberately excluded.
+
+Undetermined pending verification:
+- ADO database driver, DirectX canvas backend, DirectShow media backend.
+
+## What I verified versus what I asserted
+
+Verified by inspection of this tree: every file path, line number and LOC count; module
+gating (`w,vc7`); the 17 SEH sites; the 13 production files using `__uuidof` and the
+three `__declspec(uuid)` sites in `avmedia`; the ATL reference counts per module and
+the fact that `shlxthandler`/`setup` use `MFC_INCLUDE` for resources only; the absence
+of a 64-bit GCC dispatch in `wnt.mk`; the `__MINGW32__`/`sal_Unicode` handling; the PSDK
+dependency in `external/mingwheaders`; the installer's required-tools list in
+`control.pm:105`; the 38 `--with-system-*` options and their lack of Windows gating; the
+`COMEX` ≤ 12 ceiling on the MSVC path; and the staleness of the MinGW files in git
+history.
+
+Asserted from knowledge of the toolchains, **not** verified against a live MSYS2 or
+Windows SDK install:
+
+- That MSYS2 CLANG64 targets `x86_64-w64-windows-gnu` with the Itanium C++ ABI, libc++
+  and compiler-rt, and that no clang + MSVCRT environment exists for x86_64.
+- That clang supports `__try`/`__except`, `__uuidof` and `__declspec(uuid)` on mingw
+  targets and GCC does not.
+- That clang's `-fms-extensions`/`-fms-compatibility` are sufficient to parse current
+  Windows SDK ATL headers — **the highest-value thing to test first**, since it decides
+  Phase 3's size.
+- That the Windows SDK installs standalone without Visual Studio and that ATL is
+  available in that installation.
+- That mingw-w64 provides `comdef.h`, d3d9 and dshow headers, and that `widl` is an
+  adequate `midl` replacement.
+- That MSYS2 packages exist and are usable for the `--with-system-*` set named above.
+
+No build was attempted; there is no Windows or MSYS2 host in this environment.


(openoffice) 03/04: Record the --with-system-* audit and correct where ATL comes from

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch msys2-dev-prototype
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit fefcf25cecc0e53f43d6d9c440c2ef8d5faa59cc
Author: Jim Jagielski <ji...@gmail.com>
AuthorDate: Tue Aug 11 13:19:35 2026 -0400

    Record the --with-system-* audit and correct where ATL comes from
    
    All 37 options are clear of Windows gating, so the externals phase can lean on
    MSYS2 packages as planned. ATL, though, looks like a Visual Studio Build Tools
    component rather than part of the standalone SDK, which weakens the "no Visual
    Studio at all" claim until the probe settles it.
---
 MSYS2-WINDOWS-BUILD-FEASIBILITY.md | 60 ++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 19 deletions(-)

diff --git a/MSYS2-WINDOWS-BUILD-FEASIBILITY.md b/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
index 34c1c02532..3d55943278 100644
--- a/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
+++ b/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
@@ -38,9 +38,9 @@ from a standalone Windows SDK install.
 
 The maintenance argument is the strongest one for doing this at all. The current MSVC
 path is pinned to `COMEX` ≤ 12 — VS2008 (`set_soenv.in:715-723`, `configure.ac:2245`).
-An MSYS2 build tracks a rolling, self-updating toolchain and depends on the Windows SDK
-only as a small, explicitly-declared set of components that installs standalone without
-Visual Studio.
+An MSYS2 build tracks a rolling, self-updating toolchain and depends on Microsoft only
+through a small, explicitly-declared set of components — a current Windows SDK and, for
+ATL, a Build Tools component — rather than on one pinned IDE.
 
 ## Where each dependency comes from
 
@@ -51,7 +51,7 @@ Visual Studio.
 | C runtime | **UCRT** | In-box on Windows 10+; see the MSVCRT question below |
 | Shell, perl, make, autotools, pkg-config | **MSYS2** | Replaces the Cygwin dependency |
 | Most bundled third-party libraries | **MSYS2 packages** via `--with-system-*` | 38 such options already exist in `configure.ac` |
-| **ATL** | **Windows SDK** | mingw-w64 has none and no free ATL exists |
+| **ATL** | **VS Build Tools** — *not* the standalone SDK, see below | mingw-w64 has none and no free ATL exists |
 | **MSI database tools** (`msidb`, `msitran`, `msiinfo`, `uuidgen`) | **Windows SDK** | `msitools`/WiX are not worth the effort |
 | **`signtool`** | **Windows SDK** | Only if producing signed builds |
 | ADO headers (`adoint.h`, `adodef.h`, …) | **Windows SDK** | Keeps the ADO database driver alive |
@@ -60,10 +60,23 @@ Visual Studio.
 | DirectShow / Direct3D headers | **mingw-w64** | Legacy DirectX SDK not needed |
 | JDK | **native Windows JDK** | MSYS2 ships none |
 
-Net effect: **no Microsoft compiler or build tooling at all**, and the Windows SDK
-reduced to four discrete, auditable items. That is the dependency reduction that
-actually matters — the SDK is a stable, versioned, standalone download, whereas the
-current dependency is on a specific ancient Visual Studio.
+Net effect: **the Microsoft compiler is not used at all**, and the Microsoft dependency
+reduces to four discrete, auditable items. That is the reduction that actually matters —
+a current, versioned SDK and (for ATL) a Build Tools component, versus today's dependency
+on one specific ancient Visual Studio.
+
+**Correction, pending the probe.** An earlier draft claimed all four items come from a
+standalone Windows SDK with no Visual Studio involvement. That is probably wrong for ATL:
+modern ATL ships as a Visual Studio / VS Build Tools component under
+`VC/Tools/MSVC/<ver>/atlmfc`, not under `Windows Kits`. AOO's own history points the same
+way — `external/mingwheaders/makefile.mk:47` reads ATL out of `$(PSDK_HOME)/include/atl`,
+i.e. the old Platform SDK, which today's standalone SDK is not a continuation of for this
+purpose.
+
+If that holds, the honest statement is *"no Visual Studio IDE and no MSVC compiler, but
+one Build Tools component for ATL"* — still a large reduction, but not the clean claim.
+`msys2-probe.sh` searches both locations and settles it. The MSI tools and `signtool` are
+genuinely Windows SDK, and are unaffected.
 
 ## The UCRT vs MSVCRT question
 
@@ -124,7 +137,7 @@ are holding in reserve. If it is ever forced, the three items above are the bill
 | `__MINGW32__` conditionals | 100 files across the tree |
 | `solenv/bin/addsym-mingw.sh`, `_tg_def.mk` MinGW branches | Export/`.def` handling present |
 | ~20 external modules | Already have `WNT` + `COM=GCC` build recipes |
-| `--with-system-*` | 38 options; the 8 spot-checked are not gated off on Windows |
+| `--with-system-*` | 37 options; **audited — none is gated off on Windows** |
 
 All of it is 32-bit and none has had functional work in years — every recent commit
 touching these files is whitespace or mechanical. But the build system already
@@ -202,11 +215,19 @@ from that path. Document as a limitation of the MSYS2 configuration.
 ### B4 — Externals via MSYS2 packages
 
 The biggest simplification available, and the one that most directly serves "easier and
-more straightforward". `configure.ac` already exposes `--with-system-*` for nss,
+more straightforward". `configure.ac` exposes 37 `--with-system-*` options — nss,
 openssl, icu, python, expat, libxml, libxslt, curl, boost, hunspell, hyphen, mythes,
-graphite, redland, zlib, jpeg, mdds, vigra, libtextcat, cairo, coinmp and more — none
-gated off on Windows, all pkg-config driven, and MSYS2 provides pkg-config and packages
-for essentially all of them.
+graphite, redland, zlib, jpeg, mdds, vigra, libtextcat, cairo, coinmp, poppler and more.
+
+**Audited in full: not one is gated off on Windows.** The only `_os` interactions are
+Darwin force-on defaults (`zlib` at `configure.ac:3851`, `python` at `4126`, `curl` at
+`4692`), a feature gate that explicitly *includes* WINNT (`graphite`, `5110`), and
+feature gates unrelated to platform (`cairo` behind `test_cairo`, `poppler` behind
+`enable_pdfimport`, `dicts` behind its own flag). All are pkg-config driven, and MSYS2
+supplies pkg-config.
+
+Which of them MSYS2 actually packages for the clang64 prefix is a separate question, and
+the one thing here still unmeasured — `msys2-probe.sh` section 8 enumerates it.
 
 This deletes most of what was going to be a 4–8 week phase, and in particular sidesteps
 the worst single risk in the original assessment: **building the bundled Python 3 under
@@ -367,10 +388,9 @@ three `__declspec(uuid)` sites in `avmedia`; the ATL reference counts per module
 the fact that `shlxthandler`/`setup` use `MFC_INCLUDE` for resources only; the absence
 of a 64-bit GCC dispatch in `wnt.mk`; the `__MINGW32__`/`sal_Unicode` handling; the PSDK
 dependency in `external/mingwheaders`; the installer's required-tools list in
-`control.pm:105`; the existence of 38 `--with-system-*` options and the absence of Windows
-gating in the 8 spot-checked (openssl, expat, libxml, curl, boost, hunspell, icu, nss —
-the other 30 were not checked); the `COM=GCC` version-decoding path at
-`configure.ac:2301` and the CCNUMVER gates named in B5a; the
+`control.pm:105`; all 37 `--with-system-*` options and the absence of Windows gating in
+every one of them (B4); the `COM=GCC` version-decoding path at `configure.ac:2301` and the
+CCNUMVER gates named in B5a; the
 `COMEX` ≤ 12 ceiling on the MSVC path; and the staleness of the MinGW files in git
 history.
 
@@ -384,8 +404,10 @@ Windows SDK install:
 - That clang's `-fms-extensions`/`-fms-compatibility` are sufficient to parse current
   Windows SDK ATL headers — **the highest-value thing to test first**, since it decides
   Phase 3's size.
-- That the Windows SDK installs standalone without Visual Studio and that ATL is
-  available in that installation.
+- **Where ATL actually comes from.** An earlier draft asserted the standalone Windows SDK
+  carries it; on reflection that is probably wrong (modern ATL is a VS Build Tools
+  component). Neither the old claim nor the correction has been verified on a real
+  machine — `msys2-probe.sh` section 6 searches both locations.
 - That mingw-w64 provides `comdef.h`, d3d9 and dshow headers, and that `widl` is an
   adequate `midl` replacement.
 - That MSYS2 packages exist and are usable for the `--with-system-*` set named above.


(openoffice) 02/04: Baseline the MSYS2 build at x86_64 and note the CCNUMVER gate hazard

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch msys2-dev-prototype
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit fec32e0c2741cf7efba3edffb9dfaa558af61403
Author: Jim Jagielski <ji...@gmail.com>
AuthorDate: Tue Aug 11 13:08:25 2026 -0400

    Baseline the MSYS2 build at x86_64 and note the CCNUMVER gate hazard
    
    Windows on ARM is deferred, so key the platform on $(COM)$(OS)$(CPU) rather
    than $(COM)$(OS) to keep adding it a new OUTPATH instead of a refactor.
---
 MSYS2-WINDOWS-BUILD-FEASIBILITY.md | 60 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 3 deletions(-)

diff --git a/MSYS2-WINDOWS-BUILD-FEASIBILITY.md b/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
index 5bb9af9c7d..34c1c02532 100644
--- a/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
+++ b/MSYS2-WINDOWS-BUILD-FEASIBILITY.md
@@ -1,8 +1,25 @@
 # MSYS2 / clang as an alternative Windows build for Apache OpenOffice
 
-Scope: x86_64 only, Windows 10+, **additive** — the existing MSVC path stays the
+Scope: **x86_64 only**, Windows 10+, **additive** — the existing MSVC path stays the
 default and is not modified. Assessment against `trunk` as of 2026-08-11.
 
+Explicitly out of scope, in both directions:
+
+- **32-bit Windows.** Not supported by this build mode. The existing `wntgcci` OUTPATH
+  and the `mingw_intel` bridge are 32-bit and are neither revived nor extended.
+- **Windows on ARM (arm64).** Deferred. MSYS2 does ship a CLANGARM64 environment, so the
+  door is open, but nothing here is planned or estimated for it. x86_64 is the baseline
+  and the only target that Phase 1's go/no-go decision covers.
+
+Keep the architecture additive along the CPU axis as well as the compiler axis, so that
+adding arm64 later is a new OUTPATH plus a new bridge rather than a refactor. Concretely:
+key everything on `$(COM)$(OS)$(CPU)` as `GCCWNTX`, never on `$(COM)$(OS)` alone. If
+Windows/arm64 is ever taken up it becomes `GCCWNTR` (or whatever CPU letter is chosen)
+with its own `wntgccr.mk` and its own bridge — and that bridge is a **third** piece of
+work, not a recompile: Windows/arm64 uses AAPCS64 with Microsoft's variations, so neither
+the Win64/x86_64 bridge built here nor the existing `s5abi_macosx_aarch64` bridge would
+drop in unchanged.
+
 Goal, restated: *reduce and contain* the Microsoft dependency, not eliminate it. Use
 the Windows SDK where it is genuinely the cheapest correct answer; use mingw-w64 and
 MSYS2 packages everywhere else. Optimise for a build that is easy to set up, easy to
@@ -107,7 +124,7 @@ are holding in reserve. If it is ever forced, the three items above are the bill
 | `__MINGW32__` conditionals | 100 files across the tree |
 | `solenv/bin/addsym-mingw.sh`, `_tg_def.mk` MinGW branches | Export/`.def` handling present |
 | ~20 external modules | Already have `WNT` + `COM=GCC` build recipes |
-| `--with-system-*` | 38 options, none gated off on Windows |
+| `--with-system-*` | 38 options; the 8 spot-checked are not gated off on Windows |
 
 All of it is 32-bit and none has had functional work in years — every recent commit
 touching these files is whitespace or mechanical. But the build system already
@@ -230,6 +247,40 @@ one place and can be audited, version-pinned, and eventually shrunk further.
 
 **Risk: low-medium. Effort: moderate, touches many files.**
 
+#### B5a — `COM=GCC` misroutes compiler-version detection
+
+A consequence of the `COM=GCC` decision that needs handling deliberately rather than by
+accident. `configure.ac:2301-2303` derives the version for `COM=GCC` from
+`${CC} -dumpfullversion -dumpversion`. Clang answers with *its own* version, so
+`CCNUMVER` lands around `002000010000` for clang 20 and is then compared against gates
+that were written to mean GCC versions.
+
+Most of the tree survives this by luck, because clang's major version sits above every
+GCC gate:
+
+- `solenv/inc/rules.mk:97,109` and `openssl/makefile.mk:59` test
+  `COM==GCC && CCNUMVER >= 000300040000` / `>= 000400060000` → true, which is what we
+  want.
+- `svx/Library_svxcore.mk:454` and `dbaccess/Library_dbui.mk:291` gate a GCC 4.9-specific
+  workaround on `4.9 <= CCNUMVER < 5.0` → false, also what we want.
+- The `CCNUMVER <= 001399999999` gates in `extensions/source/ole/makefile.mk:75,99`,
+  `desktop/util/makefile.mk:233,249` and `embedserv/util/makefile.mk:67` are *MSVC*
+  version gates (13.x = VC7) that will now be evaluated against a clang version → false.
+  Probably the desired modern behaviour, but it is an accident: those branches were never
+  meant to be reached by a non-MSVC compiler at all.
+
+Decide this explicitly in Phase 0 — either add an MSYS2/clang branch to the version
+decoding that sets `CCNUMVER` to something the `COM==GCC` gates interpret correctly, or
+keep clang's real version and audit the gates once, documenting that GCC-version tests
+are permanently "modern". Do not leave it implicit; a future clang major bump could flip
+a gate nobody knew was live.
+
+Two adjacent pre-existing defects to be aware of while working here, neither introduced
+by this project: `configure.ac:2306-2309` has an unreachable `elif` (both branches test
+`CCNUMVER -ge 000300000001`), and `COM=CLANG` on non-Darwin already routes to
+`COMID="gcc3"` at `configure.ac:2322-2325`, which is a second, separate path to the same
+class of confusion.
+
 ### B6 — Odds and ends
 
 - IDL: replace `midl.exe` with mingw-w64 `widl` in `extensions/source/activex/msidl`
@@ -316,7 +367,10 @@ three `__declspec(uuid)` sites in `avmedia`; the ATL reference counts per module
 the fact that `shlxthandler`/`setup` use `MFC_INCLUDE` for resources only; the absence
 of a 64-bit GCC dispatch in `wnt.mk`; the `__MINGW32__`/`sal_Unicode` handling; the PSDK
 dependency in `external/mingwheaders`; the installer's required-tools list in
-`control.pm:105`; the 38 `--with-system-*` options and their lack of Windows gating; the
+`control.pm:105`; the existence of 38 `--with-system-*` options and the absence of Windows
+gating in the 8 spot-checked (openssl, expat, libxml, curl, boost, hunspell, icu, nss —
+the other 30 were not checked); the `COM=GCC` version-decoding path at
+`configure.ac:2301` and the CCNUMVER gates named in B5a; the
 `COMEX` ≤ 12 ceiling on the MSVC path; and the staleness of the MinGW files in git
 history.