summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-08-23 11:13:09 +0200
committerattilamolnar <attilamolnar@hush.com>2013-09-08 17:21:37 +0200
commitba7431b4fd6c62dd04d252e769e825769accb2a9 (patch)
treebd136fbb263d2bed7d0b57b63aa61686f4ad19a5
parentdeb18ee9cfa531a87141aea61171c6899ef7d687 (diff)
Hide all symbols that aren't exported explicitly
In addition to reducing the sizes of all binaries this also helps the optimizer
-rw-r--r--include/compat.h4
-rw-r--r--include/hashcomp.h4
-rw-r--r--include/modules.h2
-rw-r--r--include/protocol.h2
-rw-r--r--make/template/main.mk6
5 files changed, 11 insertions, 7 deletions
diff --git a/include/compat.h b/include/compat.h
index 1cdad06c2..0357f5478 100644
--- a/include/compat.h
+++ b/include/compat.h
@@ -111,6 +111,6 @@
#else
# include <unistd.h>
# define ENTRYPOINT int main(int argc, char** argv)
-# define DllExport
-# define CoreExport
+# define DllExport __attribute__ ((visibility ("default")))
+# define CoreExport __attribute__ ((visibility ("default")))
#endif
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 51570978a..ec1cc5764 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -118,8 +118,8 @@ namespace irc
* This class is used to implement irc::string, a case-insensitive, RFC-
* comparing string class.
*/
- struct irc_char_traits : std::char_traits<char> {
-
+ struct CoreExport irc_char_traits : public std::char_traits<char>
+ {
/** Check if two chars match.
* @param c1st First character
* @param c2nd Second character
diff --git a/include/modules.h b/include/modules.h
index e8f0d10fe..d7b46ad48 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1428,7 +1428,7 @@ struct AllModuleList {
{ \
return new y; \
} \
- extern "C" const char inspircd_src_version[] = VERSION " " REVISION;
+ extern "C" DllExport const char inspircd_src_version[] = VERSION " " REVISION;
#endif
#define COMMAND_INIT(c) MODULE_INIT(CommandModule<c>)
diff --git a/include/protocol.h b/include/protocol.h
index 6af0ed21c..e474dd095 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -26,7 +26,7 @@ class User;
typedef std::vector<std::string> parameterlist;
-class ProtocolInterface
+class CoreExport ProtocolInterface
{
public:
class ServerInfo
diff --git a/make/template/main.mk b/make/template/main.mk
index bdb4d9762..d82e8b27e 100644
--- a/make/template/main.mk
+++ b/make/template/main.mk
@@ -35,7 +35,7 @@ COMPILER = @COMPILER@
SYSTEM = @SYSTEM@
BUILDPATH = @BUILD_DIR@
SOCKETENGINE = @SOCKETENGINE@
-CORECXXFLAGS = -fPIC -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
+CORECXXFLAGS = -fPIC -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
LDLIBS = -lstdc++
CORELDFLAGS = -rdynamic -L. $(LDFLAGS)
PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS)
@@ -54,6 +54,10 @@ INSTMODE_LIB = 0640
CORECXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute
@ENDIF
+@IFNEQ $(SYSTEM)-$(COMPILER) darwin-gcc
+ CORECXXFLAGS += -fvisibility=hidden
+@ENDIF
+
@IFNEQ $(SYSTEM) darwin
LDLIBS += -pthread
@ENDIF