Fix allowlist regex in bindgen invocation

The allowlist is just a regex, which means bindgen leaves it to the
user to resolve Windows vs POSIX filepath differences. We need to
support both / and \. It's unclear why only some headers are broken, but
it's probably something to do with whether the header is included
directly or indirectly.

Unfortunately, in doing so, we run into a mess of escaping issues, so
the regex is more permissing than ideal.

Bug: 595
Change-Id: I8b785aeaaeff162d9eb2aced89928f9602445903
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/58967
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
This commit is contained in:
David Benjamin
2023-04-19 21:16:25 +00:00
committed by Boringssl LUCI CQ
parent 1a5570b8e8
commit a38d600805
+23 -5
View File
@@ -5,15 +5,33 @@ target_link_libraries(rust_wrapper crypto)
# Generate architecture-specific wrappers.
set(WRAPPER_TARGET ${CMAKE_BINARY_DIR}/rust/bssl-sys/src/wrapper_${RUST_BINDINGS}.rs)
set(COMMAND ${BINDGEN_EXECUTABLE} "wrapper.h"
set(COMMAND ${BINDGEN_EXECUTABLE} wrapper.h
-o ${WRAPPER_TARGET}
--no-derive-default
--enable-function-attribute-detection
--use-core
--default-macro-constant-type="signed"
--rustified-enum="point_conversion_form_t"
--allowlist-file=".*/include/openssl/.*\\.h"
--allowlist-file=".*/rust_wrapper\\.h"
--default-macro-constant-type=signed
--rustified-enum=point_conversion_form_t
# These regexes need to accept both / and \ to handle Windows file
# path differences, due a bindgen issue. See
# https://crbug.com/boringssl/595. Ideally, we would write [/\\],
# but there are many layers of escaping here. First, CMake
# interprets backslashes. Then CMake generates a Ninja or Make file.
# That, in turn, launches passes inputs to the shell on POSIX, and
# does something else on Windows.
#
# It is unlikely that every layer here has sufficiently well-defined
# escaping and correctly handled the next layer's escaping. On top
# of that, we'd likely need to detect Windows vs POSIX hosts and
# change the input. Instead, just use [[:punct:]] which is more
# permissive than necessary, but we only need to exclude unwanted
# libc heaaders.
#
# If bindgen ever supports some file-based config (see
# https://github.com/rust-lang/rust-bindgen/issues/2508), we can
# switch to that.
--allowlist-file=".*[[:punct:]]include[[:punct:]]openssl[[:punct:]].*\\.h"
--allowlist-file=".*[[:punct:]]rust_wrapper\\.h"
-- # these are LLVM arg passthroughs
-I../../include
# https://doc.rust-lang.org/nightly/rustc/platform-support.html