Skip to content

Added freestanding mode - #74

Open
danieltowner wants to merge 2 commits into
freestanding_bounds_checkfrom
freestanding_mode
Open

danieltowner wants to merge 2 commits into
freestanding_bounds_checkfrom
freestanding_mode

Conversation

@danieltowner

Copy link
Copy Markdown
Contributor

Allows the library to be used without any runtime support libraries. The main restriction is no maths/complex/iostream support. Note that complex-like behaviour can be restored using custom complex vlaues and defining a suitable complex_trait specialisation.

@danieltowner
danieltowner added this pull request to stack #64 November 20, 2026 17:36
@danieltowner
danieltowner removed this pull request from stack #64 November 20, 2026 17:40
@danieltowner
danieltowner changed the base branch from complex_like to freestanding_bounds_check November 20, 2026 17:40
@danieltowner
danieltowner added this pull request to stack #75 November 20, 2026 17:40
Comment thread test/freestanding/include.cpp Resolved
@omalyshe
omalyshe requested review from omalyshe and a balanced review from Copilot November 20, 2026 22:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical freestanding header parsing and baseline x86-64 probe failures remain, alongside a test-only intrinsic-header workaround and missing verification that exercised operations require no runtime support.

4 open issues
What changed in this PR

Introduces freestanding support for xvec’s SIMD API by separating runtime-dependent features from core vector operations.

Changes:

  • Gates stream output, standard complex integration, and runtime-backed math behind __STDC_HOSTED__.
  • Preserves custom complex-type support through complex_traits.
  • Adds a freestanding compilation probe and documents the new mode.
File Description
test/​freestanding/​include.cpp Adds compilation probes for vector operations and custom complex types.
test/​CMakeLists.txt Registers the freestanding object-build test.
include/​xvec/​x86/​x86_impl.hpp Removes the direct <complex> include.
include/​xvec/​simd Gates <ostream> and removes the direct <complex> include.
include/​xvec/​generic/​generic_impl.hpp Gates <cmath> and generic math implementations.
include/​xvec/​detail/​utilities.hpp Gates standard complex support while retaining custom traits.
include/​xvec/​detail/​std_rebind.hpp Removes the direct <complex> include.
include/​xvec/​detail/​std_math.hpp Gates transcendental functions and their exports.
include/​xvec/​detail/​std_complex.hpp Removes the direct <complex> include.
include/​xvec/​detail/​mask.hpp Gates stream dependencies and mask output.
CHANGELOG.md Documents freestanding mode and custom complex support.

Review effort: Balanced

return _Vp([=](auto i) { return typename _Vp::value_type(doOp(v[i])); });
}

#endif // __STDC_HOSTED__
Comment thread test/CMakeLists.txt

add_library(FreestandingInclude OBJECT EXCLUDE_FROM_ALL freestanding/include.cpp)
target_include_directories(FreestandingInclude PRIVATE "${XVEC_ROOT_DIR}/include")
target_compile_options(FreestandingInclude PRIVATE -ffreestanding)
Comment thread test/CMakeLists.txt

enable_testing()

add_library(FreestandingInclude OBJECT EXCLUDE_FROM_ALL freestanding/include.cpp)
@@ -0,0 +1,34 @@
// Checks that <xvec/simd> compiles and basic operations instantiate with -ffreestanding.
#if defined(__GNUC__) && !defined(__clang__)
#define _MM_MALLOC_H_INCLUDED // GCC's mm_malloc.h needs hosted malloc/free.
@danieltowner
danieltowner force-pushed the freestanding_mode branch 2 times, most recently from b39f359 to c2c7082 Compare November 21, 2026 17:34
Allows the library to be used without any runtime support libraries. The main restriction is no maths/complex/iostream support. Note that complex-like behaviour can be restored using custom complex vlaues and defining a suitable `complex_trait` specialisation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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