-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Put brotli on the FetchContent plan #107166
Changes from 19 commits
fba095d
75c20c1
c46e058
ff875b8
a8f604c
e1c1d10
199888a
0f8202b
d717e9d
72de3b8
72bc9f8
81e5520
e9896c9
599dc91
a575d28
3bddbf5
9087c81
adaa23c
470a561
c5bfcc4
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 |
---|---|---|
|
@@ -30,6 +30,8 @@ The .NET Foundation licenses this file to you under the MIT license. | |
|
||
<PropertyGroup> | ||
<UseSystemZlib Condition="'$(UseSystemZlib)' == '' and !Exists('$(IlcSdkPath)libz.a')">true</UseSystemZlib> | ||
<!-- Use libbrotlicommon.a as the sentinel for the three brotli libs. --> | ||
<UseSystemBrotli Condition="'$(UseSystemBrotli)' == '' and !Exists('$(IlcSdkPath)libbrotlicommon.a')">true</UseSystemBrotli> | ||
<FullRuntimeName>libRuntime.WorkstationGC</FullRuntimeName> | ||
<FullRuntimeName Condition="'$(ServerGarbageCollection)' == 'true' or '$(IlcLinkServerGC)' == 'true'">libRuntime.ServerGC</FullRuntimeName> | ||
|
||
|
@@ -168,6 +170,14 @@ The .NET Foundation licenses this file to you under the MIT license. | |
<NativeLibrary Condition="'$(UseSystemZlib)' != 'true'" Include="$(IlcSdkPath)libz.a" /> | ||
</ItemGroup> | ||
|
||
<!-- brotli must be added after System.IO.Compression.Native and brotlicommon must be added last, order matters. --> | ||
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. Was there a reason to move this ItemGroup from line 171 to here? I suspect something about the ItemGroup in line 168 was causing trouble. 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 had just added the itemgroup here initially before @agocke did the implementation that uses |
||
<ItemGroup Condition="'$(UseSystemBrotli)' != 'true'"> | ||
<NativeLibrary Include="$(IlcSdkPath)libbrotlienc.a" /> | ||
<NativeLibrary Include="$(IlcSdkPath)libbrotlidec.a" /> | ||
<NativeLibrary Include="$(IlcSdkPath)libbrotlicommon.a" /> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup Condition="'$(StaticICULinking)' == 'true' and '$(NativeLib)' != 'Static' and '$(InvariantGlobalization)' != 'true'"> | ||
<NativeLibrary Include="$(IntermediateOutputPath)libs/System.Globalization.Native/build/libSystem.Globalization.Native.a" /> | ||
<DirectPInvoke Include="libSystem.Globalization.Native" /> | ||
|
@@ -181,11 +191,6 @@ The .NET Foundation licenses this file to you under the MIT license. | |
<NativeSystemLibrary Include="crypto" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(UseSystemBrotli)' != 'false' and Exists('$(IlcSdkPath)nonportable.txt')"> | ||
<NativeSystemLibrary Include="brotlienc" /> | ||
<NativeSystemLibrary Include="brotlidec" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(StaticOpenSslLinking)' == 'true' and '$(NativeLib)' != 'Static'"> | ||
<NativeLibrary Include="$(IntermediateOutputPath)libs/System.Security.Cryptography.Native/build/libSystem.Security.Cryptography.Native.OpenSsl.a" /> | ||
<DirectPInvoke Include="libSystem.Security.Cryptography.Native.OpenSsl" /> | ||
|
@@ -210,6 +215,7 @@ The .NET Foundation licenses this file to you under the MIT license. | |
<NativeSystemLibrary Include="swiftCore" Condition="'$(_IsApplePlatform)' == 'true'" /> | ||
<NativeSystemLibrary Include="swiftFoundation" Condition="'$(_IsApplePlatform)' == 'true'" /> | ||
<NativeSystemLibrary Include="z" Condition="'$(UseSystemZlib)' == 'true'" /> | ||
<NativeSystemLibrary Include="brotlienc;brotlidec;brotlicommon" Condition="'$(UseSystemBrotli)' == 'true'" /> | ||
<NativeSystemLibrary Include="rt" Condition="'$(_IsApplePlatform)' != 'true' and '$(_linuxLibcFlavor)' != 'bionic'" /> | ||
<NativeSystemLibrary Include="log" Condition="'$(_linuxLibcFlavor)' == 'bionic'" /> | ||
<NativeSystemLibrary Include="icucore" Condition="'$(_IsApplePlatform)' == 'true'" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
1.1.0 | ||
https://github.com/google/brotli/releases/tag/v1.1.0 | ||
|
||
Copy the c/dec, c/enc, c/common, and c/include folders into the root and remove all other files. | ||
|
||
Apply https://github.com/google/brotli/commit/85d88cbfc2b742e0742286ec277b73bdbf7be433.patch | ||
Deleted tests, python, docs folders | ||
Apply https://github.com/google/brotli/commit/85d88cbfc2b742e0742286ec277b73bdbf7be433.patch |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,30 @@ | ||
# IMPORTANT: do not use add_compile_options(), add_definitions() or similar functions here since it will leak to the including projects | ||
include(FetchContent) | ||
|
||
include_directories(BEFORE "${CMAKE_CURRENT_LIST_DIR}/brotli/include") | ||
|
||
set (BROTLI_SOURCES_BASE | ||
common/constants.c | ||
common/context.c | ||
common/dictionary.c | ||
common/platform.c | ||
common/shared_dictionary.c | ||
common/transform.c | ||
dec/bit_reader.c | ||
dec/decode.c | ||
dec/huffman.c | ||
dec/state.c | ||
enc/backward_references.c | ||
enc/backward_references_hq.c | ||
enc/bit_cost.c | ||
enc/block_splitter.c | ||
enc/brotli_bit_stream.c | ||
enc/cluster.c | ||
enc/command.c | ||
enc/compound_dictionary.c | ||
enc/compress_fragment.c | ||
enc/compress_fragment_two_pass.c | ||
enc/dictionary_hash.c | ||
enc/encode.c | ||
enc/encoder_dict.c | ||
enc/entropy_encode.c | ||
enc/fast_log.c | ||
enc/histogram.c | ||
enc/literal_cost.c | ||
enc/memory.c | ||
enc/metablock.c | ||
enc/static_dict.c | ||
enc/utf8_util.c | ||
FetchContent_Declare( | ||
brotli | ||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/brotli | ||
) | ||
|
||
addprefix(BROTLI_SOURCES "${CMAKE_CURRENT_LIST_DIR}/brotli" "${BROTLI_SOURCES_BASE}") | ||
set(BROTLI_DISABLE_TESTS ON) | ||
set(__CURRENT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) | ||
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. Don't forget to run all the exotic azp runs: runtime-community, runtime-extra-platforms, the nativeaot and wasm ones. They might capture some interesting error messages. 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. Once I have regular CI working I'll make sure to do so. |
||
set(BUILD_SHARED_LIBS OFF) | ||
FetchContent_MakeAvailable(brotli) | ||
set(BUILD_SHARED_LIBS ${__CURRENT_BUILD_SHARED_LIBS}) | ||
|
||
target_compile_options(brotlicommon PRIVATE $<$<COMPILE_LANG_AND_ID:C,MSVC>:/guard:cf>) | ||
target_compile_options(brotlienc PRIVATE $<$<COMPILE_LANG_AND_ID:C,MSVC>:/guard:cf>) | ||
target_compile_options(brotlidec PRIVATE $<$<COMPILE_LANG_AND_ID:C,MSVC>:/guard:cf>) | ||
target_compile_options(brotlienc PRIVATE $<$<COMPILE_LANG_AND_ID:C,Clang,AppleClang,GNU>:-Wno-implicit-fallthrough>) | ||
target_compile_options(brotlidec PRIVATE $<$<COMPILE_LANG_AND_ID:C,Clang,AppleClang,GNU>:-Wno-implicit-fallthrough>) | ||
|
||
# Even though we aren't building brotli as shared libraries, we still need to be able to export the symbols | ||
# from the brotli libraries so that they can be used by System.IO.Compression. | ||
# Since we link all of the static libraries into a single shared library, we need to define BROTLICOMMON_SHARED_COMPILATION | ||
# for all targets so brotlienc and brotlidec don't expect to link against a separate brotlicommon shared library. | ||
target_compile_definitions(brotlienc PRIVATE BROTLI_SHARED_COMPILATION BROTLIENC_SHARED_COMPILATION BROTLICOMMON_SHARED_COMPILATION) | ||
target_compile_definitions(brotlidec PRIVATE BROTLI_SHARED_COMPILATION BROTLIDEC_SHARED_COMPILATION BROTLICOMMON_SHARED_COMPILATION) | ||
target_compile_definitions(brotlicommon PRIVATE BROTLI_SHARED_COMPILATION BROTLICOMMON_SHARED_COMPILATION) | ||
|
||
# Don't build the brotli command line tool unless explicitly requested | ||
# (which we never do) | ||
set_target_properties(brotli PROPERTIES EXCLUDE_FROM_ALL ON) |
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.
Where does UseSystemLibs acquire its value? Or rather, who is in charge of appending "brotli"? I mainly want to know if we're properly deciding to use system brotli in mobile platforms and wasm/wasi.
BTW, if you run runtime-community, I'd be curious to see if armv6 will give us trouble like with zlib-ng.
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.
UseSystemLibs
is used in source-build for our distro partners to build against system brotli.I don't expect issues with armv6 like zlib-ng as brotli isn't accelerated like zlib-ng is on various platforms.
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.
AFAIK, it's not set automatically anywhere. Even in source-build, we are manually passing it at build-time when we want to build the full .NET SDK for a platform. The only exception is for 9.0 (only) where we assume system brotli (#107225 ).
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.
It would be nice if we can make the vmr default to the configuration that is preferred by most distro maintainers.
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've created an issue for this: dotnet/source-build#4625.