Skip to content

5.8.3.1: the module reads lzma.h as the static library it links (LZMA_API_STATIC) - #2

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/5.8.3.1-static-api
Nov 12, 2026
Merged

Sunrisepeak merged 1 commit into
mainfrom
fix/5.8.3.1-static-api

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

compat.xz is a static library. On Windows lzma.h declares every function imported from a DLL unless LZMA_API_STATIC is defined, and the module's units read it without: a program that imports the module calls through __imp_lzma_*. No DLL provides those, so lld-link makes a slot of its own for each, and it does not count such a slot as a reference. In a link that collects unreferenced sections (-ffunction-sections, the release profile) the functions are dropped and each slot holds the image's first byte.

Found in mcpp: mcpp pack --compress xz:<level> and its unit test faulted on Windows (EXCEPTION_ACCESS_VIOLATION at the image base) once its dependency objects were rebuilt; the link's map names the five slots, __imp_lzma_end, __imp_lzma_code, __imp_lzma_easy_buffer_encode, __imp_lzma_stream_decoder, __imp_lzma_stream_buffer_bound.

  • tools/surface.toml states defines = ["LZMA_API_STATIC"]; the generator writes it before lzma.h in both module units, in tests/macros.cpp and in <mwrap/xz/macros.hpp>, which a unit that includes lzma.h itself includes first.
  • tests/linked.cpp reads that the functions are not at one address: slots whose functions were dropped all hold the same one, which is not null.
  • CI runs the tests in the release profile as well as the dev profile. 5.8.3 passed the dev profile on Windows.
  • docs/usage.md: what a unit that includes lzma.h beside the module states.

The version is a wrapper revision of upstream 5.8.3 (mcpp-index docs/mwrap.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant