Browse Source

Merge pull request #1887 from MikuAuahDark/visibility

Compile with hidden symbol visibility by default.
Sasha Szpakowski 2 years ago
parent
commit
7876955001
2 changed files with 7 additions and 1 deletions
  1. 4 0
      platform/unix/configure.ac
  2. 3 1
      src/common/config.h

+ 4 - 0
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])

+ 3 - 1
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