-
Notifications
You must be signed in to change notification settings - Fork 294
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
# This config closely follows the original GN build file | ||
# Ref: https://chromium.googlesource.com/chromium/src/third_party/zlib.git/+/refs/heads/main/BUILD.gn | ||
# The main difference is that we don't set ZLIB_DLL because it messes things up on Windows | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
zlib_warnings = [ | ||
"-Wno-incompatible-pointer-types", | ||
"-Wunused-variable", | ||
] | ||
|
||
cc_library( | ||
name = "zlib_common_headers", | ||
hdrs = [ | ||
"chromeconf.h", | ||
"deflate.h", | ||
"inffast.h", | ||
"inffixed.h", | ||
"inflate.h", | ||
"inftrees.h", | ||
"zconf.h", | ||
"zlib.h", | ||
"zutil.h", | ||
], | ||
defines = ["ZLIB_IMPLEMENTATION"], | ||
includes = ["."], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "x86_defines", | ||
defines = select({ | ||
"@platforms//os:windows": ["X86_WINDOWS"], | ||
"//conditions:default": ["X86_NOT_WINDOWS"], | ||
}), | ||
) | ||
|
||
cc_library( | ||
name = "zlib_adler32_simd", | ||
srcs = [ | ||
"adler32_simd.c", | ||
"adler32_simd.h", | ||
], | ||
copts = select({ | ||
"@platforms//cpu:x86_64": ["-mssse3"], | ||
"//conditions:default": [], | ||
}), | ||
defines = select({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should really be There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. There's also another nuisance: I'm using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question! We use |
||
"@platforms//cpu:x86_64": ["ADLER32_SIMD_SSSE3"], | ||
"@platforms//cpu:aarch64": ["ADLER32_SIMD_NEON"], | ||
}), | ||
visibility = ["//visibility:public"], | ||
deps = [":zlib_common_headers"] + select({ | ||
"@platforms//cpu:x86_64": [":x86_defines"], | ||
"//conditions:default": [], | ||
}), | ||
) | ||
|
||
cc_library( | ||
name = "zlib_arm_crc32", | ||
srcs = [ | ||
"crc32_simd.c", | ||
"crc32_simd.h", | ||
], | ||
defines = ["CRC32_ARMV8_CRC32"] + select({ | ||
"@platforms//os:linux": ["ARMV8_OS_LINUX"], | ||
"@platforms//os:macos": ["ARMV8_OS_MACOS"], | ||
"@platforms//os:windows": ["ARMV8_OS_WINDOWS"], | ||
}), | ||
visibility = ["//visibility:public"], | ||
deps = [":zlib_common_headers"], | ||
) | ||
|
||
cc_library( | ||
name = "zlib_inflate_chunk_simd", | ||
srcs = [ | ||
"contrib/optimizations/chunkcopy.h", | ||
"contrib/optimizations/inffast_chunk.c", | ||
"contrib/optimizations/inffast_chunk.h", | ||
"contrib/optimizations/inflate.c", | ||
], | ||
copts = zlib_warnings, | ||
defines = select({ | ||
"@platforms//cpu:x86_64": [ | ||
"INFLATE_CHUNK_SIMD_SSE2", | ||
"INFLATE_CHUNK_READ_64LE", | ||
], | ||
"@platforms//cpu:aarch64": [ | ||
"INFLATE_CHUNK_SIMD_NEON", | ||
"INFLATE_CHUNK_READ_64LE", | ||
], | ||
}), | ||
visibility = ["//visibility:public"], | ||
deps = [":zlib_common_headers"], | ||
) | ||
|
||
cc_library( | ||
name = "zlib_crc32_simd", | ||
srcs = [ | ||
"crc32_simd.c", | ||
"crc32_simd.h", | ||
"crc_folding.c", | ||
], | ||
copts = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
"-msse4.2", | ||
"-mpclmul", | ||
], | ||
defines = select({ | ||
"@platforms//cpu:x86_64": ["CRC32_SIMD_SSE42_PCLMUL"], | ||
}), | ||
visibility = ["//visibility:public"], | ||
deps = [":zlib_common_headers"], | ||
) | ||
|
||
cc_library( | ||
name = "zlib_slide_hash_simd", | ||
srcs = [ | ||
"slide_hash_simd.h", | ||
], | ||
defines = select({ | ||
"@platforms//cpu:x86_64": ["DEFLATE_SLIDE_HASH_SSE2"], | ||
"@platforms//cpu:aarch64": ["DEFLATE_SLIDE_HASH_NEON"], | ||
}), | ||
visibility = ["//visibility:public"], | ||
deps = [":zlib_common_headers"], | ||
) | ||
|
||
filegroup( | ||
name = "inflate_c", | ||
srcs = [ | ||
"inflate.c", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
filegroup( | ||
name = "zlib_files", | ||
srcs = [ | ||
"adler32.c", | ||
"chromeconf.h", | ||
"compress.c", | ||
"contrib/optimizations/insert_string.h", | ||
"cpu_features.c", | ||
"cpu_features.h", | ||
"crc32.c", | ||
"crc32.h", | ||
"deflate.c", | ||
"deflate.h", | ||
"gzclose.c", | ||
"gzguts.h", | ||
"gzlib.c", | ||
"gzread.c", | ||
"gzwrite.c", | ||
"infback.c", | ||
"inffast.c", | ||
"inffast.h", | ||
"inffixed.h", | ||
"inflate.h", | ||
"inftrees.c", | ||
"inftrees.h", | ||
"trees.c", | ||
"trees.h", | ||
"uncompr.c", | ||
"zconf.h", | ||
"zlib.h", | ||
"zutil.c", | ||
"zutil.h", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "zlib", | ||
srcs = [":zlib_files"] + select({ | ||
"@platforms//cpu:x86_64": [], | ||
"@platforms//cpu:aarch64": [], | ||
"//conditions:default": [":inflate_c"], | ||
}), | ||
copts = zlib_warnings, | ||
defines = select({ | ||
"@platforms//cpu:x86_64": [], | ||
"@platforms//cpu:aarch64": [], | ||
"//conditions:default": ["CPU_NO_SIMD"], | ||
}), | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":zlib_adler32_simd", | ||
":zlib_inflate_chunk_simd", | ||
":zlib_slide_hash_simd", | ||
] + select({ | ||
"@platforms//cpu:x86_64": [":zlib_crc32_simd"], | ||
"@platforms//cpu:aarch64": [":zlib_arm_crc32"], | ||
}), | ||
) |
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