Skip to content

Exclude non-BoringSSL items from bindings - #520

Open
kornelski wants to merge 3 commits into
masterfrom
stdlib-dupes
Open

kornelski wants to merge 3 commits into
masterfrom
stdlib-dupes

Conversation

@kornelski

Copy link
Copy Markdown
Collaborator

Rust started warning about incompatible redefinitions of malloc.

Boring headers pull in C stdlib, and bindgen isn't very good at filtering out its unused/irrelevant symbols.

This change excludes about 3000 lines of boilerplate from the bindings. I couldn't simply exclude __.*, because macOS uses a pattern of time_t = __darwin_time_t, and bindgen would naively leave it broken instead of following the aliases.

@kornelski
kornelski force-pushed the stdlib-dupes branch 3 times, most recently from b0277e2 to 03672fc Compare August 14, 2026 16:35
Comment thread boring-sys/build/main.rs
.merge_extern_blocks(true)
.prepend_enum_name(true)
.allowlist_item("[A-Z].*|.*_.*|tm.*|time.*") // Exclude unprefixed stdlib and POSIX functions
.blocklist_item("rusage.*|RLIMIT.*|USE_CLANG.*|__?v?snprintf.*|.*DEPRECATED.*|sig[a-z0-9]*_t|__sig.*|_?sigaction.*|__darwin_(arm_|[um]context).*|[um]context_t|__arm_.*|__AVAIL.*|MAC_OS_(X_)?VER.*")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some more failures on Android due to signal-related symbols, https://github.com/cloudflare/boring/actions/runs/31857179845/job/94944070421?pr=520

error[E0425]: cannot find type `__sighandler_t` in this scope
    --> /home/runner/work/boring/boring/.cache/build-dir/x86_64-linux-android/debug/build/boring-sys-95dbbaded2f700d3/out/bindings.rs:6719:21
     |
6719 |     pub sa_handler: __sighandler_t,
     |                     ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find type `__sigrestore_t` in this scope
    --> /home/runner/work/boring/boring/.cache/build-dir/x86_64-linux-android/debug/build/boring-sys-95dbbaded2f700d3/out/bindings.rs:6721:22
     |
6721 |     pub sa_restorer: __sigrestore_t,
     |                      ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find type `sigset_t` in this scope
    --> /home/runner/work/boring/boring/.cache/build-dir/x86_64-linux-android/debug/build/boring-sys-95dbbaded2f700d3/out/bindings.rs:6722:18
     |
6722 |     pub sa_mask: sigset_t,
     |                  ^^^^^^^^ not found in this scope

error[E0425]: cannot find type `sigval_t` in this scope
    --> /home/runner/work/boring/boring/.cache/build-dir/x86_64-linux-android/debug/build/boring-sys-95dbbaded2f700d3/out/bindings.rs:6827:18
     |
6775 | pub union sigval {
     | ---------------- similarly named union `sigval` defined here
...
6827 |     pub _sigval: sigval_t,
     |                  ^^^^^^^^
     |

Aside from that there are also warnings, but these exist before this PR:

[boring-sys 5.2.0] android toolchain=/usr/local/lib/android/sdk/ndk/27.3.13750724/build/cmake/android.toolchain.cmake
[boring-sys 5.2.0] CMAKE_GENERATOR = None
[boring-sys 5.2.0] cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "x86_64-linux-android-clang": No such file or directory (os error 2)
[boring-sys 5.2.0] cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "x86_64-linux-android-clang++": No such file or directory (os error 2)
[boring-sys 5.2.0] cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "x86_64-linux-android-clang": No such file or directory (os error 2)
[boring-sys 5.2.0] CMAKE_PREFIX_PATH_x86_64-linux-android = None
[boring-sys 5.2.0] CMAKE_PREFIX_PATH_x86_64_linux_android = None

@Lekensteyn

Copy link
Copy Markdown
Collaborator

#529 has an alternative approach to exclude non-BoringSSL symbols that should be more robust.

Are the "ptr casts" and Clippy changes still needed? I don't see any warnings in a recent run, and neither have these commits been applied to current master yet.

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.

4 participants