Remove macOS SDK dependency from libvec native build#145066
Merged
ldematte merged 2 commits intoelastic:mainfrom Mar 27, 2026
Merged
Remove macOS SDK dependency from libvec native build#145066ldematte merged 2 commits intoelastic:mainfrom
ldematte merged 2 commits intoelastic:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
ChrisHegarty
approved these changes
Mar 27, 2026
Contributor
ChrisHegarty
left a comment
There was a problem hiding this comment.
Thanks for doing this. Looks great.
mamazzol
pushed a commit
to mamazzol/elasticsearch
that referenced
this pull request
Mar 30, 2026
Introduce minimal C++ standard library headers (tinystd/) for Darwin cross-compilation, eliminating the dependency on the macOS SDK's libc++ headers Replace explicit libc function calls with compiler builtins: fmax() → __builtin_fmaxf(), sqrt() → __builtin_sqrt() Remove unused #include <math.h>, <assert.h>, <stdio.h>, <TargetConditionals.h> from all source files Update build.gradle to use -nostdinc + tinystd for Darwin/clang builds
mromaios
pushed a commit
to mromaios/elasticsearch
that referenced
this pull request
Apr 9, 2026
…elastic#144845) This PR adds a Docker-based cross-compilation pipeline for building libvec for all three platforms from a single Linux/amd64 container, replacing the previous Mac-dependent workflow. It builds on top of elastic#145066 (merged), which introduced the tinystd headers and builtin replacements.
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
tinystd/) for Darwin cross-compilation, eliminating the dependency on the macOS SDK's libc++ headersfmax()→__builtin_fmaxf(),sqrt()→__builtin_sqrt()#include <math.h>,<assert.h>,<stdio.h>,<TargetConditionals.h>from all source filesbuild.gradleto use-nostdinc+ tinystd for Darwin/clang buildsWhy?
The Darwin build currently depends on the macOS SDK for C/C++ standard library headers. This is a problem for the cross-compilation Docker pipeline (#144845), where including the proprietary SDK in a public image has licensing concerns. By providing our own minimal headers for the C++ stdlib features we actually use, we can compile for Darwin without any SDK.
The tinystd headers compile to identical machine code as the real standard library (verified with
objdump --disassemble). Linux builds are unaffected — they continue to use the real libstdc++.Source code improvements
fmax()→__builtin_fmaxf()— fixes a subtle bug where thedoublevariant caused unnecessaryfcvtfloat↔double conversions on ARMsqrt()→__builtin_sqrt()— explicit builtin, doesn't rely on optimizer to inline<cstdint>→<stdint.h>invec.h— freestanding header, no C++ wrapper neededassert()calls and<assert.h>fromvec_common.hTest plan
./gradlew vecAarch64SharedLibrarybuilds on macOS with tinystd (no SDK headers)JDKVectorLibrary*tests pass on macOS with the locally built librarynative/docker-cross-compilebranch: all 3 platforms (darwin-aarch64, linux-aarch64, linux-x64) build and pass testsobjdumpPrerequisite for #144845 (cross-compilation pipeline).