Skip to content

Fix windows build - #2654

Merged
michalvasko merged 3 commits into
CESNET:develfrom
jktjkt:fix-windows-build
Nov 27, 2026
Merged

michalvasko merged 3 commits into
CESNET:develfrom
jktjkt:fix-windows-build

Conversation

@jktjkt

@jktjkt jktjkt commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

xml/json BUGFIX copy value characters from the input

Once a value needed a dynamic buffer, e.g. because of an entity reference or an escape sequence, every following character was appended by copying bytes from the address of its decoded code point. The code point, however, holds the Unicode integer value, not raw bytes in the UTF-8 encoding.

This happened to work (for ASCII) on LE systems. On BE, the first byte of that integer is always zero, so the value got cut off at the next character. Any characters > 0x7f were mangled.

Copy the bytes from the input instead. The tests need a non-ASCII character after the reference or the escape.

cmake BUGFIX build yangupdate from an OBJECT library

The yang_update library needs the internal symbols that libyang does not export, so it links the library's objects directly. But $<TARGET_OBJECTS:> is meant for OBJECT libraries only. New CMake versions are lenient about that, the 3.10 in the i386/ubuntu container of the 32-bit CI job is not and fails the configuration with "Objects of target "yang" referenced but is not an OBJECT library". The job has been red since yangobj was removed in 8ed0dbd.

Build libyang from a separate OBJECT library again and take the objects from there. This is done for the static library as well, so that the objects are available regardless of BUILD_SHARED_LIBS.

tests BUGFIX Windows load yang.dll next to the tests

The tests link the shared yang library, but Windows has no rpath. It finds a DLL only next to the executable or on PATH, and neither covers where yang.dll is built. The tests are built into tests// while yang.dll ends up in /, so all of the tests died on startup with STATUS_DLL_NOT_FOUND (0xc0000135), after the build itself had already been fixed. The DLLs of the dependencies were not a problem as vcpkg copies those by itself.

tests BUGFIX skip only the POSIX regex part of tpdf_reuse on Windows

This entire test was being skipped on Windows. The only problematic part is actually the OpenConfig module because of its POSIX regular expression. This test was introduced by a fix for #2581, and the thing that's tested does not actually depend on the OpenConfig regex dialect.

Let's not skip this entire test, and let's use an appropriate #ifdef for this.

@michalvasko michalvasko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the commit cmake BUGFIX build yangupdate from an OBJECT library, if the issue is only an old version of cmake, then please remove it. We were trying to get rid of multiple main targets and be left with only yang. There is another prepared PR that increases the required cmake version to 3.12.0. But many thanks for the other fixes!

@jktjkt

jktjkt commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Yes, updating the minimal CMake version should work, too, but I think that the minimal version in which this is fixed is very likely at least 3.15. In 3.21 they fixed a dependency ordering problem related to object libraries, so you want 3.21+.

@michalvasko

Copy link
Copy Markdown
Member

Thanks for the information, we will check what cmake version exactly works and adjust it accordingly. In the meantime, please drop that specific commit so the other fixes can be merged.

@Roytak

Roytak commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

You're completely right, looks like CMake accepts it since 3.15, but it only works reliably since 3.21. In #2651 I kept the yangobj OBJECT library and pass $<TARGET_OBJECTS:yangobj> to add_library() as sources, which works on any version. I raised the minimum to 3.12, the lowest version that works for the whole family, because sysrepo and netopeer2 link OBJECT libraries through target_link_libraries(), which needs 3.12, and libyang builds fine with it (from my testing on many different platforms)

jktjkt and others added 3 commits November 27, 2026 15:57
Once a value needed a dynamic buffer, e.g. because of an entity reference
or an escape sequence, every following character was appended by copying
bytes from the address of its decoded code point. The code point,
however, holds the Unicode integer value, not raw bytes in the UTF-8
encoding.

This happened to work (for ASCII) on LE systems. On BE, the first byte
of that integer is always zero, so the value got cut off at the next
character. Any characters > 0x7f were mangled.

Copy the bytes from the input instead. The tests need a non-ASCII
character after the reference or the escape.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The tests link the shared yang library, but Windows has no rpath. It
finds a DLL only next to the executable or on PATH, and neither covers
where yang.dll is built. The tests are built into tests/<config>/
while yang.dll ends up in <config>/, so all of the tests died on
startup with STATUS_DLL_NOT_FOUND (0xc0000135), after the build itself
had already been fixed. The DLLs of the dependencies were not a problem
as vcpkg copies those by itself.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This entire test was being skipped on Windows. The only problematic part
is actually the OpenConfig module because of its POSIX regular
expression. This test was introduced by a fix for CESNET#2581, and the thing
that's tested does not actually depend on the OpenConfig regex dialect.

Let's not skip this entire test, and let's use an appropriate #ifdef for
this.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jktjkt

jktjkt commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the information, we will check what cmake version exactly works and adjust it accordingly. In the meantime, please drop that specific commit so the other fixes can be merged.

Done. I would be perfectly OK with you cherry-picking these commits as you see fit, btw.

@michalvasko
michalvasko merged commit 852806f into CESNET:devel Nov 27, 2026
14 of 15 checks passed
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.

3 participants