-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use V8's zlib #2522
Use V8's zlib #2522
Conversation
Couple thoughts on this –
Change LGTM but it looks like there's SIMD-related compile errors on Windows so building this using Bazel might be more complex |
@anonrig ... your experience with simd may be helpful in the longer term effort here |
Thanks for the notes @fhanau I don't care about ZLIB_VERNUM itself, just that there is consistency between what is being used in workerd and edgeworker, so as to eliminate a possible source of trouble. I'll have a look tomorrow into what is going wrong on Windows. Fingers crossed that it's not too hard to fix. |
Node.js ZLIB configuration might give you a better understanding for the SIMD related issues. If you couldn't solve this in a reasonable amount of time, I have a Windows machine at home. https://github.com/anonrig/node/blob/main/deps/zlib/zlib.gyp |
00128a8
to
e1b55cc
Compare
May resolve #2540 if we decide to go with this approach. |
d1b9ac5
to
d8aea2c
Compare
d8aea2c
to
481445f
Compare
@@ -0,0 +1,194 @@ | |||
# This config closely follows the original GN build file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewers: In this file, I try to keep everything as similar as possible to the original BUILD.gn even if it looks strange in bazel
Internal PR passes |
Thank you for doing this! Should certainly improve performance in use cases where developers use compression APIs within workerd a lot. |
"@platforms//cpu:x86_64": ["-mssse3"], | ||
"//conditions:default": [], | ||
}), | ||
defines = select({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should really be local_defines
– defines are added to every target that depends on zlib otherwise, which is really polluting the global defines namespace and unnecessarily making the command line of workerd longer. https://bazel.build/reference/be/c-cpp#cc_library.local_defines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree; the main reason I left it all as define is to match BUILD.gn. I can take a crack at limiting the scope in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also another nuisance: I'm using defines
to avoid nested selects which don't work in bazel. I am actually not entirely sure how to get around this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! We use selects.config_setting_group
(https://bazel.build/docs/configurable-attributes#and-chaining) for this. Started with a PR on converting those.
"crc32_simd.h", | ||
"crc_folding.c", | ||
], | ||
copts = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a requirement on ISA extensions that we didn't have before – IMHO this is reasonable since these extensions have been around for a long time but we need to document it.
If we're doing that it's reasonable to define the same set of extensions for the entire build and remove the individual flags from here (I agree that we should follow the structure of BUILD.gn for the individual targets but to make the file less complex we should not have to define ISA extension flags for each target). I will prepare a PR for this.
This PR changes the source of zlib to match what V8 is using, so that we don't have version conflicts between workerd and the internal edgeworker repo.
zlib is built from source. The build config is a translation from the BUILD.gn file into bazel syntax.
Note that this is a bit of a different build process from edgeworker, which uses precompiled binaries from v8 for zlib.