Closed joshlf closed 6 years ago
Can a workaround be a postprocessing script called from bindgen.sh
? I tested the following on a copy of boringssl.rs
with #[link name...]
lines removed and got the original file back. I can open a PR if the script is good enough.
diff --git a/boringssl/bindgen.sh b/boringssl/bindgen.sh
index 564423c..e52c289 100755
--- a/boringssl/bindgen.sh
+++ b/boringssl/bindgen.sh
@@ -143,3 +143,16 @@ cat boringssl.rs >> "$TMP"
mv "$TMP" boringssl.rs
rustfmt boringssl.rs
+
+awk -v "vers=${MAJOR}_${MINOR}_${PATCH}_" '
+/extern "C" {/ {
+ print
+ getline
+ if ($0 ~ "pub fn") {
+ fn = $3
+ sub("[(].*", "", fn)
+ print " #[link_name = \"__RUST_MUNDANE_" vers fn "\"]"
+ }
+}
+{ print }' boringssl.rs >> "$TMP"
+mv "$TMP" boringssl.rs
Yeah, that looks awesome! Check out CONTRIBUTING.md
to see how to submit it. Would it be possible to also count the number of link_name
attributes emitted by the script? We could make sure it matches the number of functions we expect in the script as a sanity check. I'm always a little wary of using simple syntax analysis on code because it can be so error-prone.
Looks like you got all of the Gerrit magic right; well done! Faster than it took me to figure out for sure.
Currently, our
bindgen.sh
script does not automatically generate thelink_name
attributes that we need in order to perform symbol renaming as described inboringssl/README.md
. Instead, we do this manually, which is annoying.We should do this automatically. One good option would be to implement the
bindgen
feature described in this issue: https://github.com/rust-lang-nursery/rust-bindgen/issues/1375. It could also be good to have a simpler workaround until that feature is implemented.