From: Viktor Szakats Date: Thu, 23 May 2024 14:44:40 +0000 (+0200) Subject: cmake: fix brotli lib order X-Git-Tag: curl-8_9_0~405 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7508e9ec41e19bb209498dbc493e5378d8a93b62;p=thirdparty%2Fcurl.git cmake: fix brotli lib order Fix root cause that caused missing symbols when linking brotli statically with e.g. binutils `ld` (and any other "picky" linker, or "traditional" linker as CMake now calls them). Also drop existing workaround that added brotli libs twice to the lib list. ``` x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(decode.c.obj):decode.c:(.text$ProcessCommands[ProcessCommands]+0xbb5): undefined reference to `BrotliTransformDictionaryWord' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(decode.c.obj):decode.c:(.text$SafeProcessCommands[SafeProcessCommands]+0xe8a): undefined reference to `BrotliTransformDictionaryWord' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(decode.c.obj):decode.c:(.rdata$.refptr._kBrotliContextLookupTable[.refptr._kBrotliContextLookupTable]+0x0): undefined reference to `_kBrotliContextLookupTable' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(decode.c.obj):decode.c:(.rdata$.refptr._kBrotliPrefixCodeRanges[.refptr._kBrotliPrefixCodeRanges]+0x0): undefined reference to `_kBrotliPrefixCodeRanges' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(state.c.obj):state.c:(.text$BrotliDecoderStateInit[BrotliDecoderStateInit]+0x21): undefined reference to `BrotliDefaultAllocFunc' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(state.c.obj):state.c:(.text$BrotliDecoderStateInit[BrotliDecoderStateInit]+0x2f): undefined reference to `BrotliDefaultFreeFunc' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(state.c.obj):state.c:(.text$BrotliDecoderStateInit[BrotliDecoderStateInit]+0x10e): undefined reference to `BrotliSharedDictionaryCreateInstance' x86_64-w64-mingw32-ld: .../curl/brotli/_bld/usr/lib/libbrotlidec.a(state.c.obj):state.c:(.text$BrotliDecoderStateCleanup[BrotliDecoderStateCleanup]+0xf4): undefined reference to `BrotliSharedDictionaryDestroyInstance' collect2: error: ld returned 1 exit status ``` Breakage reproducible with curl-for-win config "`win-gcc`" and deleting the `LDFLAGS+=' -Wl,--start-group'` line from its `curl.sh` script. (Above line still required for some non-brotli cases, e.g. libssh2 and zlib.) Assisted-by: Kai Pastor Ref: https://github.com/curl/curl/pull/10857#discussion_r1611714989 Follow-up to 1e3319a167d2f32d295603167486e9e88af9bb4e #10857 Closes #13761 --- diff --git a/CMake/FindBrotli.cmake b/CMake/FindBrotli.cmake index 11ab7f8254..dcab8f7cd3 100644 --- a/CMake/FindBrotli.cmake +++ b/CMake/FindBrotli.cmake @@ -40,4 +40,4 @@ find_package_handle_standard_args(Brotli ) set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR}) -set(BROTLI_LIBRARIES ${BROTLICOMMON_LIBRARY} ${BROTLIDEC_LIBRARY}) +set(BROTLI_LIBRARIES ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY}) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3525d3fca..65b805c33c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -580,7 +580,6 @@ if(CURL_BROTLI) find_package(Brotli REQUIRED) if(BROTLI_FOUND) set(HAVE_BROTLI ON) - set(CURL_LIBS "${BROTLI_LIBRARIES};${CURL_LIBS}") # For 'ld' linker. Emulate `list(PREPEND ...)` to stay compatible with