From fc6e3840b7f82b3cb3521d4c0fafaffd9ce65e87 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sat, 9 Dec 2023 08:52:25 +0100 Subject: [PATCH] CI updates --- .github/workflows/ci.yml | 2 +- .../workflows/static-analyzer-clang-analyzer.yml | 2 ++ .github/workflows/static-analyzer-clang-tidy.yml | 2 ++ .github/workflows/test-yaml-check.yml | 1 + .github/workflows/weekly-ci-bs-by-hand.yml | 13 +++++++------ .github/workflows/weekly-ci-cc-alpine-linux.yml | 2 ++ .github/workflows/weekly-ci-cc-alpine-mingw.yml | 3 ++- .github/workflows/weekly-ci-cc-zigcc.yml | 2 +- .github/workflows/weekly-ci-rt-checkers.yml | 5 +++-- CMakeLists.txt | 9 ++++++--- Makefile | 6 +++--- misc/make/Makefile-extra.mk | 2 +- src/check/dt_cxxlib.cpp | 10 ++++++++++ 13 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2a6aa44..6ba31b22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -404,7 +404,7 @@ jobs: needs: [ job-rebuild-and-verify-stubs ] name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} runs-on: ubuntu-latest - container: 'alpine:3.18' # older versions such as alpine:3.12 also work; no-container also works + container: 'alpine:3.19' # older versions such as alpine:3.12 also work; no-container also works strategy: fail-fast: false matrix: diff --git a/.github/workflows/static-analyzer-clang-analyzer.yml b/.github/workflows/static-analyzer-clang-analyzer.yml index c3032199..f1406b22 100644 --- a/.github/workflows/static-analyzer-clang-analyzer.yml +++ b/.github/workflows/static-analyzer-clang-analyzer.yml @@ -20,8 +20,10 @@ jobs: - container: 'alpine:3.16' - container: 'alpine:3.17' - container: 'alpine:3.18' + - container: 'alpine:3.19' - container: 'alpine:edge' - container: 'i386/alpine:3.18' + - container: 'i386/alpine:3.19' - container: 'i386/alpine:edge' name: ${{ format('Analyze clang-analyzer {0}', matrix.container) }} runs-on: ubuntu-latest diff --git a/.github/workflows/static-analyzer-clang-tidy.yml b/.github/workflows/static-analyzer-clang-tidy.yml index e3655052..7c9c437a 100644 --- a/.github/workflows/static-analyzer-clang-tidy.yml +++ b/.github/workflows/static-analyzer-clang-tidy.yml @@ -18,8 +18,10 @@ jobs: matrix: include: - container: 'alpine:3.18' + - container: 'alpine:3.19' - container: 'alpine:edge' - container: 'i386/alpine:3.18' + - container: 'i386/alpine:3.19' - container: 'i386/alpine:edge' name: ${{ format('Analyze clang-tidy {0}', matrix.container) }} runs-on: ubuntu-latest diff --git a/.github/workflows/test-yaml-check.yml b/.github/workflows/test-yaml-check.yml index 2b491f3f..a0914304 100644 --- a/.github/workflows/test-yaml-check.yml +++ b/.github/workflows/test-yaml-check.yml @@ -18,6 +18,7 @@ jobs: - container: 'alpine:3.16' - container: 'alpine:3.17' - container: 'alpine:3.18' + - container: 'alpine:3.19' - container: 'alpine:edge' name: ${{ format('{0}', matrix.container) }} runs-on: ubuntu-latest diff --git a/.github/workflows/weekly-ci-bs-by-hand.yml b/.github/workflows/weekly-ci-bs-by-hand.yml index 81e114ef..a72a0252 100644 --- a/.github/workflows/weekly-ci-bs-by-hand.yml +++ b/.github/workflows/weekly-ci-bs-by-hand.yml @@ -17,7 +17,8 @@ jobs: # ...and also uses a subdirectory "upx with space" in order to detect possible quoting issues # ...and also uses ccache as we are running the same build-script again and again if: github.repository_owner == 'upx' - strategy: { matrix: { container: ['alpine:3.9','alpine:3.18','alpine:edge','i386/alpine:edge'] } } + # Alpine 3.9 + latest Alpine release + edge + strategy: { matrix: { container: ['alpine:3.9','alpine:3.19','alpine:edge','i386/alpine:edge'] } } name: ${{ format('by-hand gcc {0}', matrix.container) }} runs-on: ubuntu-latest container: ${{ matrix.container }} @@ -27,7 +28,7 @@ jobs: # install ccache, g++, git and various POSIX shells shells="bash dash loksh mksh zsh" case ${{ matrix.container }} in - *:3.18 | *:edge) shells="$shells oksh yash" ;; + *:3.19 | *:edge) shells="$shells oksh yash" ;; esac echo "installing shells: $shells" apk update && apk upgrade && apk add ccache g++ git $shells @@ -67,16 +68,16 @@ jobs: - name: 'Build by-hand with mksh -o sh' run: 'mksh -o sh "./upx with space/misc/scripts/build_upx_by_hand.sh"' - name: 'Build by-hand with oksh' - if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge') + if: endsWith(matrix.container, ':3.19') || endsWith(matrix.container, ':edge') run: 'oksh "./upx with space/misc/scripts/build_upx_by_hand.sh"' - name: 'Build by-hand with oksh -o posix' - if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge') + if: endsWith(matrix.container, ':3.19') || endsWith(matrix.container, ':edge') run: 'oksh -o posix "./upx with space/misc/scripts/build_upx_by_hand.sh"' - name: 'Build by-hand with oksh -o sh' - if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge') + if: endsWith(matrix.container, ':3.19') || endsWith(matrix.container, ':edge') run: 'oksh -o sh "./upx with space/misc/scripts/build_upx_by_hand.sh"' - name: 'Build by-hand with yash' - if: endsWith(matrix.container, ':3.18') || endsWith(matrix.container, ':edge') + if: endsWith(matrix.container, ':3.19') || endsWith(matrix.container, ':edge') run: 'yash "./upx with space/misc/scripts/build_upx_by_hand.sh"' - name: 'Build by-hand with zsh' run: 'zsh "./upx with space/misc/scripts/build_upx_by_hand.sh"' diff --git a/.github/workflows/weekly-ci-cc-alpine-linux.yml b/.github/workflows/weekly-ci-cc-alpine-linux.yml index f4c4c689..1c70bc67 100644 --- a/.github/workflows/weekly-ci-cc-alpine-linux.yml +++ b/.github/workflows/weekly-ci-cc-alpine-linux.yml @@ -38,6 +38,7 @@ jobs: - { container: 'alpine:3.16', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } # May 2022: C++2b; clang-13 & gcc-11 - { container: 'alpine:3.17', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } - { container: 'alpine:3.18', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } + - { container: 'alpine:3.19', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } - { container: 'alpine:edge', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } - { container: 'i386/alpine:edge', use_cxx20: 1, use_cxx2b: 1, use_lto: 1 } # more 32-bit i386 versions, just for testing @@ -51,6 +52,7 @@ jobs: - { container: 'i386/alpine:3.16' } # clang-13, gcc-11 - { container: 'i386/alpine:3.17' } # clang-15, gcc-12 - { container: 'i386/alpine:3.18' } # clang-16, gcc-12 + - { container: 'i386/alpine:3.19' } # clang-17, gcc-13 name: ${{ format('container {0}', matrix.container) }} runs-on: ubuntu-latest container: ${{ matrix.container }} diff --git a/.github/workflows/weekly-ci-cc-alpine-mingw.yml b/.github/workflows/weekly-ci-cc-alpine-mingw.yml index c85485eb..c7640c49 100644 --- a/.github/workflows/weekly-ci-cc-alpine-mingw.yml +++ b/.github/workflows/weekly-ci-cc-alpine-mingw.yml @@ -28,7 +28,8 @@ jobs: - { container: 'alpine:3.17', wine: true, i686_mingw: false } # wine-7.21 # Wine >= 8.0 can run i686 32-bit programs in WOW64 mode on pure 64-bit systems - { container: 'alpine:3.18', wine: true, i686_mingw: true } # wine-8.13 - - { container: 'alpine:edge', wine: true, i686_mingw: true } # wine-8.19 + - { container: 'alpine:3.19', wine: true, i686_mingw: true } # wine-8.21 + - { container: 'alpine:edge', wine: true, i686_mingw: true } # wine-8.21 name: ${{ format('container {0}', matrix.container) }} runs-on: ubuntu-latest container: ${{ matrix.container }} diff --git a/.github/workflows/weekly-ci-cc-zigcc.yml b/.github/workflows/weekly-ci-cc-zigcc.yml index df2266cb..26a30a53 100644 --- a/.github/workflows/weekly-ci-cc-zigcc.yml +++ b/.github/workflows/weekly-ci-cc-zigcc.yml @@ -49,7 +49,7 @@ jobs: - { zig_target: x86_64-windows-gnu } name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} runs-on: ubuntu-latest - container: 'alpine:3.18' # older versions such as alpine:3.12 also work; no-container also works + container: 'alpine:3.19' # older versions such as alpine:3.12 also work; no-container also works env: # for zig-cc wrapper scripts (see below): ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING diff --git a/.github/workflows/weekly-ci-rt-checkers.yml b/.github/workflows/weekly-ci-rt-checkers.yml index c5b0c253..92155fce 100644 --- a/.github/workflows/weekly-ci-rt-checkers.yml +++ b/.github/workflows/weekly-ci-rt-checkers.yml @@ -20,8 +20,9 @@ jobs: fail-fast: false matrix: include: - - { container: 'alpine:3.18', release: debug, qemu: 'qemu-x86_64 -cpu Nehalem' } - - { container: 'alpine:3.18', release: release, qemu: 'qemu-x86_64 -cpu Nehalem' } + # latest Alpine release + edge + - { container: 'alpine:3.19', release: debug, qemu: 'qemu-x86_64 -cpu Nehalem' } + - { container: 'alpine:3.19', release: release, qemu: 'qemu-x86_64 -cpu Nehalem' } - { container: 'alpine:edge', release: release, qemu: 'qemu-x86_64 -cpu Nehalem' } - { container: 'i386/alpine:edge', release: release, qemu: 'qemu-i386' } name: ${{ format('{0} {1}', matrix.container, matrix.release) }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 073f8fff..c7d2de9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -379,7 +379,7 @@ function(upx_compile_source_debug_with_O2) endforeach() endfunction() -# sanitize a target +# sanitize a target: this needs proper support from your compiler AND toolchain function(upx_sanitize_target) foreach(t ${ARGV}) if(UPX_CONFIG_DISABLE_SANITIZE) @@ -389,6 +389,8 @@ function(upx_sanitize_target) elseif(MINGW OR CYGWIN) # avoid link errors with current MinGW-w64 versions # see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan + elseif(CMAKE_C_COMPILER_ID MATCHES "^GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "8.0") + # unsupported compiler; unreliable/broken sanitize implementation else() # default sanitizer for Debug builds target_compile_options(${t} PRIVATE $<$:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>) @@ -418,7 +420,7 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") if(WIN32 OR MINGW OR CYGWIN) if(CMAKE_C_COMPILER_ID MATCHES "(Clang|GNU)") # runtime library: msvcrt vs ucrt vs cygwin - print_have_symbol(__CRTDLL__ __CYGWIN__ __CYGWIN32__ __MINGW32__ __MINGW64_VERSION_MAJOR __MSVCRT__ _UCRT) + print_have_symbol(__CRTDLL__ __CYGWIN__ __CYGWIN32__ __CYGWIN64__ __MINGW32__ __MINGW64__ __MINGW64_VERSION_MAJOR __MSVCRT__ _UCRT _WIN32 _WIN64) # exception handing: SJLJ (setjmp/longjmp) vs DWARF vs SEH print_have_symbol(__GCC_HAVE_DWARF2_CFI_ASM __SEH__ __USING_SJLJ_EXCEPTIONS__) # threads: win32 vs posix/pthread/winpthreads vs mcfgthread @@ -449,7 +451,7 @@ if(Threads_FOUND) "${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/try_compile/${f}" OUTPUT_VARIABLE output) if(NOT result) - # failed; under MinGW be sure the use the posix-threads and NOT the win32-threads version + # failed; under MinGW be sure to use the posix-threads and NOT the win32-threads version #message(STATUS "${output}") # debug output from try_compile set(Threads_FOUND OFF) break() @@ -659,6 +661,7 @@ endif() if(CMAKE_INSTALL_PREFIX) include(GNUInstallDirs) endif() +# install files if(CMAKE_INSTALL_PREFIX AND DEFINED CMAKE_INSTALL_FULL_BINDIR) install(TARGETS upx DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") install(FILES diff --git a/Makefile b/Makefile index 2acaa367..c5b17351 100644 --- a/Makefile +++ b/Makefile @@ -24,14 +24,14 @@ endif # default #*********************************************************************** +.DEFAULT_GOAL = build/release + 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 .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 - build/debug: PHONY $(call run_config,$@,Debug) $(call run_build,$@,Debug) @@ -64,7 +64,7 @@ endif # developer convenience CTEST = ctest -test: $(.DEFAULT_GOAL) +test:: $(.DEFAULT_GOAL) PHONY cd $(.DEFAULT_GOAL) && $(CTEST) ifneq ($(wildcard /usr/bin/env),) # needs bash, perl, xargs, etc. check-whitespace clang-format run-testsuite run-testsuite-debug run-testsuite-release: src/Makefile PHONY diff --git a/misc/make/Makefile-extra.mk b/misc/make/Makefile-extra.mk index 5c208d11..ce95cf1a 100644 --- a/misc/make/Makefile-extra.mk +++ b/misc/make/Makefile-extra.mk @@ -4,7 +4,7 @@ # ifeq ($(UPX_MAKEFILE_EXTRA_MK_INCLUDED),) -UPX_MAKEFILE_EXTRA_MK_INCLUDED := 1 +override UPX_MAKEFILE_EXTRA_MK_INCLUDED := 1 override check_defined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),$(error ERROR: variable '$1' is not defined),)) override check_undefined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),,$(error ERROR: variable '$1' is already defined))) diff --git a/src/check/dt_cxxlib.cpp b/src/check/dt_cxxlib.cpp index f5b16023..a221a0ed 100644 --- a/src/check/dt_cxxlib.cpp +++ b/src/check/dt_cxxlib.cpp @@ -53,12 +53,22 @@ ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == sizeof(int)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof('a') == sizeof(char)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("") == 1) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("a") == 2) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("ab") == 3) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L'a') == sizeof(wchar_t)) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L"") == 1 * sizeof(wchar_t)) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L"a") == 2 * sizeof(wchar_t)) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L"ab") == 3 * sizeof(wchar_t)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0) == sizeof(int)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0L) == sizeof(long)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0LL) == sizeof(long long)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(nullptr) == sizeof(void *)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(sizeof(0)) == sizeof(size_t)) ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(usizeof(0)) == sizeof(unsigned)) +#if 0 +// works, but may trigger clang/gcc warnings "-Wunused-value" +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof((1LL, 1)) == sizeof(int)) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof((1, 1LL)) == sizeof(long long)) +#endif namespace compile_time = upx::compile_time; ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("") == 0)