From c342339fee183a7d78fcba534f3a8c3801ff9b5c Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Wed, 28 Dec 2022 13:51:08 +0800 Subject: [PATCH 1/4] Define LOVE_EXPORT on non-Windows. With GCC or Clang, LOVE_EXPORT is defined as __attribute__((visibility("default"))). --- src/common/config.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/config.h b/src/common/config.h index 5aef35faa..150bd24ef 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -104,8 +104,10 @@ #endif // DLL-stuff. -#ifdef LOVE_WINDOWS +#if defined(_MSC_VER) # define LOVE_EXPORT __declspec(dllexport) +#elif defined(__GNUC__) || defined(__clang__) +# define LOVE_EXPORT __attribute__((visibility("default"))) #else # define LOVE_EXPORT #endif From bfcb6c66439153ae78ca560f8080932a039a6379 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Wed, 28 Dec 2022 13:51:21 +0800 Subject: [PATCH 2/4] Compile with -fvisibility=hidden by default. This gives around 1MB size reduction. --- platform/unix/configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/unix/configure.ac b/platform/unix/configure.ac index 89ad64b69..4f4a47a3d 100644 --- a/platform/unix/configure.ac +++ b/platform/unix/configure.ac @@ -29,6 +29,10 @@ AC_DEFUN([LOVE_MSG_ERROR], # C++11 support in cpp11.m4 ACLOVE_CPP11_TEST +# Add -fvisibility=hidden and -fvisibility-inlines-hidden +CFLAGS="-fvisibility=hidden $CFLAGS" +CPPFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden $CPPFLAGS" + # Allow people on OSX to use autotools, they need their platform files AC_ARG_ENABLE([osx], AC_HELP_STRING([--enable-osx], [Compile platform-specific files for OSX]), [], [enable_osx=no]) From b4e9731dfbab3c95cc6ba2a5b9bfca091eb8bde8 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Thu, 29 Dec 2022 10:27:52 -0400 Subject: [PATCH 3/4] Add LOVE_EXPORT to a couple macOS functions called from the exe. --- src/common/macosx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/macosx.h b/src/common/macosx.h index ff94eef42..37c2c1676 100644 --- a/src/common/macosx.h +++ b/src/common/macosx.h @@ -37,13 +37,13 @@ namespace macosx * in the main bundle (love.app.) * Returns an empty string if no love file is found. **/ -std::string getLoveInResources(); +LOVE_EXPORT std::string getLoveInResources(); /** * Checks for drop-file events. Returns the filepath if an event occurred, or * an empty string otherwise. **/ -std::string checkDropEvents(); +LOVE_EXPORT std::string checkDropEvents(); /** * Returns the full path to the executable. From 6730d57f042a5516e20a92999dd7ad6e615fe89c Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Thu, 29 Dec 2022 10:28:28 -0400 Subject: [PATCH 4/4] macOS: compile with symbols hidden by default. --- platform/xcode/liblove.xcodeproj/project.pbxproj | 3 +++ platform/xcode/love.xcodeproj/project.pbxproj | 3 +++ 2 files changed, 6 insertions(+) diff --git a/platform/xcode/liblove.xcodeproj/project.pbxproj b/platform/xcode/liblove.xcodeproj/project.pbxproj index a9e7bb610..1194b78b5 100644 --- a/platform/xcode/liblove.xcodeproj/project.pbxproj +++ b/platform/xcode/liblove.xcodeproj/project.pbxproj @@ -4931,6 +4931,7 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = LOVE_APPLE_USE_FRAMEWORKS; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; @@ -4996,6 +4997,7 @@ LOVE_APPLE_USE_FRAMEWORKS, "DEBUG=1", ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; @@ -5136,6 +5138,7 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = LOVE_APPLE_USE_FRAMEWORKS; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; diff --git a/platform/xcode/love.xcodeproj/project.pbxproj b/platform/xcode/love.xcodeproj/project.pbxproj index 4eeb2fb5b..2328e9b7c 100644 --- a/platform/xcode/love.xcodeproj/project.pbxproj +++ b/platform/xcode/love.xcodeproj/project.pbxproj @@ -535,6 +535,7 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = LOVE_APPLE_USE_FRAMEWORKS; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_NEWLINE = NO; @@ -607,6 +608,7 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = LOVE_APPLE_USE_FRAMEWORKS; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_NEWLINE = NO; @@ -840,6 +842,7 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = LOVE_APPLE_USE_FRAMEWORKS; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_NEWLINE = NO;