From db6b2225b186e6254443e00bc04b43664bf96d39 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 3 Jan 2022 23:42:12 +0000 Subject: [PATCH] Use GNU visibility attributes when on non-Windows. This reduces binary sizes by several megabytes on my system. --- CMakeLists.txt | 2 +- include/services.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfaa69efe..157d9fc36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,7 +188,7 @@ if(MSVC) # Otherwise, we're not using Visual Studio else() # Set the compile flags to have all warnings on (including shadowed variables) - set(CXXFLAGS "${CXXFLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter ${CMAKE_CXX_FLAGS}") + set(CXXFLAGS "${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wpedantic -Wno-unused-parameter ${CMAKE_CXX_FLAGS}") # Also, if we are building under MinGW, add another define for MinGW if(MINGW) add_definitions(-DMINGW) diff --git a/include/services.h b/include/services.h index d6d98adcf..823aad8a3 100644 --- a/include/services.h +++ b/include/services.h @@ -51,8 +51,8 @@ #define _(x) x #ifndef _WIN32 -# define DllExport -# define CoreExport +# define DllExport __attribute__ ((visibility ("default"))) +# define CoreExport __attribute__ ((visibility ("default"))) # define anope_close close #else # include "anope_windows.h"