Hi Jeff,
I came across this webpage some time ago http://gcc.gnu.org/wiki/Visibility
and added the relevant attributes to a private version of shareLib.h:
=== modified file 'src/libCom/misc/shareLib.h'
--- src/libCom/misc/shareLib.h 2008-08-06 16:52:52 +0000
+++ src/libCom/misc/shareLib.h 2011-09-28 22:38:37 +0000
@@ -139,6 +139,24 @@
# define epicsShareDef
# define epicsShareAPI __stdcall /* function removes arguments */
# define READONLY const
+
+#elif __GNUC__ >= 4
+/*
+ * See http://gcc.gnu.org/wiki/Visibility
+ */
+
+# define epicsShareExtern __attribute__ ((visibility("default"))) extern
+# define epicsShareClass __attribute__ ((visibility("default")))
+# define epicsShareFunc __attribute__ ((visibility("default")))
+
+# define epicsShareDef
+# define epicsShareAPI
+# if defined(__STDC__) || defined (__cplusplus)
+# define READONLY const
+# else
+# define READONLY
+# endif
+
/*
* if its the old VAX C Compiler (not DEC C)
*/
When I enable it by adding the -fvisibility=hidden flag to gcc for a linux-
x86_64 build I get quite a reduction in teh number of exported symbols
(counted using 'nm -C -D | wc -l'):
Library Original Visibility
------- -------- ----------
libca.so.3.15 1427 370
libcas.so.3.15 1167 336
libCom.so.3.15 1340 905
libdbCore.so.3.15 974 692
libdbRecStd.so.3.15 253 178
libdbStaticHost.so.3.15 232 208
libgdd.so.3.15 323 249
This looks like it would be a very worthwhile addition, except I'm getting a
couple of build errors for the 3.15 branch, can you work out what needs
decorating?
make[5]: Entering directory
`/home/phoebus3/ANJ/epics/base/mirror-3.15/src/ca/legacy/pcas/example/directoryService/O.linux-
x86_64'
/home/phoebus/ANJ/Linux64/bin/g++ -o caDirServ -
L/home/phoebus3/ANJ/epics/base/mirror-3.15/lib/linux-x86_64 -Wl,-
rpath,/home/phoebus3/ANJ/epics/base/mirror-3.15/lib/linux-x86_64 -m64
main.o directoryServer.o -lcas -lca -lgdd -lCom
directoryServer.o:(.rodata._ZTI15directoryServer[typeinfo for
directoryServer]+0x10): undefined reference to `typeinfo for caServer'
/home/phoebus3/ANJ/epics/base/mirror-3.15/lib/linux-x86_64/libcas.so:
undefined reference to `typeinfo for fdReg'
I'm also not sure where to set the -fvisibility flag, because it's not
supported before gcc 4.0 — I'll check with Janet, but ideas welcome...
- Andrew
--
Optimization is the process of taking something that works and
replacing it with something that almost works, but costs less.
-- Roger Needham
- Replies:
- RE: gcc 4.x symbol visibility Jeff Hill
- Navigate by Date:
- Prev:
[Merge] lp:~strauman/epics-base/stacktrace into lp:epics-base Till Straumann
- Next:
RE: gcc 4.x symbol visibility Jeff Hill
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
[Merge] lp:~strauman/epics-base/stacktrace into lp:epics-base Till Straumann
- Next:
RE: gcc 4.x symbol visibility Jeff Hill
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|