-
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 (Try 2) #109707
Open
jkoritzinsky
wants to merge
6
commits into
dotnet:main
Choose a base branch
from
jkoritzinsky:brotli-fetchcontent-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88b2cf0
Reapply "Put brotli on the FetchContent plan (#107166)" (#109108)
jkoritzinsky 97c0d26
Don't double-install the brotli libs
jkoritzinsky dc47509
Don't try looking up locations for system brotli. Rely on the distro …
jkoritzinsky fd394f7
Install brotli where we install the compression native lib so they're…
jkoritzinsky 4afff60
Brotli should get pulled from the same place as Compression.Native
jkoritzinsky e3748a0
Fix looking for libbrotlicommon.a on disk to determine if we should u…
jkoritzinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,32 @@ | ||
# IMPORTANT: do not use add_compile_options(), add_definitions() or similar functions here since it will leak to the including projects | ||
|
||
include_directories(BEFORE "${CMAKE_CURRENT_LIST_DIR}/brotli/include") | ||
include(FetchContent) | ||
|
||
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}) | ||
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) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We get libz from IlcSdkPath. What's the reason for brotli to be different?
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.
Getting
libz
from the IlcSdkPath works well because we end up building zlib with the Mono runtime and we build the zlib libs as part of the NativeAOT runtime build (that builds the libraries static libs).For brotli, Mono doesn't currently build brotli in any capacity or link it into their runtime at all. As a result, putting the brotli libs into the ILC SDK and not into the "libraries native components static libs" folder causes Mono-based static linking scenarios to fail as they don't have anywhere to get the brotli symbols from. In particular, we hit this on iOS, a platform where we decided to continue using the system zlib implementation due to size constraints and linking considerations.
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.
The brotli libs are still under
IlcSdkPath
on Windows. Is that right?It does not look right to me that configuration of Mono targets is forcing a directory structure of NAOT packages.
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.
The brotli libs are next to the Compression.Native libs for all platforms. On Windows this is IlcSdkPath, on non-Windows it is not.
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.
Should we have libz next to Compression.Native too to have some sort of consistency?
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 can try giving that a shot now that we aren't going to use a vendored zlib on mobile platforms.