Skip to content

Use trailing-zero builtin with older libc++ - #243

Open
cristim wants to merge 1 commit into
OpenSwiftUIProject:mainfrom
cristim:fix/older-libcxx-count-trailing
Open

cristim wants to merge 1 commit into
OpenSwiftUIProject:mainfrom
cristim:fix/older-libcxx-count-trailing

Conversation

@cristim

@cristim cristim commented Sep 23, 2026

Copy link
Copy Markdown

Summary

Use Clang's trailing-zero builtin when scanning a nonempty free-page map. This preserves the std::countr_zero result for the nonzero unsigned long long returned by to_ullong() and builds with older libc++ headers that lack the C++20 bit operation.

Why

The target-aware arm64 macOS OpenSwiftUI dependency build compiles OpenAttributeGraph against Darling's current libc++ and failed in table.cpp because std::countr_zero was unavailable.

Validation

  • Rebuilt the OpenSwiftUI target with local OpenAttributeGraph sources and Darling's libc++ headers. table.cpp now compiles and the build advances through the C++ sources to Swift errors in Graph.swift (NSDictionary bridging and optional string handling).
  • The loop calls the builtin only while free_pages_map.any() is true, so its zero input case is unreachable.

Contributing

Reproduce with a C++20 compile of table.cpp against the older libc++ in Darling and the local Swift runtime headers selected through OpenAttributeGraph PR #242. AI-assisted changes should check the nonzero precondition and verify allocation scans still choose the least significant free bit.

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.

1 participant