Add patch for `<stddef.h>` being included inside of extern "C" section
which is invalid in C++.
### Motivation:
When building with C++ interop enabled on Linux, `<stddef.h>` fails to
import because the C++ module `_Builtin_stddef.max_align_t` (which it
includes) is re-imported with C language linkage.
```
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h"
| `- note: in file included from <module-includes>:1:
2 |
/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:20:10: note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:20:
18 | #define C_NIO_LLHTTP_SWIFT
19 |
20 | #include "c_nio_llhttp.h"
| `- note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:20:
21 |
22 | static inline llhttp_errno_t c_nio_llhttp_execute_swift(llhttp_t *parser,
/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:559:10: note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:559:
557 | extern "C" {
558 | #endif
559 | #include <stddef.h>
| `- note: in file included from /home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:559:
560 |
561 | #if defined(__wasm__)
<unknown>:0: error: could not build C module 'CNIOLLHTTP'
/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/recipe-sysroot-native/usr/lib/clang/17/include/stddef.h:128:1: error: import of C++ module '_Builtin_stddef.max_align_t' appears within extern "C" language linkage specification
126 |
127 | #if defined(__need_max_align_t)
128 | #include <__stddef_max_align_t.h>
| `- error: import of C++ module '_Builtin_stddef.max_align_t' appears within extern "C" language linkage specification
129 | #undef __need_max_align_t
130 | #endif /* defined(__need_max_align_t) */
/home/xtremek/Programming/xavgru12/meta-swift-project/poky/build-qemuarm64/tmp-glibc/work/cortexa57-oe-linux/swift-hello-world/1.0/build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:557:1: note: extern "C" language linkage specification begins here
555 | #define INCLUDE_LLHTTP_API_H_
556 | #ifdef __cplusplus
557 | extern "C" {
| `- note: extern "C" language linkage specification begins here
558 | #endif
```
### Modifications:
Added a patch to the `update_and_patch_llhttp.sh` file to move this
include to the correct location, and ran the script to actually apply it
to the included `c_nio_llhttp.h` file in the `CNIOLLHTTP` target.
### Result:
swift-nio compiles properly on a package with C++ interop
(`.interoperabilityMode(.Cxx)`) enabled in Linux.
@lhoward @Lukasa
Update llhttp dependency in `CNIOLLHTTP` target ahead of adding a new
patch to the `update_and_patch_llhttp.sh` script.
### Motivation:
We need to update the `update_and_patch_llhttp.sh` script to add an
additional patch to fix compiling swift-nio with C++ interop enabled in
Swift targets. It was recommended to update llhttp separately from the
patch update and ahead of time to keep the changes separate from each
other.
### Modifications:
Ran the `update_and_patch_llhttp.sh` script in the CNIOLLHTTP target to
update the llhttp dependency to the latest version (9.3.0). It appears
that the only changes from 9.2.1 (previous version) is a few new
includes, and the definition of the `UNREACHABLE` macro that is used
instead of the `abort()` call.
### Result:
Everything compiles locally and test suite passes with these changes.
@Lukasa
### Motivation
C++ interop support in Xcode has started to dislike the header files
from llhttp. While a bug has been filed upstream at
https://github.com/nodejs/llparse/issues/71 it doesn't seem as though
there is any movement on that fix upstream. As a result, we need to
apply a patch.
To keep the code maintainable, we'd like to apply that patch in an
automated fashion, so we should do so by amending the "update and patch"
script. Along the way, we should update LLHTTP to the latest code.
### Modifications
The modifications are split into separate commits.
1. Modify the script to fix some bugs that have crept in.
2. Run the script to update LLHTTP to latest, without the patch.
3. Fix up the tests to account for the fact that we get some different
errors from LLHTTP now.
4. Apply the patch suggested by @postmechanical in #3093
5. Re-run the script, which only applies the patch
### Result
C++ interop should be working again. Resolves#3093.
---------
Co-authored-by: George Barnett <gbarnett@apple.com>
Motivation:
The node.js HTTP parser library that we use has been unmaintained for some time. We should move to the maintained replacement, which is llhttp. This patch will update our dependency and bring us over to the new library, as well as make any changes we need.
Modifications:
This patch comes in 4 parts, each contained in a separate commit in the PR.
The first commit drops the existing http_parser code and updates some of the repo state for using llhttp.
The second commit rewrites the update script to bring in llhttp instead of http_parser.
The third runs the actual script. You can skip reviewing this except to sanity check the outcome.
The fourth commit updates the NIO code and the tests to get everything working.
In general the substance of the product modifications was minimal. The logic around keeping track of where we are in the buffer and how upgrades work has changed a bit, so that required some fiddling. I also had to add an error reporting path for the delegates to be able to throw specific errors that llhttp no longer checks for. Finally, I removed two tests that were a little overzealous and that llhttp does not police.
Result:
Back on the supported path.