Skip to content
Closed
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
33 changes: 33 additions & 0 deletions .github/workflows/probe-windows-archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Temporary probe (closed after it answers): (1) does MSVC's link.exe keep a
# locally defined function reached only through an __imp_ slot under /OPT:REF,
# where lld-link collects it; (2) do compat.xz and compat.libarchive stating their static-API macros for
# their consumers (a default-implied feature) end the archive members' crash.
name: probe-windows-archive
on:
pull_request:
paths: ['.github/workflows/probe-windows-archive.yml']
jobs:
archive:
runs-on: windows-2022
timeout-minutes: 60
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: mcpp 2026.11.21.1
run: |
set -euo pipefail
curl -fsSL --retry 5 -o m.zip "https://github.com/mcpp-community/mcpp/releases/download/v2026.11.21.1/mcpp-2026.11.21.1-windows-x86_64.zip"
unzip -q m.zip
echo "$PWD/mcpp-2026.11.21.1-windows-x86_64/bin" >> "$GITHUB_PATH"
echo "MCPP_HOME=$HOME/.mcpp-probe" >> "$GITHUB_ENV"
- name: the archive members with LZMA_API_STATIC and LIBARCHIVE_STATIC
run: |
set +e
for p in archive-tests libarchive-bundle; do
echo "== $p"
mcpp test -p "$p" --toolchain llvm@23.1.3 2>&1 | tail -25
echo "RESULT $p exit=${PIPESTATUS[0]}"
done
exit 0
14 changes: 13 additions & 1 deletion pkgs/c/compat.libarchive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,21 @@ package = {
include_dirs = {"*", "*/libarchive", "mcpp_generated/include"},
cflags = {
"-D_GNU_SOURCE",
"-DLIBARCHIVE_STATIC",
"-DPLATFORM_CONFIG_H=\\\"mcpp_libarchive_config.h\\\"",
},
-- archive.h and archive_entry.h declare every function
-- __declspec(dllimport) on Windows unless LIBARCHIVE_STATIC is defined,
-- and this package is a static library. Every TU that includes them
-- needs it, this package's and its consumers': a consumer without it
-- calls through `__imp_archive_*` slots that lld-link makes, and a link
-- that collects unreferenced sections drops the functions behind them
-- (the first call jumps to the image's first byte; compat.xz states the
-- measurement). A feature's `defines` reach the consumer, and `default`
-- implies it unconditionally, as CURL_STATICLIB in compat.curl.
features = {
["default"] = { implies = { "staticlib" } },
["staticlib"] = { defines = { "LIBARCHIVE_STATIC" } },
},
-- macOS with musl as the C library (an openkal graph). libarchive
-- reads __APPLE__ as "the Apple SDK is present" (TargetConditionals.h,
-- copyfile, quarantine) in four private translation units and in the
Expand Down
16 changes: 16 additions & 0 deletions pkgs/c/compat.xz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ package = {
"*/src/liblzma/simple",
"*/src/common",
},

-- <lzma.h> declares every function __declspec(dllimport) on Windows
-- unless LZMA_API_STATIC is defined, and this package is a static
-- library. A consumer that includes it without the macro calls through
-- `__imp_lzma_*` slots that lld-link makes for the locally defined
-- functions; a link that collects unreferenced sections (the release
-- profile, a test's link) drops the functions behind the slots, and
-- the first call jumps to the image's first byte. The macro reaches
-- every TU that includes the header the same way CURL_STATICLIB does
-- in compat.curl: a feature's `defines` reach the consumer, and
-- `default` implies it unconditionally.
features = {
["default"] = { implies = { "staticlib" } },
["staticlib"] = { defines = { "LZMA_API_STATIC" } },
},

cflags = {
"-D_GNU_SOURCE",
"-DSIZEOF_SIZE_T=8",
Expand Down
Loading