From 1e6e4043ed6d69fe5d342ab36b3dae6a6649e91d Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sat, 2 Dec 2023 01:48:26 +0100 Subject: [PATCH] CI updates and minor cleanups. --- .github/workflows/ci.yml | 2 +- .github/workflows/weekly-ci-cc-llvm-mingw.yml | 12 +++---- CMakeLists.txt | 2 ++ Makefile | 4 +-- misc/make/Makefile-extra.mk | 2 +- .../cross-compile-upx-ubuntu/Dockerfile | 2 +- src/bele.h | 36 +++++++++---------- src/packmast.cpp | 3 +- src/pefile.cpp | 3 +- src/pefile.h | 2 +- src/work.cpp | 5 +-- 11 files changed, 39 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75b461f8..b2a6aa44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install -y g++-multilib g++-mingw-w64-i686 g++-mingw-w64-x86-64 - # make sure that we use posix-threads (pthreads) and NOT win32-threads + # make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do if test -f /usr/bin/$f-posix; then sudo update-alternatives --set $f /usr/bin/$f-posix; fi done diff --git a/.github/workflows/weekly-ci-cc-llvm-mingw.yml b/.github/workflows/weekly-ci-cc-llvm-mingw.yml index a850f8b0..adefd6e9 100644 --- a/.github/workflows/weekly-ci-cc-llvm-mingw.yml +++ b/.github/workflows/weekly-ci-cc-llvm-mingw.yml @@ -27,12 +27,12 @@ jobs: - name: llvm-mingw-20230614-ucrt llvm_version: 16.0.6 url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20230614/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64.tar.xz' - - name: llvm-mingw-20231114-msvcrt - llvm_version: 17.0.5 - url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20231114/llvm-mingw-20231114-msvcrt-ubuntu-20.04-x86_64.tar.xz' - - name: llvm-mingw-20231114-ucrt - llvm_version: 17.0.5 - url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20231114/llvm-mingw-20231114-ucrt-ubuntu-20.04-x86_64.tar.xz' + - name: llvm-mingw-20231128-msvcrt + llvm_version: 17.0.6 + url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64.tar.xz' + - name: llvm-mingw-20231128-ucrt + llvm_version: 17.0.6 + url: 'https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-ubuntu-20.04-x86_64.tar.xz' name: ${{ format('{0} {1}', matrix.name, matrix.llvm_version) }} runs-on: ubuntu-latest steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c5ba125..073f8fff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ macro(upx_cmake_include_hook section) include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/hooks/CMakeLists.${section}.txt" OPTIONAL) include("${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.${section}.txt" OPTIONAL) endmacro() +file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/.upx_cmake_config_done.txt") #*********************************************************************** # options @@ -711,5 +712,6 @@ endif() endif() # UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK upx_cmake_include_hook(9_finish) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/.upx_cmake_config_done.txt" "") # vim:set ft=cmake ts=4 sw=4 tw=0 et: diff --git a/Makefile b/Makefile index 40544927..2acaa367 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,8 @@ endif run_cmake_config = $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2 run_cmake_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2 -# avoid re-running run_cmake_config if CMakeCache.txt already exists -run_config = $(if $(wildcard $1/CMakeCache.txt),,$(call run_cmake_config,$1,$2)) +# avoid re-running run_cmake_config if .upx_cmake_config_done.txt already exists +run_config = $(if $(wildcard $1/CMakeFiles/.upx_cmake_config_done.txt),,$(call run_cmake_config,$1,$2)) run_build = $(call run_cmake_build,$1,$2) .DEFAULT_GOAL = build/release diff --git a/misc/make/Makefile-extra.mk b/misc/make/Makefile-extra.mk index cfb4037d..5c208d11 100644 --- a/misc/make/Makefile-extra.mk +++ b/misc/make/Makefile-extra.mk @@ -207,7 +207,7 @@ build/extra/scan-build/debug: build/analyze/clang-analyzer/debug build/extra/scan-build/release: build/analyze/clang-analyzer/release #*********************************************************************** -# advanced: generic extra target +# advanced: generic eXtra target #*********************************************************************** # usage: diff --git a/misc/podman/cross-compile-upx-ubuntu/Dockerfile b/misc/podman/cross-compile-upx-ubuntu/Dockerfile index e97374d4..f3277017 100644 --- a/misc/podman/cross-compile-upx-ubuntu/Dockerfile +++ b/misc/podman/cross-compile-upx-ubuntu/Dockerfile @@ -34,7 +34,7 @@ RUN apt-get update && apt-get upgrade -y \ # Windows cross compilers g++-mingw-w64-i686 \ g++-mingw-w64-x86-64 \ - # make sure that we use posix-threads (pthreads) and NOT win32-threads + # make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads && for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do update-alternatives --set $f /usr/bin/$f-posix; done \ && true RUN apt-get install -y \ diff --git a/src/bele.h b/src/bele.h index ad9a492e..457d25a4 100644 --- a/src/bele.h +++ b/src/bele.h @@ -753,6 +753,24 @@ inline unsigned UPX_MIN(const LE32 &a, unsigned b) { return UPX_MIN(unsigned(a), // misc support **************************************************************************/ +// upx_is_integral; see conf.h +#define TT_UPX_IS_INTEGRAL(T) \ + template <> \ + struct upx_is_integral : public std::true_type {}; \ + template <> \ + struct upx_is_integral : public std::true_type {}; \ + template <> \ + struct upx_is_integral : public std::true_type {}; \ + template <> \ + struct upx_is_integral : public std::true_type {} +TT_UPX_IS_INTEGRAL(BE16); +TT_UPX_IS_INTEGRAL(BE32); +TT_UPX_IS_INTEGRAL(BE64); +TT_UPX_IS_INTEGRAL(LE16); +TT_UPX_IS_INTEGRAL(LE32); +TT_UPX_IS_INTEGRAL(LE64); +#undef TT_UPX_IS_INTEGRAL + // native types #if (ACC_ABI_BIG_ENDIAN) typedef BE16 NE16; @@ -776,24 +794,6 @@ typedef LE64 NE64; #define ne64_compare_signed le64_compare_signed #endif -// upx_is_integral -#define TT_IS_INTEGRAL(T) \ - template <> \ - struct upx_is_integral : public std::true_type {}; \ - template <> \ - struct upx_is_integral : public std::true_type {}; \ - template <> \ - struct upx_is_integral : public std::true_type {}; \ - template <> \ - struct upx_is_integral : public std::true_type {} -TT_IS_INTEGRAL(BE16); -TT_IS_INTEGRAL(BE32); -TT_IS_INTEGRAL(BE64); -TT_IS_INTEGRAL(LE16); -TT_IS_INTEGRAL(LE32); -TT_IS_INTEGRAL(LE64); -#undef TT_IS_INTEGRAL - // for use with qsort() extern "C" { int __acc_cdecl_qsort be16_compare(const void *, const void *); diff --git a/src/packmast.cpp b/src/packmast.cpp index 5042b511..a6a8573f 100644 --- a/src/packmast.cpp +++ b/src/packmast.cpp @@ -138,7 +138,8 @@ PackerBase *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const O void *user) may_throw { #define D(Klass) \ do { \ - COMPILE_TIME_ASSERT(std::is_nothrow_destructible_v) \ + static_assert(std::is_class_v); \ + static_assert(std::is_nothrow_destructible_v); \ auto pb = std::unique_ptr(new Klass(f)); \ if (o->debug.debug_level) \ fprintf(stderr, "visitAllPackers: (ver=%d, fmt=%3d) %s\n", pb->getVersion(), \ diff --git a/src/pefile.cpp b/src/pefile.cpp index eb9db0ec..6763c001 100644 --- a/src/pefile.cpp +++ b/src/pefile.cpp @@ -686,7 +686,8 @@ const LE32 &PeFile::IDADDR(unsigned x) const { return iddirs[x].vaddr; } */ class PeFile::ImportLinker final : public ElfLinkerAMD64 { - struct TStr final : private ::noncopyable { // temporary string owner, deletes on destruction + // temporary string owner, deletes on destruction + struct TStr final : private upx::noncopyable { explicit TStr(char *str) noexcept : s(str) {} ~TStr() noexcept { delete[] s; } // delete! operator char *() noexcept { return s; } diff --git a/src/pefile.h b/src/pefile.h index e12d53e9..384f9437 100644 --- a/src/pefile.h +++ b/src/pefile.h @@ -383,7 +383,7 @@ protected: }; class Reloc final : private noncopyable { - // these are set in constructor + // these are set in the constructor: byte *start = nullptr; unsigned start_size_in_bytes = 0; bool start_did_alloc = false; diff --git a/src/work.cpp b/src/work.cpp index de318d5d..58714a80 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -67,7 +67,7 @@ namespace { -struct XStat { +struct XStat final { struct stat st; #if USE_SETFILETIME FILETIME ft_atime; @@ -307,8 +307,9 @@ void do_one_file(const char *const iname, char *const oname) may_throw { flags = get_open_flags(WO_MUST_EXIST_TRUNCATE); copy_timestamp_only = true; } - } else if (opt->force_overwrite || opt->force) + } else if (opt->force_overwrite || opt->force) { flags = get_open_flags(WO_CREATE_OR_TRUNCATE); + } int shmode = SH_DENYWR; #if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__) // TODO later: check current mintlib if this hack is still needed