CI updates; cleanups
This commit is contained in:
+14
-18
@@ -44,10 +44,7 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
UNUSED(argv);
|
||||
return 0;
|
||||
#else
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (!e)
|
||||
e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling
|
||||
if (e && e[0] && strcmp(e, "0") != 0)
|
||||
if (is_envvar_true("UPX_DEBUG_DOCTEST_DISABLE", "UPX_DEBUG_DISABLE_DOCTEST"))
|
||||
return 0;
|
||||
bool minimal = true; // don't show summary
|
||||
bool duration = false; // don't show timings
|
||||
@@ -56,7 +53,7 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
// default for debug builds: do show the [doctest] summary
|
||||
minimal = false;
|
||||
#endif
|
||||
e = getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
||||
if (e && e[0]) {
|
||||
if (strcmp(e, "0") == 0) {
|
||||
minimal = true;
|
||||
@@ -352,11 +349,6 @@ static noinline void check_basic_cxx_exception_handling(void (*func)(int)) noexc
|
||||
// basic floating point checks to early catch toolchain/qemu/wine/etc problems
|
||||
//
|
||||
|
||||
#if defined(__clang__) && defined(__FAST_MATH__) && defined(__INTEL_LLVM_COMPILER)
|
||||
// warning: comparison with NaN always evaluates to false in fast floating point modes
|
||||
#pragma clang diagnostic ignored "-Wtautological-constant-compare"
|
||||
#endif
|
||||
|
||||
static noinline float i64_f32_add_div(upx_int64_t a, upx_int64_t b) { return (a + b) / 1000000.0f; }
|
||||
static noinline float u64_f32_add_div(upx_uint64_t a, upx_uint64_t b) {
|
||||
return (a + b) / 1000000.0f;
|
||||
@@ -388,11 +380,18 @@ struct TestFloat {
|
||||
assert_noexcept(add_div_x(X, X) == Float(2));
|
||||
assert_noexcept(sub_div(3 * X, X, Float(X)) == Float(2));
|
||||
assert_noexcept(sub_div_x(3 * X, X) == Float(2));
|
||||
// extra debugging hack
|
||||
const char *e = getenv("UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO");
|
||||
if (e && e[0] && strcmp(e, "0") != 0) {
|
||||
// extra debugging; floating point edge cases cause portability problems in practice
|
||||
if (is_envvar_true("UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO")) {
|
||||
#if defined(__clang__) && defined(__FAST_MATH__) && defined(__INTEL_LLVM_COMPILER)
|
||||
// warning: comparison with NaN always evaluates to false in fast floating point modes
|
||||
fprintf(stderr, "upx: WARNING: ignoring UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO\n");
|
||||
#elif defined(__clang__) && (__clang_major__ < 9) && defined(__SANITIZE_UNDEFINED_BEHAVIOR__)
|
||||
// @COMPILER_BUG @CLANG_BUG
|
||||
fprintf(stderr, "upx: WARNING: ignoring UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO\n");
|
||||
#else
|
||||
assert_noexcept(std::isnan(div(0, Float(0))));
|
||||
assert_noexcept(std::isinf(div(X, Float(0))));
|
||||
assert_noexcept(std::isinf(div(1, Float(0))));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -423,10 +422,7 @@ static noinline void check_basic_floating_point(void) noexcept {
|
||||
#include "../util/miniacc.h"
|
||||
|
||||
void upx_compiler_sanity_check(void) noexcept {
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (!e)
|
||||
e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling
|
||||
if (e && e[0] && strcmp(e, "0") != 0) {
|
||||
if (is_envvar_true("UPX_DEBUG_DOCTEST_DISABLE", "UPX_DEBUG_DISABLE_DOCTEST")) {
|
||||
// If UPX_DEBUG_DOCTEST_DISABLE is set then we don't want to throw any
|
||||
// exceptions in order to improve debugging experience.
|
||||
} else {
|
||||
|
||||
+1
-2
@@ -1306,8 +1306,7 @@ int upx_main(int argc, char *argv[]) may_throw {
|
||||
if (gitrev[0]) {
|
||||
// also see UPX_CONFIG_DISABLE_GITREV in CMakeLists.txt
|
||||
bool warn_gitrev = true;
|
||||
const char *ee = getenv("UPX_DEBUG_DISABLE_GITREV_WARNING");
|
||||
if (ee && ee[0] && strcmp(ee, "1") == 0)
|
||||
if (is_envvar_true("UPX_DEBUG_DISABLE_GITREV_WARNING"))
|
||||
warn_gitrev = false;
|
||||
if (warn_gitrev) {
|
||||
FILE *f = stdout;
|
||||
|
||||
+7
-5
@@ -2243,17 +2243,19 @@ tribool PackMachBase<T>::canPack()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if !defined(DEBUG)
|
||||
// disable macOS packing in Release builds until we do support macOS 13+
|
||||
// disable macOS packing until we do support macOS 13+
|
||||
// https://github.com/upx/upx/issues/612
|
||||
if (my_cputype == CPU_TYPE_X86_64 || my_cputype == CPU_TYPE_ARM64)
|
||||
if (!opt->darwin_macho.force_macos)
|
||||
if (my_cputype == CPU_TYPE_X86_64 || my_cputype == CPU_TYPE_ARM64) {
|
||||
bool force = opt->darwin_macho.force_macos || is_envvar_true("UPX_DEBUG_FORCE_PACK_MACOS");
|
||||
if (!force)
|
||||
throwCantPack("macOS is currently not supported (try --force-macos)");
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// instantiate instances
|
||||
template class PackMachBase<MachClass_BE32>;
|
||||
// template class PackMachBase<MachClass_BE64>; // currently not used
|
||||
template class PackMachBase<MachClass_LE32>;
|
||||
template class PackMachBase<MachClass_LE64>;
|
||||
|
||||
|
||||
+1
-1
@@ -1240,7 +1240,7 @@ Linker* PackVmlinuxAMD64::newLinker() const
|
||||
|
||||
// instantiate instances
|
||||
template class PackVmlinuxBase<ElfClass_BE32>;
|
||||
// template class PackVmlinuxBase<ElfClass_BE64>; // not used
|
||||
// template class PackVmlinuxBase<ElfClass_BE64>; // currently not used
|
||||
template class PackVmlinuxBase<ElfClass_LE32>;
|
||||
template class PackVmlinuxBase<ElfClass_LE64>;
|
||||
|
||||
|
||||
@@ -30,9 +30,16 @@
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_FORMAT_MACROS) // this is needed for some older glibc/mingw versions
|
||||
// these are needed for some older glibc/mingw versions
|
||||
#if !defined(__STDC_CONSTANT_MACROS)
|
||||
#define __STDC_CONSTANT_MACROS 1
|
||||
#endif
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
#define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#if !defined(__USE_MINGW_ANSI_STDIO)
|
||||
#if defined(_WIN32) && defined(__MINGW32__) && (defined(__clang__) || defined(__GNUC__))
|
||||
@@ -40,7 +47,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
// disable silly warnings about using "deprecated" POSIX functions like fopen()
|
||||
#if !defined(_CRT_NONSTDC_NO_DEPRECATE)
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||
|
||||
+38
-23
@@ -32,7 +32,36 @@
|
||||
#error "C++17 is required"
|
||||
#endif
|
||||
|
||||
// sanity check
|
||||
// check expected defines
|
||||
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
|
||||
#error "missing __CYGWIN__"
|
||||
#endif
|
||||
#if defined(__CYGWIN64__) && !defined(__CYGWIN__)
|
||||
#error "missing __CYGWIN__"
|
||||
#endif
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
// these are pre-defined since gcc-4.6 (2011) and clang-3.2 (2012)
|
||||
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 == 0)
|
||||
#error "missing __ORDER_BIG_ENDIAN__"
|
||||
#endif
|
||||
#if !defined(__ORDER_LITTLE_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 == 0)
|
||||
#error "missing __ORDER_LITTLE_ENDIAN__"
|
||||
#endif
|
||||
#if !defined(__BYTE_ORDER__) || (__BYTE_ORDER__ + 0 == 0)
|
||||
#error "missing __BYTE_ORDER__"
|
||||
#endif
|
||||
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 != 4321)
|
||||
#error "unexpected __ORDER_BIG_ENDIAN__"
|
||||
#endif
|
||||
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 != 1234)
|
||||
#error "unexpected __ORDER_BIG_ENDIAN__"
|
||||
#endif
|
||||
#if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
|
||||
#error "unexpected __BYTE_ORDER__"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// sanity checks
|
||||
#if defined(__ILP32) || defined(__ILP32__)
|
||||
static_assert(sizeof(int) == 4);
|
||||
static_assert(sizeof(long) == 4);
|
||||
@@ -55,28 +84,9 @@ static_assert(sizeof(int) == 4);
|
||||
static_assert(sizeof(long) == 4);
|
||||
static_assert(sizeof(void *) == 8);
|
||||
#endif
|
||||
|
||||
// check expected defines
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
// these are pre-defined since gcc-4.6 (2011) and clang-3.2 (2012)
|
||||
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 == 0)
|
||||
#error "missing __ORDER_BIG_ENDIAN__"
|
||||
#endif
|
||||
#if !defined(__ORDER_LITTLE_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 == 0)
|
||||
#error "missing __ORDER_LITTLE_ENDIAN__"
|
||||
#endif
|
||||
#if !defined(__BYTE_ORDER__) || (__BYTE_ORDER__ + 0 == 0)
|
||||
#error "missing __BYTE_ORDER__"
|
||||
#endif
|
||||
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 != 4321)
|
||||
#error "unexpected __ORDER_BIG_ENDIAN__"
|
||||
#endif
|
||||
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 != 1234)
|
||||
#error "unexpected __ORDER_BIG_ENDIAN__"
|
||||
#endif
|
||||
#if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
|
||||
#error "unexpected __BYTE_ORDER__"
|
||||
#endif
|
||||
#if defined(__CYGWIN__)
|
||||
static_assert(sizeof(int) == 4);
|
||||
static_assert(sizeof(void *) == sizeof(long));
|
||||
#endif
|
||||
|
||||
// ACC and C system headers
|
||||
@@ -135,6 +145,11 @@ static_assert(sizeof(void *) == 8);
|
||||
#define __SANITIZE_MEMORY__ 1
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(__SANITIZE_UNDEFINED_BEHAVIOR__) && defined(__has_feature)
|
||||
#if __has_feature(undefined_behavior_sanitizer)
|
||||
#define __SANITIZE_UNDEFINED_BEHAVIOR__ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// UPX vendor git submodule headers
|
||||
#include <doctest/doctest/parts/doctest_fwd.h>
|
||||
|
||||
@@ -768,6 +768,19 @@ int fn_strcmp(const char *n1, const char *n2) {
|
||||
// misc
|
||||
**************************************************************************/
|
||||
|
||||
bool is_envvar_true(const char *envvar, const char *alternate_name) noexcept {
|
||||
// UPX convention: any environment variable that is set and is not strictly equal to "0" is true
|
||||
const char *e = getenv(envvar);
|
||||
if (e != nullptr && e[0])
|
||||
return strcmp(e, "0") != 0;
|
||||
if (alternate_name != nullptr) {
|
||||
e = getenv(alternate_name);
|
||||
if (e != nullptr && e[0])
|
||||
return strcmp(e, "0") != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool set_method_name(char *buf, size_t size, int method, int level) {
|
||||
bool r = true;
|
||||
const char *alg;
|
||||
|
||||
@@ -192,6 +192,8 @@ bool maketempname(char *ofilename, size_t size, const char *ifilename, const cha
|
||||
bool force = true);
|
||||
bool makebakname(char *ofilename, size_t size, const char *ifilename, bool force = true);
|
||||
|
||||
bool is_envvar_true(const char *envvar, const char *alternate_name = nullptr) noexcept;
|
||||
|
||||
unsigned get_ratio(upx_uint64_t u_len, upx_uint64_t c_len);
|
||||
bool set_method_name(char *buf, size_t size, int method, int level);
|
||||
void center_string(char *buf, size_t size, const char *s);
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@
|
||||
#define UPX_VERSION_STRING "4.2.3"
|
||||
#define UPX_VERSION_STRING4 "4.23"
|
||||
#define UPX_VERSION_DATE "Mar 12th 2024"
|
||||
#define UPX_VERSION_DATE_ISO "2024-03-12"
|
||||
#define UPX_VERSION_DATE_ISO "2024-03-16"
|
||||
#define UPX_VERSION_YEAR "2024"
|
||||
|
||||
Reference in New Issue
Block a user