From 9eb01b53642384a2e072c20ffaae13cd850a2a0d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 15 Mar 2024 13:07:26 +0100 Subject: [PATCH] CMake: Avoid dsmyutil warnings on shared libraries using libjpeg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We link object files with the same names into the BundledLibjpeg static archive. This caused warnings when running dsymutil on shared libraries using that archive: skipping debug map object with duplicate name and timestamp could not find object file symbol for symbol _jpeg_start_compress Avoid that by creating copies of the source files with different names, so that all object files are unique. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-123324 Change-Id: I1d4ebdd111b4172cde793671fbe059957f102871 Reviewed-by: Tor Arne Vestbø Reviewed-by: Qt CI Bot Reviewed-by: Alexey Edelev (cherry picked from commit b72158daf502e1f7f0d8c585df6923b4d958cb94) Reviewed-by: Qt Cherry-pick Bot --- src/3rdparty/libjpeg/CMakeLists.txt | 36 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/libjpeg/CMakeLists.txt b/src/3rdparty/libjpeg/CMakeLists.txt index 6b211e25423..6ceb5e5a1a7 100644 --- a/src/3rdparty/libjpeg/CMakeLists.txt +++ b/src/3rdparty/libjpeg/CMakeLists.txt @@ -1,4 +1,4 @@ -set(JPEG16_SOURCES +set(jpeg16_original_sources src/jcapistd.c src/jccolor.c src/jcdiffct.c @@ -15,8 +15,8 @@ set(JPEG16_SOURCES src/jdsample.c src/jutils.c) -set(JPEG12_SOURCES - ${JPEG16_SOURCES} +set(jpeg12_original_sources + ${jpeg16_original_sources} src/jccoefct.c src/jcdctmgr.c src/jdcoefct.c @@ -31,8 +31,8 @@ set(JPEG12_SOURCES src/jquant1.c src/jquant2.c) -set(JPEG_SOURCES - ${JPEG12_SOURCES} +set(jpeg_original_sources + ${jpeg12_original_sources} src/jaricom.c src/jcapimin.c src/jcarith.c @@ -64,11 +64,31 @@ set(JPEG_SOURCES src/jmemnobs.c src/jpeg_nbits.c) +# Make copies of the source files for the different bit counts, so that all the object file names +# are unique in the static archive. This avoids duplicate warnings for certain linkers and debug +# info extractors (like Apple's ld and dsymutil). +function(qt_internal_copy_jpeg_sources in_sources infix out_var) + set(jpeg_sources "") + foreach(src_file ${in_sources}) + get_filename_component(src_file_name "${src_file}" NAME_WLE) + get_filename_component(src_file_extension "${src_file}" LAST_EXT) + set(dest_path "${CMAKE_CURRENT_BINARY_DIR}/${src_file_name}${infix}${src_file_extension}") + configure_file(${src_file} "${dest_path}" COPYONLY) + message(DEBUG "Copying jpeg source file ${src_file} to ${dest_path}.") + list(APPEND jpeg_sources "${dest_path}") + endforeach() + set(${out_var} "${jpeg_sources}" PARENT_SCOPE) +endfunction() + +qt_internal_copy_jpeg_sources("${jpeg16_original_sources}" "_16" jpeg16_sources) +qt_internal_copy_jpeg_sources("${jpeg12_original_sources}" "_12" jpeg12_sources) +qt_internal_copy_jpeg_sources("${jpeg_original_sources}" "" jpeg_sources) + qt_internal_add_3rdparty_library(BundledLibjpeg16bits STATIC SKIP_AUTOMOC SOURCES - ${JPEG16_SOURCES} + ${jpeg16_sources} DEFINES BITS_IN_JSAMPLE=16 INCLUDE_DIRECTORIES @@ -81,7 +101,7 @@ qt_internal_add_3rdparty_library(BundledLibjpeg12bits STATIC SKIP_AUTOMOC SOURCES - ${JPEG12_SOURCES} + ${jpeg12_sources} DEFINES BITS_IN_JSAMPLE=12 INCLUDE_DIRECTORIES @@ -96,7 +116,7 @@ qt_internal_add_3rdparty_library(BundledLibjpeg SKIP_AUTOMOC INSTALL SOURCES - ${JPEG_SOURCES} + ${jpeg_sources} $ $ INCLUDE_DIRECTORIES