From ae8904efcb897e4473e3477b4b7ee1f14184d4aa Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 8 Jun 2026 11:45:29 -0500 Subject: [PATCH 1/3] Remove duplicated mingw variables block The exact same code is there 80 lines up. --- build-release | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/build-release b/build-release index e538828..bb30d74 100755 --- a/build-release +++ b/build-release @@ -565,24 +565,6 @@ build () { cp -av "${dll_location}" "${target_build_dir}/" done fi - - local strip='strip' - if "${system_windows}" && ! "${host_windows}" - then - if "${arch_i686}" - then - bitness='32' - mingw_arch_prefix='i686' - else - bitness='64' - mingw_arch_prefix='x86_64' - fi - - strip="${mingw_arch_prefix}-w64-mingw32-strip" - cmake_opts="${cmake_opts} -DCMAKE_TOOLCHAIN_FILE=${daemon_dir}/cmake/cross-toolchain-mingw${bitness}.cmake" - # unused - # cmake_opts="${cmake_opts} -DPKG_CONFIG_EXECUTABLE=${mingw_arch_prefix}-w64-mingw32-pkg-config" - fi fi if "${build_vm}" From 4d14357c67d5a550be5a1dffce39b327dcceb876 Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 8 Jun 2026 13:06:34 -0500 Subject: [PATCH 2/3] Use GCC --print-file-name to locate MinGW DLLs Use the --print-file-name option with MinGW GCC to get the locations of its DLLs, instead of searching for them in the filesystem. Well, this only actually works directly with Debian's packaging. On other distros, --print-file-name doesn't work on DLLs. For those we use it to locate a random static library, then hope that the DLL is in a `bin` directory which is a sibling of a `lib` directory containing the static lib. The method of getting the path to the compiler (via grepping in the CMake cache) is ugly, but overall it seems better than scanning the filesystem (which may have multiple toolchains installed) for DLLs and hoping we got the right one. --- build-release | 58 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/build-release b/build-release index bb30d74..be44e75 100755 --- a/build-release +++ b/build-release @@ -29,6 +29,7 @@ set -e # error on undefined variable set -u +# TODO: use a signal so this can actually exit from subshells? throwError () { local error_keyword="${1}" local error_message="${2}" @@ -161,18 +162,31 @@ dumpSymbols () { } findDll () { - local mingw_arch="${1}" - local dll_name="${2}" + local mingw_compiler="${1}" + local dll="${2}" - if [ -z "${mingw_arch}" ] + # On Debian, --print-file-name works on DLLs. They live in multiple directories. + dll_path=$("${mingw_compiler}" --print-file-name "${dll}") + if [ -e "${dll_path}" ] then - find "${MINGW_PREFIX}/bin/${dll_name}" + echo "${dll_path}" return fi - # HACK: sort to get posix flavor of libstdc++ before win32 flavor - find '/usr' -name "${dll_name}" -type f | sort | grep --max-count=1 "${mingw_arch}" \ - || throwError INTERNAL "couldn't find DLL ${dll_name}" + local test_dll=libstdc++-6.dll + local test_importlib=libstdc++.dll.a + + # On MSYS, Arch or Fedora there are bin and lib sibling directories. + # *.dll is in bin and *.dll.a is in lib. All DLLs are in one place. + importlib_path=$("${mingw_compiler}" --print-file-name "${test_importlib}") + dll_path=$(echo "${importlib_path}" | sed -e "s!/lib/${test_importlib}\$!/bin!") + if [ -e "${dll_path}/${test_dll}" ] + then + echo "${dll_path}/${dll}" + return + fi + + throwError INTERNAL "Can't find DLL path for compiler '${mingw_compiler}'" } cleanSymbols () { @@ -500,7 +514,8 @@ build () { fi strip="${mingw_arch_prefix}-w64-mingw32-strip" - cmake_opts="${cmake_opts} -DCMAKE_TOOLCHAIN_FILE=${daemon_dir}/cmake/cross-toolchain-mingw${bitness}.cmake" + # The -DCMAKE_C_COMPILER= hack makes this variable be cached + cmake_opts="${cmake_opts} -DCMAKE_C_COMPILER= -DCMAKE_TOOLCHAIN_FILE=${daemon_dir}/cmake/cross-toolchain-mingw${bitness}.cmake" # unused # cmake_opts="${cmake_opts} -DPKG_CONFIG_EXECUTABLE=${mingw_arch_prefix}-w64-mingw32-pkg-config" fi @@ -549,21 +564,9 @@ build () { special_dll='libgcc_s_seh-1.dll' fi - extra_dll_list="${special_dll} libgomp-1.dll libstdc++-6.dll libwinpthread-1.dll libssp-0.dll" - # DLLs are added to engine_file_list after building engine_file_list="${engine_file_list} daemon.exe daemonded.exe daemon-tty.exe crash_server.exe nacl_loader.exe" engine_symbolize_list='daemon.exe daemonded.exe daemon-tty.exe' engine_strip_list='daemon.exe daemonded.exe daemon-tty.exe crash_server.exe' - - # those paths are distro-centric - # cp -av "/usr/${mingw_arch_prefix}-w64-mingw32/lib/libwinpthread-1.dll" "${target_build_dir}/" - # cp -av "/usr/lib/gcc/${mingw_arch_prefix}-w64-mingw32/7.3-posix/libstdc++-6.dll" "${target_build_dir}/" - # cp -av "/usr/lib/gcc/${mingw_arch_prefix}-w64-mingw32/7.3-posix/${special_dll}" "${target_build_dir}/" - for dll_name in ${extra_dll_list} - do - dll_location="$(findDll "${mingw_arch_prefix}" "${dll_name}")" - cp -av "${dll_location}" "${target_build_dir}/" - done fi fi @@ -590,6 +593,21 @@ build () { -D"CMAKE_EXE_LINKER_FLAGS=${cmake_cflags}" \ ${cmake_opts} \ || throwError INTERNAL "${target} cmake failed" + + if "${system_windows}" + then + extra_dll_list="${special_dll} libgomp-1.dll libstdc++-6.dll libwinpthread-1.dll libssp-0.dll" + # DLLs are added to engine_file_list after building + + local mingw_c_compiler=$(grep '^CMAKE_C_COMPILER:' "${target_build_dir}/CMakeCache.txt" \ + | sed -E 's/^[^=]*=//') + + for dll_name in ${extra_dll_list} + do + dll_location=$(findDll "${mingw_c_compiler}" "${dll_name}") + cp -av "${dll_location}" "${target_build_dir}/" + done + fi fi if "${build_vm}" From a76ab30d67cfd092c7a4003d4008362a89b53d82 Mon Sep 17 00:00:00 2001 From: slipher Date: Tue, 9 Jun 2026 14:37:25 -0500 Subject: [PATCH 3/3] MinGW: add libssp-0.dll only if needed Starting with GCC 15 or 16, the compiler no longer emits libssp dependencies. Fixes build-release on MSYS. --- build-release | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build-release b/build-release index be44e75..63efb3f 100755 --- a/build-release +++ b/build-release @@ -596,7 +596,7 @@ build () { if "${system_windows}" then - extra_dll_list="${special_dll} libgomp-1.dll libstdc++-6.dll libwinpthread-1.dll libssp-0.dll" + extra_dll_list="${special_dll} libgomp-1.dll libstdc++-6.dll libwinpthread-1.dll" # DLLs are added to engine_file_list after building local mingw_c_compiler=$(grep '^CMAKE_C_COMPILER:' "${target_build_dir}/CMakeCache.txt" \ @@ -607,6 +607,10 @@ build () { dll_location=$(findDll "${mingw_c_compiler}" "${dll_name}") cp -av "${dll_location}" "${target_build_dir}/" done + + # Tool, which will help us later + mingw_objdump=$("${mingw_c_compiler}" --print-prog-name objdump) + "${mingw_objdump}" --help > /dev/null fi fi @@ -627,6 +631,12 @@ build () { if "${system_windows}" then + # Newer MinGW toolchains don't emit libssp dependencies + if "${mingw_objdump}" -p "${target_build_dir}/daemon.exe" | grep libssp-0.dll + then + dll_location=$(findDll "${mingw_c_compiler}" libssp-0.dll) + cp -av "${dll_location}" "${target_build_dir}/" + fi engine_file_list="${engine_file_list} $(cd "${target_build_dir}" && ls *.dll)" elif "${system_macos}" then