Skip to content

Move custom object key tests out of unit-cbor.cpp and unit-msgpack.cpp - #5798

Merged
nlohmann merged 1 commit into
developfrom
fix/mingw-clang-msgpack-link
Oct 9, 2026
Merged

nlohmann merged 1 commit into
developfrom
fix/mingw-clang-msgpack-link

Conversation

@nlohmann

@nlohmann nlohmann commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Fixes the clang (NN.x) jobs of the Windows workflow, which fail on develop since #5328: linking test-msgpack_cpp11.exe stops with many

unit-msgpack.cpp:(.text$...write_msgpack...): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.rdata'

(develop run 37923290733 at 69a0c1b, clang 19.1.7; run 37955575145, clang 20.1.8; PR #5797's run 37977184430, clang 18.1.8). The last green run on develop was at d33068d, the commit before #5328.

Cause

#5328 added CBOR and MessagePack tests that instantiate a second basic_json specialization (custom_object_key_test::json) in unit-cbor.cpp and unit-msgpack.cpp. That pushed unit-msgpack.cpp.obj past 65535 sections. Clang then writes a big object file, which is fine, but the GNU linker keeps the section an associative COMDAT section belongs to in 16 bits: x_associated in binutils' include/coff/internal.h is uint16_t, even though coff_bigobj_swap_aux_in reads the 32-bit value. Jump tables of inline functions live in .rdata sections associated with their function. In larger objects the linker ties them to the wrong function, discards them together with that function's duplicate, and the .text references to them overflow. The failing symbols are those of the default json, not the custom one, which fits this.

-Wa,-mbig-obj is already set for MinGW, and a different code model would not help, because the target section is gone and not out of range.

Change

  • The four tests move unchanged into the new tests/src/unit-custom-object-key-type.cpp. unit-cbor.cpp and unit-msgpack.cpp no longer include custom_object_key_type.hpp.
  • The comment in windows.yml now explains the limit, next to the existing advice to split test files.

#5795 adds a file with the same name that already covers these tests (as TEST_CASE_TEMPLATE), so when it is rebased, keep its version of the file.

Infrastructure note, not addressed here: the mingw jobs sometimes fail in egor-tensin/setup-mingw when the winlibs download returns HTTP 404/500 ("Where was MinGW installed? Not sure").

Public API

No breaking changes. Only tests and CI comments change.

🤖 Generated with Claude Code

The custom object key tests from #5328 instantiate a second basic_json
specialization in unit-cbor.cpp and unit-msgpack.cpp. This pushed
unit-msgpack.cpp.obj past 65535 sections in the clang (MinGW) jobs of
the Windows workflow, and linking test-msgpack_cpp11 fails with
"relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.rdata'".

The GNU linker keeps the section an associative COMDAT section belongs
to in 16 bits (x_associated in include/coff/internal.h), although big
object files store 32 bits. In larger objects it therefore ties the
jump tables of inline functions to the wrong function and discards them
together with that function's duplicate.

Move the four tests unchanged into unit-custom-object-key-type.cpp and
document the limit in windows.yml.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@nlohmann nlohmann added this to the Release 3.13.0 milestone Oct 9, 2026
@nlohmann
nlohmann merged commit 74aefc3 into develop Oct 9, 2026
107 of 168 checks passed
@nlohmann
nlohmann deleted the fix/mingw-clang-msgpack-link branch October 9, 2026 22:05
@github-actions github-actions Bot added aspect: binary formats BSON, CBOR, MessagePack, UBJSON L CI tests labels Oct 9, 2026
nlohmann added a commit that referenced this pull request Oct 9, 2026
develop (#5798) added tests/src/unit-custom-object-key-type.cpp with the
custom object key tests moved out of unit-cbor.cpp and unit-msgpack.cpp.
This branch added a file of the same name; keep develop's file and move
this branch's tests:

- the key types, helpers, and test bodies go to custom_key_test.hpp;
- unit-custom-key-type-{full,no-eq,explicit,to-json,c-str}.cpp run the
  tests for one object type each, as one file with all five
  specializations failed to link with MinGW ("relocation truncated to
  fit", more than 65535 sections, see .github/workflows/windows.yml);
- the at() test expects the "(bytes 0-7)" prefix with
  JSON_DIAGNOSTIC_POSITIONS.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aspect: binary formats BSON, CBOR, MessagePack, UBJSON CI L tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant