Skip to content

Make libhecdss self-contained: static zlib + static MSVC runtime#361

Merged
nghiemv merged 2 commits into
mainfrom
fix/static-zlib-and-self-contained-check
Jun 17, 2026
Merged

Make libhecdss self-contained: static zlib + static MSVC runtime#361
nghiemv merged 2 commits into
mainfrom
fix/static-zlib-and-self-contained-check

Conversation

@nghiemv

@nghiemv nghiemv commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The published natives aren't self-contained:

Platform Non-OS dependency Result
macOS @rpath/libz.1.dylib, rpath = build-box path only fails to load anywhere but the build runner
Linux libz.so.1 works only because the system ships zlib
Windows VCRUNTIME140.dll (VC++ redistributable) works only where the redistributable is installed

The macOS case is an outright bug: the shipped darwin-* dylib records @rpath/libz.1.dylib with the only LC_RPATH pointing at the build runner's path, which exists nowhere else, so dyld can't resolve zlib and the load fails. CI never caught it because ctest ran in the same build tree where that rpath still resolves.

Root cause: deps/zlib/CMakeLists.txt aliased the static-named ZLIB::ZLIBSTATIC to madler/zlib's shared zlib target (the static one is zlibstatic). heclib_c links that alias on every non-MSVC platform, so Linux/macOS linked shared zlib.

Changes

  1. Static zlib on all platforms — repoint ZLIB::ZLIBSTATIC at zlibstatic (with its includes) and mark it position-independent so the archive links into the shared libhecdss on Linux/ELF.
  2. Static MSVC runtimeCMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded, so the Windows DLL no longer needs VCRUNTIME140.dll.
  3. Regression guard — a self_contained ctest runs CMake's built-in file(GET_RUNTIME_DEPENDENCIES) on the built native and fails if it links anything outside the OS baseline. It needs only the built lib, so testing is now enabled unconditionally (no DSS test-data required).

Scope

This is the bug fix + its regression test, split out for a fast review. The CI/Release/packaging rework and the consumer/JNI API tests follow in a stacked PR (ci/release-build-package-and-api-tests).

The published natives weren't self-contained. On macOS the shipped dylib
recorded @rpath/libz.1.dylib with the only LC_RPATH pointing at the build
runner's path, so dyld couldn't resolve zlib off the build box -- an outright
load failure. On Linux/macOS heclib_c linked *shared* zlib because
deps/zlib/CMakeLists.txt aliased the static-named ZLIB::ZLIBSTATIC to
madler/zlib's shared `zlib` target (the static one is `zlibstatic`). On
Windows the DLL needed VCRUNTIME140.dll from the VC++ redistributable.

Fixes:
- Repoint ZLIB::ZLIBSTATIC at the real static `zlibstatic` target (PIC, with
  its includes) so the archive links into the shared libhecdss everywhere.
- CMAKE_MSVC_RUNTIME_LIBRARY = MultiThreaded so the Windows DLL no longer
  depends on VCRUNTIME140.dll.

Guards against regression: a `self_contained` ctest runs CMake's built-in
file(GET_RUNTIME_DEPENDENCIES) on the built native and fails if it links
anything outside the OS baseline. It needs only the built lib, so testing is
now enabled unconditionally (no DSS test-data required).
@nghiemv nghiemv force-pushed the fix/static-zlib-and-self-contained-check branch from 3e5f8aa to 30ece21 Compare June 16, 2026 21:55
@nghiemv nghiemv requested a review from ktarbet June 16, 2026 21:58

@ktarbet ktarbet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider updating the Readme.md "Windows Dependencies" section.

It documented heclib.dll with Intel Fortran runtime DLLs (libifcore*, etc.)
and debug-variant CRT -- but nothing in this tree builds heclib.dll, and the
CMake project is C-only (no Fortran). The natives this repo actually ships are
hecdss.dll and javaHeclib.dll, and after this change both are self-contained:
static zlib + static MSVC runtime, so no VC++ redistributable and no Fortran
runtime. Replace the stale list with the accurate one.
@nghiemv nghiemv force-pushed the fix/static-zlib-and-self-contained-check branch from 4a5ef75 to 97c2241 Compare June 16, 2026 23:01
@sonarqubecloud

Copy link
Copy Markdown

@nghiemv

nghiemv commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ktarbet 😁 👋 Updated the README

@nghiemv nghiemv merged commit 2adff5d into main Jun 17, 2026
5 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.

2 participants