Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ jobs:
release: false
update: false
install: >-
${{ matrix.arch == 'x64' && 'mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake' || 'mingw-w64-i686-toolchain mingw-w64-i686-cmake' }}
${{ matrix.arch == 'x64' && 'mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake' || 'mingw-w64-i686-toolchain mingw-w64-i686-cmake' }} python git make

- name: Build static ACE library (MinGW)
if: always() && runner.os == 'Windows'
shell: msys2 {0}
run: |
cmake -S . -B build/mingw-${{ matrix.arch }} -G "MinGW Makefiles" \
cmake -S . -B build/mingw-${{ matrix.arch }} -G "MSYS Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DOPENADS_BUILD_TESTS=ON \
-DOPENADS_VERSION_FORCE="${{ steps.tag.outputs.version }}" \
Expand All @@ -195,6 +195,25 @@ jobs:
ctest --test-dir build/mingw-${{ matrix.arch }} --output-on-failure -C Release
ls -la build/mingw-${{ matrix.arch }}/src/libopenace*.a

- name: Package one-archive static Harbour kit and run smoke
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
bits=32; if [ '${{ matrix.arch }}' = x64 ]; then bits=64; fi
bash tools/scripts/test_harbour_static_mingw.sh build/mingw-${{ matrix.arch }}/src/libopenace$bits.a $bits

- name: Regenerate MinGW DLL imports and link health probe
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
set -euo pipefail
BITS="${{ matrix.arch == 'x64' && '64' || '32' }}"
mkdir -p build/fresh-imports
python3 tools/scripts/regenerate_mingw_imports.py \
"build/${{ matrix.preset }}/src/Release/openace${BITS}.dll" \
"dist/import-libs/${{ matrix.arch }}/mingw/libace${BITS}.a" \
"build/fresh-imports/libace${BITS}.a" "$BITS"

- name: Stage release files (POSIX)
if: always() && runner.os != 'Windows'
shell: bash
Expand All @@ -217,6 +236,8 @@ jobs:
mkdir -p "$STAGE/include/openads"
cp include/openads/ace.h "$STAGE/include/ace.h"
cp include/openads/{ace,error,openads_sql,platform,version}.h "$STAGE/include/openads/"
mkdir -p "$STAGE/contrib/oads_hb"
cp contrib/oads_hb/{oads_hb.c,oads_stats_display.prg,README.md} "$STAGE/contrib/oads_hb/"
tar czvf "$STAGE.tar.gz" "$STAGE"
ls -la "$STAGE.tar.gz"
echo "ASSET=$STAGE.tar.gz" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -266,11 +287,15 @@ jobs:
# Static ACE library (MinGW): link into an hbmk2 -comp=mingw[64]
# app and no ace<bits>.dll is needed at all. Built in the
# "Build static ACE library (MinGW)" step above.
$staticLib = "build/mingw-${{ matrix.arch }}/src/libopenace$bits.a"
$staticLib = "build/static-kit-$bits/libopenace$bits.a"
if (-not (Test-Path $staticLib)) {
throw "Static ACE library missing: $staticLib"
}
Copy-Item $staticLib "$stage/libopenace$bits.a"
Copy-Item "build/static-kit-$bits/libopenace$bits.manifest.json" "$stage/"
Copy-Item -Recurse "build/static-kit-$bits/runtime-notices" "$stage/"
Copy-Item docs/mingw-static-ace.md,docs/static-runtime-notices.md "$stage/"
Copy-Item "build/fresh-imports/libace$bits.a" "$stage/lib/mingw/libace$bits.a" -Force
# Server + bench CLIs
Copy-Item "$build/tools/serverd/Release/openads_serverd.exe" "$stage/"
Copy-Item "$build/tools/bench/Release/openads_bench.exe" "$stage/"
Expand All @@ -283,13 +308,13 @@ jobs:
# into the app, not shipped in the DLL. Arch-independent C
# source: both Windows zips carry it. (Pritpal Bedi.)
New-Item -ItemType Directory "$stage/contrib/oads_hb" -Force | Out-Null
Copy-Item contrib/oads_hb/oads_hb.c,contrib/oads_hb/README.md "$stage/contrib/oads_hb/"
Copy-Item contrib/oads_hb/oads_hb.c,contrib/oads_hb/oads_stats_display.prg,contrib/oads_hb/README.md "$stage/contrib/oads_hb/"
if ("${{ matrix.arch }}" -eq "x86") {
Copy-Item src/openads_ace_x86_stdcall.def "$stage/"
# Ship the 32-bit MinGW import library at the archive root too:
# 32-bit Harbour (hbmk2 -comp=mingw, rddads) links it directly.
# (Reported by Pritpal Bedi.)
Copy-Item dist/import-libs/x86/mingw/libace32.a "$stage/"
Copy-Item build/fresh-imports/libace32.a "$stage/"
} else {
Copy-Item src/openads_ace.def "$stage/"
}
Expand Down Expand Up @@ -438,12 +463,19 @@ jobs:
with tarfile.open(path) as t:
files = {m.name: t.extractfile(m).read() for m in t.getmembers() if m.isfile()}
byname = {pathlib.PurePosixPath(n).name: data for n, data in files.items()}
required = ['LICENSE','NOTICE','README.md','openads.ini.sample']
required = ['LICENSE','NOTICE','README.md','openads.ini.sample','oads_hb.c','oads_stats_display.prg']
windows = '-windows-' in path.name
if windows:
bits = '64' if '-x64.' in path.name else '32'
required += [f'ace{bits}.dll',f'openace{bits}.dll',f'ace{bits}.lib',f'openace{bits}.lib',f'libopenace{bits}.a','openads_serverd.exe','openads_bench.exe','oads_hb.c']
required += [f'ace{bits}.dll',f'openace{bits}.dll',f'ace{bits}.lib',f'openace{bits}.lib',f'libopenace{bits}.a',f'libopenace{bits}.manifest.json','openads_serverd.exe','openads_bench.exe','mingw-static-ace.md','static-runtime-notices.md']
assert byname[f'ace{bits}.dll'] == byname[f'openace{bits}.dll'], 'ACE aliases differ'
import json
manifest = json.loads(byname[f'libopenace{bits}.manifest.json'])
assert manifest['profile'] == 'matching', 'Unexpected release static profile'
assert manifest['archive_sha256'] == hashlib.sha256(byname[f'libopenace{bits}.a']).hexdigest(), 'Static archive hash mismatch'
for name, digest in manifest['runtime_notice_sha256'].items():
assert any(n.endswith('/runtime-notices/' + name) and hashlib.sha256(data).hexdigest() == digest for n, data in files.items()), f'Missing or mismatched runtime notice {name}'
assert len(manifest['runtime_notice_sha256']) == 4, 'Missing runtime notices'
binary = byname['openads_serverd.exe']
else:
ext = 'dylib' if '-macos-' in path.name else 'so'
Expand Down
40 changes: 40 additions & 0 deletions docs/mingw-static-ace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# MinGW static client kit

`libopenace32.a` or `libopenace64.a` is the combined implementation archive.
It contains the OpenADS engine, its bundled dependencies, the matching static
C++/GCC/pthread runtime, and compiled Harbour wrappers. `libace32.a` and
`libace64.a` are DLL import libraries, not substitutes.

Use your matching Harbour VM and ADS RDD. Rebuild the ADS driver against the
supplied `ace.h` (cdecl for MinGW). Link the implementation archive after that
RDD and keep Windows system libraries `ws2_32` and `psapi`. Do not compile a
second `oads_hb.c`, add another runtime archive, or add an ACE DLL import library.
Keep only one implementation archive visible in linker search directories.

The release runs `tools/scripts/test_harbour_static_mingw.sh` before staging
the combined archive, compiler/hash manifest and runtime notices. The script
is repository-only: it needs the source tree, packager, pinned Harbour source,
and a matching MSYS2 compiler. A downloaded kit is not a source-build tree.
The smoke rejects ACE, C++, GCC and pthread runtime DLL imports.

## Profiles

`matching` requires the same compiler for runtime and wrapper objects. The
standard release retains its existing MSYS2 compiler route. It does not change
the owner's compiler. Its current static configuration disables TLS and HTTP;
no TLS-enabled static kit is claimed by this change.

`qt492-x86` checks pinned i686 GCC10.2 runtime and Qt MinGW4.9.2 wrapper/link
compiler. It changes only BigObj containers, not machine code. The executable
TLS-exit bridge records the callback before CRT startup and registers cleanup
in the normal CRT constructor phase, avoiding the old CRT exit-lock deadlock.
It must not be reused for DLLs or unrelated toolchains. The matching-toolchain release smoke does not exercise this legacy profile.
Qualify it separately on the exact compiler pair and application before use.

The legacy profile also needs the exact compiler-distribution runtime notices
under `share/licenses`. Missing notices stop packaging; do not substitute a
newer compiler's notices. See `static-runtime-notices.md` before distribution.

Static linking removes the ACE DLL dependency. It does not prevent executable
patching, injected code or a rebuilt application. A passing smoke is not
production approval, a Vouch pass, or permission to merge to main.
36 changes: 36 additions & 0 deletions docs/static-runtime-notices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Static runtime redistribution review

The combined kit now redistributes `libstdc++.a`, `libgcc.a`, `libgcc_eh.a`
and `libwinpthread.a`. The legacy executable profile also copies selected
MinGW CRT compatibility objects. Treat this archive as a distribution of those
components, not just an OpenADS build output.

Packaging copies the exact installed compiler's GCC GPLv3 text and Runtime
Library Exception, MinGW runtime notices and winpthreads license into
`runtime-notices/`, and hashes them in the manifest. A missing notice stops
packaging. Keep that directory with the archive and retain applicable notices
when distributing applications built from it. Existing OpenADS LICENSE/NOTICE
files and bundled engine dependency obligations are unchanged.

GCC's documentation describes libstdc++ as GPLv3 with the GCC Runtime Library
Exception 3.1. The exception permits eligible Target Code combinations with
independent modules under their chosen terms. This is not a blanket statement
that redistribution of the runtime itself has no source obligations. Before
public distribution, preserve the exact runtime package/source versions and
check the applicable corresponding-source or source-offer route. Do not
claim that the combined archive is licensed only under OpenADS's license.
No compiler executable, profiling runtime or libquadmath is included here.

The MSYS2 winpthreads package identifies MIT and BSD-3-Clause-Clear terms.
MinGW advises retaining its runtime notices with binary packages. We copy
all those runtime notices rather than guessing which individual notices
apply. Legacy Winlibs distributions need their own exact-version copies.
This review is a packaging checklist, not legal advice or final production
redistribution clearance.

Sources inspected October 13, 2026:
- https://gcc.sourceware.org/onlinedocs/libstdc++/manual/license.html
- https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/PKGBUILD
- https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-crt/PKGBUILD
- https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-winpthreads/PKGBUILD
- https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/COPYING.MinGW-w64/COPYING.MinGW-w64.txt
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ target_link_libraries(oads_imac_test PRIVATE openads_ace)
find_package(Python3 COMPONENTS Interpreter QUIET)
if(Python3_Interpreter_FOUND)
add_test(NAME mingw_import_parser COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mingw_import_parser_test.py)
add_test(NAME static_client_packaging COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/static_client_packaging_test.py)
endif()

# The security default must be tested in new processes, not after a unit test
Expand Down
153 changes: 153 additions & 0 deletions tests/static_client_packaging_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/usr/bin/env python3
"""Host-independent packaging failure gates, with explicitly synthetic tool output."""
import hashlib
import importlib.util
import json
from pathlib import Path
import sys
import tempfile
import unittest
from unittest.mock import patch

ROOT = Path(__file__).resolve().parents[1]
spec = importlib.util.spec_from_file_location('static_packager', ROOT / 'tools/scripts/package_static_client.py')
packager = importlib.util.module_from_spec(spec)
spec.loader.exec_module(packager)


class PackagingGates(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name).resolve()
self.runtime = self.root / 'runtime'
self.link = self.runtime
for name in ('ar', 'objcopy', 'nm', 'gcc'):
path = self.runtime / 'bin' / name
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text('synthetic tool, never executed')
self.notices = ('gcc/COPYING3', 'gcc/COPYING.RUNTIME', 'crt/COPYING.MinGW-w64-runtime.txt', 'winpthreads/COPYING')
for name in self.notices:
path = self.runtime / 'share/licenses' / name
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text('SYNTHETIC TEST NOTICE ' + name)
for name in ('libstdc++.a', 'libgcc.a', 'libgcc_eh.a', 'libwinpthread.a'):
(self.runtime / name).write_bytes(b'!<arch>\nsynthetic runtime')
self.engine = self.root / 'engine.a'
self.engine.write_bytes(b'!<arch>\nsynthetic engine')
self.glue = self.root / 'glue.c'
self.glue.write_text('synthetic wrapper')
self.output = self.root / 'kit/libopenace32.a'
self.target = 'i686-w64-mingw32'
self.missing_exports = False
self.empty_exports = False
self.missing_runtime = False
self.target_mismatch = False

def fake_run(self, *args, cwd=None, text=True, input=None):
tool, *options = [str(a) for a in args]
if options == ['-dumpmachine']:
if self.target_mismatch and Path(tool).parent.parent.resolve() == self.link.resolve():
return 'x86_64-w64-mingw32\n'
return self.target + '\n'
if options == ['-dumpversion']:
return '15.2.0\n'
if options and options[0].startswith('-print-file-name='):
name = options[0].split('=', 1)[1]
if self.missing_runtime:
return str(self.root / 'absent.a') + '\n'
return str(self.runtime / name) + '\n'
if Path(tool).name == 'ar' and options == ['-M']:
candidate = Path(input.splitlines()[0].removeprefix('create '))
candidate.write_bytes(b'!<arch>\nSYNTHETIC COMBINED ARCHIVE')
return ''
if Path(tool).name == 'gcc' and '-c' in options:
Path(options[options.index('-o') + 1]).write_bytes(b'SYNTHETIC OBJECT')
return ''
if Path(tool).name == 'nm':
if options[0] == '-u':
return '' if self.empty_exports else ' U _AdsProbe\n'
return '' if self.missing_exports else '0000 T _AdsProbe\n'
if Path(tool).name == 'ar' and options[0] in ('r', 's'):
return ''
raise AssertionError(('unexpected synthetic-tool call', args))

def execute(self, profile='matching'):
argv = ['package_static_client.py', '--engine', str(self.engine),
'--runtime-root', str(self.runtime), '--link-root', str(self.link),
'--harbour-include', str(self.root), '--glue', str(self.glue),
'--ace-include', str(self.root), '--output', str(self.output),
'--profile', profile]
with patch.object(sys, 'argv', argv), patch.object(packager, 'run', self.fake_run), patch.object(packager.shutil, 'which', return_value=None), patch('builtins.print'):
packager.main()

def test_matching_profiles_record_archive_and_all_notice_hashes(self):
for target in ('i686-w64-mingw32', 'x86_64-w64-mingw32'):
self.target = target
self.execute()
manifest = json.loads(self.output.with_suffix('.manifest.json').read_text())
self.assertEqual(manifest['runtime_target'], target)
self.assertEqual(manifest['archive_sha256'], hashlib.sha256(self.output.read_bytes()).hexdigest())
self.assertEqual(manifest['engine_sha256'], hashlib.sha256(self.engine.read_bytes()).hexdigest())
self.assertEqual(len(manifest['runtime_notice_sha256']), 4)
for name, digest in manifest['runtime_notice_sha256'].items():
self.assertEqual(digest, hashlib.sha256((self.output.parent / 'runtime-notices' / name).read_bytes()).hexdigest())

def test_missing_notice_stops_packaging(self):
(self.runtime / 'share/licenses' / self.notices[0]).unlink()
with self.assertRaisesRegex(SystemExit, 'Missing exact runtime notice'):
self.execute()
self.assertFalse(self.output.exists())

def test_missing_runtime_stops_packaging(self):
self.missing_runtime = True
with self.assertRaisesRegex(SystemExit, 'Missing static runtime'):
self.execute()
self.assertFalse(self.output.exists())

def test_missing_wrapper_export_keeps_existing_archive(self):
self.output.parent.mkdir()
self.output.write_bytes(b'previous archive')
self.missing_exports = True
with self.assertRaisesRegex(SystemExit, 'Missing implementation exports'):
self.execute()
self.assertEqual(self.output.read_bytes(), b'previous archive')

def test_no_wrapper_requirements_is_not_success(self):
self.empty_exports = True
with self.assertRaisesRegex(SystemExit, 'Missing implementation exports'):
self.execute()

def test_matching_profile_rejects_different_compiler_roots(self):
self.link = self.root / 'other'
(self.link / 'bin').mkdir(parents=True)
(self.link / 'bin/gcc').write_text('synthetic tool')
with self.assertRaisesRegex(SystemExit, 'same runtime and link compiler'):
self.execute()

def test_architecture_mismatch_stops_before_output(self):
self.link = self.root / 'other'
(self.link / 'bin').mkdir(parents=True)
(self.link / 'bin/gcc').write_text('synthetic tool')
self.target_mismatch = True
with self.assertRaisesRegex(SystemExit, 'architecture mismatch'):
self.execute()
self.assertFalse(self.output.exists())

def test_windows_drive_paths_convert_for_msys_python(self):
with patch.object(packager, 'NATIVE_WINDOWS', False), patch.object(packager.shutil, 'which', return_value='cygpath'), patch.object(packager, 'run', return_value='/d/build/engine.a\n') as call:
self.assertEqual(packager.host_path('D:/build/engine.a').as_posix(), '/d/build/engine.a')
call.assert_called_once_with('cygpath', '-u', 'D:/build/engine.a')

def test_mri_stdin_paths_convert_to_native_drive_paths(self):
with patch.object(packager.shutil, 'which', return_value='cygpath'), patch.object(packager, 'run', return_value='D:/build/kit.a\n') as call:
self.assertEqual(packager.mri_path('/d/build/kit.a'), 'D:/build/kit.a')
call.assert_called_once_with('cygpath', '-m', '/d/build/kit.a')

def test_legacy_profile_rejects_unpinned_compiler(self):
with self.assertRaisesRegex(SystemExit, 'requires pinned'):
self.execute('qt492-x86')


if __name__ == '__main__':
unittest.main(verbosity=2)
Loading
Loading