This patch has 3 parts: a commit to update the vendoring script, a
commit that contains the results of running the script, and then a fixup
for the API breaks we got.
* Update vendoring and perlasm
* Update vendoring script
* Update to BoringSSL 3309ca66385ecb0c37f1ac1be9f88712e25aa8ec
* Handle API break in BoringSSL
* Various vendor script fixes:
- Fix various 'gsed' occurrences with '$sed'
- Remove the delocate patch, it is no longer required
- Add another patch to include inttypes in
CNIOBoringSSL/crypto/x509/t_x509.c where PRIu64 is used and remove it
from CNIOBoringSSL_bn.h. this works around a build failure with
xcodeproj.
- Use the host platform build directory when mangling C++ symbols
- Fix Python bytes/string writing in build-asm.py
* Update BoringSSL to c239ffd0552179f358de31517391679e9b62ccd3
* Update BoringSSL to 25773430c07075a368416c3646fa4b07daf4968a
* Clean up the use of the X509 pointer
Motivation:
BoringSSL has begun opaquifying their X.509 library. This unfortunately
manifests as source code changes in Swift due to the way OpaquePointer
behaves. As a result, we need to change the places that held an X.509
pointer directly.
While we're here, we've been playing a bit fast-and-loose with the
lifetime of owned pointers. We should take this opportunity to clean
things up and be a bit better behaved.
Modifications:
- Replace the X509 pointers with OpaquePointer
- Use scoped access to the X.509 access outside the NIOSSLCertificate
class.
Result:
Code compiles with better pointer hygeine.
Motivation:
C++ structures emit a number of symbols into their binaries that are
named based on the name of the structure. Most notably, these are the
three (or five, depending on mode) magic structure methods: copy
constructor, copy assignment operator, destructor.
By and large this isn't an issue for us as BoringSSL already namespaces
most of its structures. However, a few structures are the target of
opaque typedefs in the public header files. These need to use the names
that would appear in the internal source. If they didn't, the internal
source wouldn't compile! As a result they need to appear outside the
inner prefixing namespace.
We knew about this limitation at the time we did this work, but hoped
we'd get along just fine without changing anything. In fact we did, for
nearly three years. But the chickens have come home to roost in
https://github.com/grpc/grpc-swift/issues/1134.
So it's time to fix it.
Fortunately for us, we never write down the names of the inner types in
our source code. That means we don't actually care what that name _is_.
This gives us our escape hatch: we can namespace the names of the
underlying C++ types using the same preprocessor trick as the function
names. This will have the effect of also namespacing their magic
methods.
Modifications:
This patch attempts to make this change defensively, by assuming that
other structures may be added that meet this pattern. To do it, we
compile the binary _again_ and search for any C++ methods that haven't
already been namespaced and that don't belong to Swift. We then extract
the structure name from them and add a `#define` for it. This forcibly
renames the structure in all cases.
Result:
No more colliding symbols.
* Update vendoring script to fix a missing includeo
Motivation:
The openssl/evp.h header was missing causing compilation to fail.
In addition, a previously missing header is now included by BoringSSL.
Modifications:
- Update the fix import line to fix the new missing header.
Result:
BoringSSL can be vendored using our script.
* Update BoringSSL to 4a265be4d931e35f0d108040c94d37bb49827948.
Motivation:
BoringSSL and Folly both attempt to play silly buggers with the sdallocx
symbol defined in jemalloc. Unfortunately, they don't play nicely
together, and the end result if you have both present is that BoringSSL
will reliably SIGBUS or SIGSEGV on initialization. Naturally, this isn't
good.
Modifications:
- Resolve the issue by patching out BoringSSL's allocator optimisation.
- Update BoringSSL to 6432bb46ab44731567ec923e6c8fc182f13d0070.
Result:
Flow and BoringSSL will play better together.
Motivation:
BoringSSL potentially defines different symbols on different
architecture and platform combinations. This means that we've
historically missed mangling some symbol names when our script only
involved building on macOS.
We should build on more platforms to test this.
Modifications:
- Added support for cross compiling to Linux amd64, Linux aarch64, and
Linux armv7 in symbol mangling script.
- Added support for compiling for iOS armv6 and arm64 in symbol mangling
script.
Result:
Harder to run the mangling script, better results when you do.
Motivation:
Well-formed Linux assembly code declares a .note.GNU-stack section in
order to help out the linker. When absent, the linker makes some
suboptimal linking decisions that can cause pain in running programs.
Modifications:
- Amend the vendoring script to add the .note.GNU-stack section to all
assembly files on Linux.
- Updated BoringSSL
Results:
Better linker behaviour.
Motivation:
Our scripts have code to catch the functions that are used with STACK_OF
and LHASH_OF data structures in BoringSSL in order to namespace them.
Sadly, some declarations were falling through the cracks: we missed some
LHASH_OF functions used internally, and we missed the
DEFINE_NAMED_STACK_OF macro used for a new C++ data type.
Modifications:
- Improved these scripts to catch more cases.
- Updated BoringSSL to 9806ae005b3085683a2fcf2953e4170893e0973d.
Result:
Fewer exported symbols from BoringSSL.
Motivation:
When including an xcodeproj generated by SwiftPM (which builds
CNIOBoringSSL) into an xcodeproj which wasn't generated by SwiftPM it
doesn't know about the correct header paths.
Modifications:
Update the vendor-boringssl script to:
- Namespace BoringSSL with CNIOBoringSSL_ instead of CNIOBoringSSL/
- Create an umbrealla CNIOBoringSSL header
- Apply a patch to replace inttypes.h with sys/types.h in bn.h
- Apply a patch to conditionally include arm_arch.h
BoringSSL was also updated to: ae223d6138807a13006342edfeef32e813246b39
Result:
Non-SwiftPM xcodeproj's can build a SwiftPM generated xcodeproj
which includes CNIOBoringSSL.
Motivation:
The 32-bit assembly in BoringSSL doesn't assemble correctly on 32-bit
apple platforms. It took us a while to notice because we previously
haven't had any supported 32-bit platforms. NIOSSL still doesn't really
support any 32-bit Apple platforms, as all production use on those
platforms should use NIOTS, but there's no excuse for the compilation
failures really.
Modifications:
Remove assembly acceleration on 32-bit Apple platforms.
Result:
Better compilation on 32-bit Apple platforms.
Motivation:
We want to avoid BoringSSL falling too far out of date. This patch updates
BoringSSL.
Modifications:
Updated BoringSSL.
Result:
Newer BoringSSL.
Motivation:
Our previous namespacing effort used symbol analysis of a compiled binary
to locate all the symbols that needed to be namespaced away. This works
fine for regular C and C++ symbols, but fails for any header-only
inline functions.
These functions, while not emitted into the binary, can cause problems
with the C++ ODR if they are included in multiple clang modules. This
unfortunately does happen if the user includes both this library and,
for example, modularised headers that include OpenSSL headers.
Fortunately, we can namespace the inline functions as well.
Modifications:
- Namespaced all the inline headers by source analysis.
Result:
Fewer code conflicts.