From 4a63a30c17309a886961075118012fe87a1dbbff Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 29 Jun 2021 06:10:37 +0400 Subject: [PATCH] Get rid of unneeded glibc wraps --- CMakeLists.txt | 3 -- .../openssl/openssl_common/CMakeLists.txt | 8 --- external/qt/CMakeLists.txt | 27 ---------- linux_glibc_wraps/CMakeLists.txt | 22 -------- .../platform/linux/linux_glibc_wraps.c | 29 ----------- .../platform/linux/linux_glibc_wraps_32.c | 49 ----------------- .../platform/linux/linux_glibc_wraps_64.c | 52 ------------------- variables.cmake | 1 - 8 files changed, 191 deletions(-) delete mode 100644 linux_glibc_wraps/CMakeLists.txt delete mode 100644 linux_glibc_wraps/platform/linux/linux_glibc_wraps.c delete mode 100644 linux_glibc_wraps/platform/linux/linux_glibc_wraps_32.c delete mode 100644 linux_glibc_wraps/platform/linux/linux_glibc_wraps_64.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 15c7247..7299f07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,6 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL add_subdirectory(external) -if (DESKTOP_APP_USE_GLIBC_WRAPS) - add_subdirectory(linux_glibc_wraps) -endif() if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED AND Qt5WaylandClient_FOUND) diff --git a/external/openssl/openssl_common/CMakeLists.txt b/external/openssl/openssl_common/CMakeLists.txt index e05ef9f..3343366 100644 --- a/external/openssl/openssl_common/CMakeLists.txt +++ b/external/openssl/openssl_common/CMakeLists.txt @@ -21,14 +21,6 @@ if (NOT DESKTOP_APP_USE_PACKAGED) endif() if (LINUX) - if (DESKTOP_APP_USE_GLIBC_WRAPS) - target_link_libraries(external_openssl_common - INTERFACE - desktop-app::linux_glibc_wraps - $ - ) - endif() - target_link_libraries(external_openssl_common INTERFACE ${CMAKE_DL_LIBS} diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index bd51d20..77aa5b5 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -287,26 +287,6 @@ else() -Wl,--no-as-needed,-lrt ) endif() - if (DESKTOP_APP_USE_GLIBC_WRAPS) - target_link_options(external_qt - INTERFACE - -Wl,-wrap,aligned_alloc - -Wl,-wrap,secure_getenv - -Wl,-wrap,clock_gettime - -Wl,--no-as-needed,-lrt - ) - if (NOT build_linux32) - target_link_options(external_qt - INTERFACE - -Wl,-wrap,__divmodti4 - ) - else() - target_link_options(external_qt - INTERFACE - -Wl,-wrap,__divmoddi4 - ) - endif() - endif() target_link_static_libraries(external_qt INTERFACE proxy @@ -335,13 +315,6 @@ else() $ ) endif() - if (DESKTOP_APP_USE_GLIBC_WRAPS) - target_link_libraries(external_qt - INTERFACE - desktop-app::linux_glibc_wraps - $ - ) - endif() if (Qt5WaylandClient_FOUND) target_link_libraries(external_qt INTERFACE diff --git a/linux_glibc_wraps/CMakeLists.txt b/linux_glibc_wraps/CMakeLists.txt deleted file mode 100644 index 49a4329..0000000 --- a/linux_glibc_wraps/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# This file is part of Desktop App Toolkit, -# a set of libraries for developing nice desktop applications. -# -# For license and copyright information please follow this link: -# https://github.com/desktop-app/legal/blob/master/LEGAL - -add_library(linux_glibc_wraps STATIC) -add_library(desktop-app::linux_glibc_wraps ALIAS linux_glibc_wraps) - -get_filename_component(src_loc . REALPATH) - -nice_target_sources(linux_glibc_wraps ${src_loc} -PRIVATE - platform/linux/linux_glibc_wraps.c - platform/linux/linux_glibc_wraps_32.c - platform/linux/linux_glibc_wraps_64.c -) -if (NOT build_linux32) - set_source_files_properties(${src_loc}/platform/linux/linux_glibc_wraps_32.c PROPERTIES HEADER_FILE_ONLY TRUE) -else() - set_source_files_properties(${src_loc}/platform/linux/linux_glibc_wraps_64.c PROPERTIES HEADER_FILE_ONLY TRUE) -endif() diff --git a/linux_glibc_wraps/platform/linux/linux_glibc_wraps.c b/linux_glibc_wraps/platform/linux/linux_glibc_wraps.c deleted file mode 100644 index 1770ab1..0000000 --- a/linux_glibc_wraps/platform/linux/linux_glibc_wraps.c +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of Desktop App Toolkit, -// a set of libraries for developing nice desktop applications. -// -// For license and copyright information please follow this link: -// https://github.com/desktop-app/legal/blob/master/LEGAL -// -#include -#include -#include - -void *__wrap_aligned_alloc(size_t alignment, size_t size) { - void *result = NULL; - return (posix_memalign(&result, alignment, size) == 0) - ? result - : NULL; -} - -int enable_secure_inited = 0; -int enable_secure = 1; - -char *__wrap_secure_getenv(const char *name) { - if (enable_secure_inited == 0) { - enable_secure_inited = 1; - enable_secure = (geteuid() != getuid()) - || (getegid() != getgid()); - } - return enable_secure ? NULL : getenv(name); -} - diff --git a/linux_glibc_wraps/platform/linux/linux_glibc_wraps_32.c b/linux_glibc_wraps/platform/linux/linux_glibc_wraps_32.c deleted file mode 100644 index 2a0890f..0000000 --- a/linux_glibc_wraps/platform/linux/linux_glibc_wraps_32.c +++ /dev/null @@ -1,49 +0,0 @@ -// This file is part of Desktop App Toolkit, -// a set of libraries for developing nice desktop applications. -// -// For license and copyright information please follow this link: -// https://github.com/desktop-app/legal/blob/master/LEGAL -// -#include -#include - -#if defined(_M_IX86) || defined(__i386__) -#define GETTIME_GLIBC_VERSION "2.2" -#elif defined(_M_ARM) || defined(__arm__) -#define GETTIME_GLIBC_VERSION "2.4" -#else -#error Please add glibc wraps for your architecture -#endif - -int __clock_gettime_glibc_old(clockid_t clk_id, struct timespec *tp); -__asm__(".symver __clock_gettime_glibc_old,clock_gettime@GLIBC_" GETTIME_GLIBC_VERSION); - -int __wrap_clock_gettime(clockid_t clk_id, struct timespec *tp) { - return __clock_gettime_glibc_old(clk_id, tp); -} - -uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p); - -int64_t __wrap___divmoddi4(int64_t num, int64_t den, int64_t *rem_p) { - int minus = 0; - int64_t v; - - if (num < 0) { - num = -num; - minus = 1; - } - if (den < 0) { - den = -den; - minus ^= 1; - } - - v = __udivmoddi4(num, den, (uint64_t *)rem_p); - if (minus) { - v = -v; - if (rem_p) - *rem_p = -(*rem_p); - } - - return v; -} - diff --git a/linux_glibc_wraps/platform/linux/linux_glibc_wraps_64.c b/linux_glibc_wraps/platform/linux/linux_glibc_wraps_64.c deleted file mode 100644 index 2d1ca15..0000000 --- a/linux_glibc_wraps/platform/linux/linux_glibc_wraps_64.c +++ /dev/null @@ -1,52 +0,0 @@ -// This file is part of Desktop App Toolkit, -// a set of libraries for developing nice desktop applications. -// -// For license and copyright information please follow this link: -// https://github.com/desktop-app/legal/blob/master/LEGAL -// -#include - -#if defined(_M_X64) || defined(__x86_64__) -#define GETTIME_GLIBC_VERSION "2.2.5" -#elif defined(__aarch64__) -#define GETTIME_GLIBC_VERSION "2.17" -#else -#error Please add glibc wraps for your architecture -#endif - -typedef unsigned int UTItype __attribute__ ((mode (TI))); -typedef int TItype __attribute__ ((mode (TI))); - -int __clock_gettime_glibc_old(clockid_t clk_id, struct timespec *tp); -__asm__(".symver __clock_gettime_glibc_old,clock_gettime@GLIBC_" GETTIME_GLIBC_VERSION); - - -int __wrap_clock_gettime(clockid_t clk_id, struct timespec *tp) { - return __clock_gettime_glibc_old(clk_id, tp); -} - -UTItype __udivmodti4(UTItype num, UTItype den, UTItype *rem_p); - -TItype __wrap___divmodti4(TItype num, TItype den, TItype *rem_p) { - int minus = 0; - TItype v; - - if (num < 0) { - num = -num; - minus = 1; - } - if (den < 0) { - den = -den; - minus ^= 1; - } - - v = __udivmodti4(num, den, (UTItype *)rem_p); - if (minus) { - v = -v; - if (rem_p) - *rem_p = -(*rem_p); - } - - return v; -} - diff --git a/variables.cmake b/variables.cmake index 5c19c2c..80c336a 100644 --- a/variables.cmake +++ b/variables.cmake @@ -32,7 +32,6 @@ option(DESKTOP_APP_DISABLE_DBUS_INTEGRATION "Disable all code for D-Bus integrat option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration (Linux only)." OFF) option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration (Linux only)." OFF) option(DESKTOP_APP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." OFF) -option(DESKTOP_APP_USE_GLIBC_WRAPS "Use wraps for new GLIBC features." OFF) option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer (Linux only)." OFF) option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ${no_special_target}) option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF)