Fix macOS paclet build; make multi-platform build automatic and host-aware#2
Open
sashakolpakov wants to merge 1 commit into
Conversation
…aware
The macOS (Darwin) build of libHypergraphRewriting failed to link:
Undefined symbols for architecture arm64:
"_WSNewPacket", "_WSNextPacket", "_WSPutFunction", "_WSPutString"
referenced from hypergraph_ffi.cpp.o
Root cause: in paclet_source/CMakeLists.txt the WSTP block has three
platform branches. Windows and Linux each link the WSTP library
(wstp64i4.lib / libWSTP64i4.so), but the Darwin branch only defined
HAVE_WSTP=1 and added the include dir -- it never linked libWSTPi4.a.
So hypergraph_ffi.cpp compiled with the WSTP code path enabled but the
symbols were never resolved.
Changes:
* paclet_source/CMakeLists.txt
- Darwin branch now links libWSTPi4.a (it needs -framework Foundation,
already added in the Darwin linker block).
- WSTP platform selection and PLATFORM_DIR now honour
CMAKE_OSX_ARCHITECTURES, so a native x86_64 build on Apple silicon
links the x86_64 WSTP slice and lands in MacOSX-x86-64/.
* cmake/FindMathematica.cmake
- Add /Applications/Wolfram.app/Contents (Wolfram 14+ install name) and
its ~/Applications equivalent to the macOS search paths, so the kernel
is found without setting MATHEMATICA_HOME.
* build_all_platforms.sh -- rewritten around a declarative target schema.
- Each target declares its toolchain probe, auto-install command, and
configure line. Missing-but-installable toolchains are installed
automatically (--no-install to opt out).
- Targets the host architecture cannot build (e.g. Windows-ARM64, which
needs the Windows SDK) are SKIPPED with a reason instead of aborting
the whole run. The run only fails on a build that was actually
attempted. Previously the Windows-ARM64 configure error killed the
entire script via `set -e` + `|| exit 1`.
- macOS host now builds both macOS slices natively (Apple clang) and the
Linux/Windows targets via the brew cross-toolchains -- no OSXCross
required for the native arches.
- Assembles the .paclet archive at the end when all attempted builds
succeed.
* README.md -- corrected the build/cross-compilation docs (was Linux-only,
referenced clang-22); documented where artifacts land (the
paclet_archive/*.paclet) and the host-aware skipping behaviour.
* .gitignore -- ignore the generated paclet_archive/.
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Fixes #1.
The bug
On macOS, linking
libHypergraphRewriting.dylibfailed with undefined WSTPsymbols (
_WSNewPacket,_WSNextPacket,_WSPutFunction,_WSPutString).The Darwin branch of the WSTP block in
paclet_source/CMakeLists.txtsetHAVE_WSTP=1and added the include dir but — unlike the Windows and Linuxbranches — never linked the WSTP library. See #1 for the full analysis.
Changes
paclet_source/CMakeLists.txtlibWSTPi4.a(needs-framework Foundation, alreadypresent in the Darwin linker block). This is the actual fix for the linker error.
PLATFORM_DIRnow honourCMAKE_OSX_ARCHITECTURES,so a native
-arch x86_64build on Apple silicon links the x86_64 WSTP sliceand is emitted into
MacOSX-x86-64/.cmake/FindMathematica.cmake/Applications/Wolfram.app/Contents(Wolfram 14+ install name) and the~/Applicationsvariant to the macOS search paths — no more manualMATHEMATICA_HOMEjust to be found.build_all_platforms.sh— rewritten around a declarative target schemaline. Missing-but-installable toolchains are installed automatically
(
--no-installto opt out).are skipped with a reason, not fatal. The run only fails on a build that was
actually attempted. Previously the Windows-ARM64 configure error aborted the
whole script.
Linux/Windows targets build via the Homebrew cross-toolchains — OSXCross is no
longer required for the native arches.
.pacletarchive at the end when all attempted builds succeed.README.md— corrected build/cross-compilation docs (were Linux-only andreferenced
clang-22); documented artifact locations and the host-aware skipping..gitignore— ignore the generatedpaclet_archive/.Verification (macOS, Apple silicon, Wolfram 14)
./build_all_platforms.shbuilds MacOSX-ARM64, MacOSX-x86-64, Linux-x86-64,Linux-ARM64, Windows-x86-64, skips Windows-ARM64 with a clear message, and
produces
paclet_archive/WolframInstitute__HypergraphRewriteEngine-0.0.1.paclet.nm -uon the macOS dylib shows no undefinedWS*symbols. The x86_64 dylibreports
x86_64vialipo -archs.🤖 Generated with Claude Code