Repository navigation
Move custom object key tests out of unit-cbor.cpp and unit-msgpack.cpp - #5798
Merged
Merged
Conversation
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
clang (NN.x)jobs of the Windows workflow, which fail ondevelopsince #5328: linkingtest-msgpack_cpp11.exestops with many(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_jsonspecialization (custom_object_key_test::json) inunit-cbor.cppandunit-msgpack.cpp. That pushedunit-msgpack.cpp.objpast 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_associatedin binutils'include/coff/internal.hisuint16_t, even thoughcoff_bigobj_swap_aux_inreads the 32-bit value. Jump tables of inline functions live in.rdatasections 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.textreferences to them overflow. The failing symbols are those of the defaultjson, not the custom one, which fits this.-Wa,-mbig-objis already set for MinGW, and a different code model would not help, because the target section is gone and not out of range.Change
tests/src/unit-custom-object-key-type.cpp.unit-cbor.cppandunit-msgpack.cppno longer includecustom_object_key_type.hpp.windows.ymlnow 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
mingwjobs sometimes fail inegor-tensin/setup-mingwwhen 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