Skip to content

Conversation

@kaukabrizvi
Copy link
Owner

PR Description

This PR adds an optional prefix-symbols feature to boring and boring-sys that prefixes all BoringSSL libssl/libcrypto symbols to avoid collisions with OpenSSL or other BoringSSL variants.

What this does

  • Adds a prefix-symbols Cargo feature.

  • Unix-only build logic that:

    • Uses nm to list global symbols.
    • Applies prefixes via objcopy --redefine-syms.
    • Updates bindgen link names through a custom ParseCallbacks.

Why

This enables BoringSSL to safely coexist with OpenSSL build inside the same process - necessary for interoperability testing with s2n-tls

Can't build with clang-12 to libc++ mismatch
}

if config.features.prefix_symbols {
cfg.define("CMAKE_POSITION_INDEPENDENT_CODE", "ON");

Choose a reason for hiding this comment

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

Why do prefixed symbols need position independent code? Minimally we should comment explaining why this is needed.


/// Prefix applied to all BoringSSL symbols so they don't collide with OpenSSL.
///
const SYMBOL_PREFIX: &str = "BSSL";

Choose a reason for hiding this comment

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

This is certainly nicer than nothing, but is there any way to apply a dynamic prefix? Ideally we'd just BSSL_{crate_version}.

https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates

CARGO_PKG_VERSION — The full version of your package.

I think that might be the solution.

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.

2 participants