diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6958b90..6377732b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,13 +166,13 @@ jobs: echo "===== parallel jobs: $jobs" parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs fi - - name: Run file system test suite + - name: Run file system tests run: | jobs="gcc/debug gcc/release clang/debug clang/release" test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release" echo "===== parallel jobs: $jobs" parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs - - name: Run file system test suite with Valgrind + - name: Run file system tests with Valgrind if: false # note: valgrind is SLOW run: | if command -v valgrind >/dev/null; then @@ -237,6 +237,7 @@ jobs: - name: Check out test suite if: ${{ matrix.testsuite }} run: git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite + - run: set -x; xcode-select -p || true; xcodebuild -version || true - run: set -x; clang --version; clang++ --version - run: clang -E -x c -dM /dev/null # list predefined macros for C - run: clang++ -E -x c++ -dM /dev/null # list predefined macros for C++ @@ -283,7 +284,7 @@ jobs: test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release" echo "===== parallel jobs: $jobs" parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs - - name: Run file system test suite + - name: Run file system tests if: ${{ matrix.testsuite }} # for coreutils readlink run: | export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" @@ -615,7 +616,7 @@ jobs: jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release" echo "===== parallel jobs: $jobs" parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs - - name: Run file system test suite + - name: Run file system tests if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }} run: | apk add coreutils sudo diff --git a/src/bele_policy.h b/src/bele_policy.h index f125bf44..9cc60c0e 100644 --- a/src/bele_policy.h +++ b/src/bele_policy.h @@ -49,7 +49,7 @@ #if defined(BELE_RTP) struct AbstractPolicy { - explicit inline AbstractPolicy() noexcept {} + explicit inline AbstractPolicy() noexcept = default; virtual inline ~AbstractPolicy() noexcept {} V bool isBE() C = 0; V bool isLE() C = 0; @@ -97,7 +97,7 @@ struct BEPolicy final : public AbstractPolicy #endif { - explicit inline BEPolicy() noexcept {} + explicit inline BEPolicy() noexcept = default; #if defined(BELE_CTP) typedef N_BELE_RTP::BEPolicy RTP_Policy; #elif defined(BELE_RTP) @@ -156,7 +156,7 @@ struct LEPolicy final : public AbstractPolicy #endif { - explicit inline LEPolicy() noexcept {} + explicit inline LEPolicy() noexcept = default; #if defined(BELE_CTP) typedef N_BELE_RTP::LEPolicy RTP_Policy; #elif defined(BELE_RTP) diff --git a/src/check/dt_impl.cpp b/src/check/dt_impl.cpp index 4bce6662..c93ab5d9 100644 --- a/src/check/dt_impl.cpp +++ b/src/check/dt_impl.cpp @@ -59,6 +59,10 @@ // warning: comparison with NaN always evaluates to false in fast floating point modes #pragma clang diagnostic ignored "-Wtautological-constant-compare" #endif +#if defined(__FAST_MATH__) && defined(__clang__) && (__clang_major__ + 0 >= 18) +// warning: use of NaN is undefined behavior due to the currently enabled floating-point options +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif #include diff --git a/src/conf.h b/src/conf.h index 6f00efdb..8b549a52 100644 --- a/src/conf.h +++ b/src/conf.h @@ -1,4 +1,4 @@ -/* conf.h -- +/* conf.h -- primary configuration This file is part of the UPX executable compressor. @@ -32,6 +32,7 @@ **************************************************************************/ #include "util/system_headers.h" +#include "util/system_undefs.h" #include "version.h" #if !defined(__has_attribute) @@ -47,6 +48,7 @@ // reserve name "upx" for namespace namespace upx {} +// check compiler core static_assert(CHAR_BIT == 8); static_assert(sizeof(short) == 2); static_assert(sizeof(int) == 4); @@ -58,7 +60,7 @@ static_assert((1u << 31) << 1 == 0); static_assert(((int) (1u << 31)) >> 31 == -1); // arithmetic right shift static_assert((-1) >> 31 == -1); // arithmetic right shift static_assert(CHAR_MAX == 255); // -funsigned-char -static_assert((char) (-1) == 255); +static_assert((char) (-1) == 255); // -funsigned-char // enable some more strict warnings for Git developer builds #if defined(UPX_CONFIG_DISABLE_WSTRICT) && (UPX_CONFIG_DISABLE_WSTRICT + 0 == 0) @@ -215,20 +217,6 @@ typedef upx_int64_t upx_off_t; // portab **************************************************************************/ -// some platform system headers may pre-define these, so undef to avoid conflicts -#undef _ -#undef __ -#undef ___ -#undef dos -#undef large -#undef linux -#undef PAGE_MASK -#undef PAGE_SIZE -#undef small -#undef SP -#undef SS -#undef tos -#undef unix #if (ACC_OS_POSIX) && !defined(__unix__) #define __unix__ 1 #endif diff --git a/src/main.cpp b/src/main.cpp index b9c0aa77..ab67e456 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -/* main.cpp -- +/* main.cpp -- main entry This file is part of the UPX executable compressor. diff --git a/src/util/system_headers.h b/src/util/system_headers.h index 4b7f1d30..5f3aa93d 100644 --- a/src/util/system_headers.h +++ b/src/util/system_headers.h @@ -40,8 +40,15 @@ #if defined(__CYGWIN64__) && !defined(__CYGWIN__) #error "missing __CYGWIN__" #endif -#if defined(__clang__) || defined(__GNUC__) +#if defined(__MINGW64__) && !defined(__MINGW32__) +#error "missing __MINGW32__" +#endif +#if defined(_WIN64) && !defined(_WIN32) +#error "missing _WIN32" +#endif + // byte order - these are pre-defined since gcc-4.6 (2011) and clang-3.2 (2012) +#if defined(__clang__) || defined(__GNUC__) #if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 == 0) #error "missing __ORDER_BIG_ENDIAN__" #endif @@ -61,6 +68,7 @@ #error "unexpected __BYTE_ORDER__" #endif #endif + // pic and pie #if defined(__PIC__) && defined(__pic__) static_assert((__PIC__) == (__pic__)); diff --git a/src/util/system_undefs.h b/src/util/system_undefs.h new file mode 100644 index 00000000..b54bf45b --- /dev/null +++ b/src/util/system_undefs.h @@ -0,0 +1,58 @@ +/* system_undefs.h -- undef system pre-defines + + This file is part of the UPX executable compressor. + + Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + UPX and the UCL library are free software; you can redistribute them + and/or modify them under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + */ + +// some platform system headers may pre-define these, so undef to avoid conflicts +#undef _ +#undef __ +#undef ___ +#undef ____ +#undef _____ +#undef MIPSEB +#undef MIPSEL +#undef PAGE_MASK +#undef PAGE_SIZE +#undef PPC +#undef R3000 +#undef R4000 +#undef SP +#undef SS +#undef WIN32 +#undef WIN64 +#undef WINNT +#undef dos +#undef far +#undef huge +#undef i386 +#undef large +#undef linux +#undef mips +#undef near +#undef powerpc +#undef small +#undef tos +#undef unix + +/* vim:set ts=4 sw=4 et: */ diff --git a/src/work.cpp b/src/work.cpp index 3f4bf6c1..12e801fa 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -1,4 +1,4 @@ -/* work.cpp -- main driver +/* work.cpp -- main work driver This file is part of the UPX executable compressor. @@ -26,12 +26,12 @@ */ // This file implements the central loop, and it uses class PackMaster to -// dispatch. PackMaster by itself will instantiate a concrete subclass -// of class PackerBase which then does the actual work. +// dispatch. PackMaster by itself will instantiate a concrete subclass of +// class PackerBase which then does the actual work; search for "HERE". // And see p_com.cpp for a simple executable format. // -// And this file also has the burden to deal with all those pesky low-level -// file handling issues. +// Additionally this file also has the burden to deal with all those pesky +// low-level file handling issues. #define WANT_WINDOWS_LEAN_H 1 // _get_osfhandle, GetFileTime, SetFileTime #include "util/system_headers.h"