Add static and shared linkage test (closes #153)#413
Merged
Conversation
cbor_encode_half previously encoded all NaN values as 0x7E00, losing the sign bit and up to 10 payload bits. Negative tiny floats (too small for half precision) were also rounded to +0 instead of -0. - cbor_encode_half: map the top 10 bits of the single-precision mantissa to the half-precision mantissa, preserving both the quiet/signaling bit and the payload. Fall back to a quiet NaN only when the payload fits entirely in the bottom 13 bits (not representable in half precision). Preserve the sign bit in the tiny-float-to-zero rounding path. - _cbor_decode_half: reconstruct the single-precision float bit pattern from the half-precision NaN bits, enabling round-trip fidelity. Fixes #215 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MIPS legacy uses bit 22 = 0 for quiet NaN (opposite of IEEE 754-2008),
so the C NAN constant has a different bit pattern there. Tests that
asserted cbor_encode_half(NAN) == {0xF9, 0x7E, 0x00} were relying on
the old behavior of normalizing all NaN values to 0x7E00.
Replace specific-byte assertions on NAN, -NAN, and nanf("2") with
structural checks (valid CBOR half marker, exp=0x1F, non-zero mantissa)
plus the existing encode/decode round-trip. Keep a deterministic
specific-byte assertion for an explicit bit pattern (0x7FC02000)
constructed via memcpy, which is independent of the platform's NAN.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds test/linkage/, a standalone CMake consumer project that builds against an installed libcbor via find_package, for both static (BUILD_SHARED_LIBS=OFF) and shared (BUILD_SHARED_LIBS=ON) builds. This catches the class of bug fixed in #148, where static and shared library artifacts had colliding names on Windows, breaking installs. Adds a run-linkage-tests CircleCI command that installs libcbor to a temp prefix and builds/runs the consumer for both variants. The command runs in build-and-test, build-and-test-clang, and a new dedicated linkage-test CI job. Closes #153 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Release builds enable LTO (INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON), which makes clang emit LLVM bitcode into libcbor.a. GNU ld cannot read that format when linking the consumer, causing the static linkage test to fail on the build-and-test-clang job. Switching to Debug avoids LTO entirely while still exercising the install and find_package paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #413 +/- ##
=======================================
Coverage 99.94% 99.94%
=======================================
Files 20 20
Lines 1747 1747
=======================================
Hits 1746 1746
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The linkage tests already run as part of build-and-test and build-and-test-clang; the dedicated job is redundant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
test/linkage/, a standalone CMake consumer project that usesfind_package(libcbor)to link against an installed libcbor — the minimal reproduction of how a downstream user would consume the libraryrun-linkage-testsCircleCI command that builds and installs libcbor twice (once withBUILD_SHARED_LIBS=OFF, once withBUILD_SHARED_LIBS=ON) and runs the consumer against each installrun-linkage-testsintobuild-and-test(GCC) andbuild-and-test-clang(Clang), and adds a new dedicatedlinkage-testCI jobThis catches the class of regression fixed in #148, where the static and shared library artifacts had colliding output names, breaking installs especially on Windows.
Test plan
linkage-testjob and the linkage steps at the end ofbuild-and-testandbuild-and-test-clangCloses #153
🤖 Generated with Claude Code