Details
Description
Hi!
I've been up to building the entirety of Qt cross-platform. but the issue I'm describing happens with a native GCC toolchain. I'm also using the official conanfile for Qt 6.7.1, providing built libpng, zlib, freetype, etc. The reason I'm posting this here is I don't think it's a conan issue, as the problem comes from GN invocations.
Almost the entire webengine module has finished building, when I encountered a linker error:
"/usr/bin/python3" "../../../../../../../src/qtwebengine/src/3rdparty/chromium/build/toolchain/gcc_link_wrapper.py" --output="./v8_context_snapshot_generator" -- /usr/bin/g++ -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -m64 -Wl,-O2 -Wl,--gc-sections -rdynamic -Wl,-z,defs -Wl,--as-needed -pie -Wl,--disable-new-dtags -L/home/host/conan/home/p/b/nss9306d22c66924/p/lib -L/home/host/conan/home/p/b/sqlitc7d5f67bfbb6f/p/lib -L/home/host/conan/home/p/b/zlib91bc0fa91c990/p/lib -L/home/host/conan/home/p/b/nspr900d68a8fb991/p/lib -L/home/host/conan/home/p/b/libpn8ab592101f831/p/lib -L/home/host/conan/home/p/b/freet7727274ab95c2/p/lib -L/home/host/conan/home/p/b/bzip2ece3b256d4582/p/lib -L/home/host/conan/home/p/b/brotlf7918074e3cb5/p/lib -L/home/host/conan/home/p/b/fontc1d644f1af0a27/p/lib -L/home/host/conan/home/p/b/util-2c2a7afeb8031/p/lib -L/home/host/conan/home/p/b/expat89f962ec3608a/p/lib -L/home/host/conan/home/p/b/opus11470ea062c51/p/lib -L/home/host/conan/home/p/b/libdr8eb88b84e962f/p/lib -o "./v8_context_snapshot_generator" -Wl,--start-group @"./v8_context_snapshot_generator.rsp" -Wl,--end-group -latomic -ldl -lpthread -lrt -lsoftokn3 -lsqlite3 -lm -lnssdbm3 -lz -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -lresolv -lpng -lexpat -lfreetype -lbz2 -lbrotlidec -lbrotlienc -lbrotlicommon -lfontconfig -luuid -lopus -ldrm /usr/bin/ld: /home/host/conan/home/p/b/libpn8ab592101f831/p/lib/libpng.a(png.c.o): in function `png_reset_crc': png.c:(.text+0x40f): undefined reference to `crc32' /usr/bin/ld: /home/host/conan/home/p/b/libpn8ab592101f831/p/lib/libpng.a(png.c.o): in function `png_calculate_crc': png.c:(.text+0x475): undefined reference to `crc32' /usr/bin/ld: png.c:(.text+0x4a4): undefined reference to `crc32' /usr/bin/ld: /home/host/conan/home/p/b/libpn8ab592101f831/p/lib/libpng.a(png.c.o): in function `png_icc_set_sRGB': png.c:(.text+0x4b56): undefined reference to `adler32' /usr/bin/ld: png.c:(.text+0x4b64): undefined reference to `adler32' /usr/bin/ld: png.c:(.text+0x4b74): undefined reference to `crc32' /usr/bin/ld: png.c:(.text+0x4b82): undefined reference to `crc32'
These references are defined in zlib, but the libs are built statically, where order matters. These flags are in the wrong order, as -lz has to come after -lpng and -lfreetype as it's dependees.
I've looked everywhere on what script or module sets up these flags, to no avail. What I suspect is that they get exported into rsp files by qtwebengine/cmake/Gn.cmake that qtwebengine/cmake/Functions.cmake calls:
foreach(ninjaTarget ${arg_NINJA_TARGETS}) list(APPEND output ${ninjaTarget}_objects.rsp ${ninjaTarget}_archives.rsp ${ninjaTarget}_libs.rsp ${ninjaTarget}_ldir.rsp) endforeach() list(TRANSFORM output PREPEND "${arg_BUILDDIR}/") add_custom_command( OUTPUT ${output} COMMAND ${CMAKE_COMMAND} -DBUILD_DIR=${arg_BUILDDIR} -DSOURCE_DIR=${CMAKE_CURRENT_LIST_DIR} -DMODULE=${arg_MODULE} -DQT_HOST_PATH=${QT_HOST_PATH} -DINSTALL_LIBEXECDIR=${INSTALL_LIBEXECDIR} -DINSTALL_BINDIR=${INSTALL_BINDIR} -DPython3_EXECUTABLE=${Python3_EXECUTABLE} -DGN_THREADS=$ENV{QTWEBENGINE_GN_THREADS} -DQT_ALLOW_SYMLINK_IN_PATHS=${QT_ALLOW_SYMLINK_IN_PATHS} -P ${WEBENGINE_ROOT_SOURCE_DIR}/cmake/Gn.cmake WORKING_DIRECTORY ${WEBENGINE_ROOT_BUILD_DIR} COMMENT "Run gn for target ${arg_CMAKE_TARGET} in ${arg_BUILDDIR}" DEPENDS ${gnArgArgFile} run_${arg_MODULE}_GnReady "${WEBENGINE_ROOT_SOURCE_DIR}/src/${arg_MODULE}/configure/BUILD.root.gn.in" "${WEBENGINE_ROOT_SOURCE_DIR}/cmake/Gn.cmake" )
<build_folder>/QtWebEngineCore_libs.rsp:
-latomic -ldl -lpthread -lrt -lsoftokn3 -lsqlite3 -lm -lnssdbm3 -lz -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -lresolv -lopus -lfontconfig -luuid -lfreetype -lbz2 -lpng -lbrotlidec -lbrotlienc -lbrotlicommon -lexpat -ldrm -ldbus-1
I've also tried to explicitly specify libs = [ "png", "z" ] in relevant BUILD.gn files, but GN does not seem to respect it.
I'm not sure if these flags come from Qt's main libs up the chain or from chroimum down the line, from GN files.
Thanks in advance!