Enable -fvisibility=hidden on static libraries by default.

Only on non-GCC2 for now, as GCC2 does not have -fvisibility.

An opt-out is left as a possibility, and is unfortunately necessary
for libshared and libicon, as these two are used even in WebKit instead
of linking to the .a. However, libcolumnlistview, libagg, and a whole
bunch of others are now no longer exported, so this is already a major
improvement on what symbols we were leaking.

This may provide performance differences for consumers of these APIs,
as GCC and the linker are now free to merge and directly use functions
that previously could have been semantically interposed. AGG usage in
app_server, especially, may benefit.

We can also now remove the addition from libnetservices, so do that.
This commit is contained in:
Augustin Cavalier
2021-09-08 17:32:47 -04:00
parent 03980b1fb0
commit 37ea891aad
7 changed files with 21 additions and 7 deletions
+6
View File
@@ -154,6 +154,12 @@ rule StaticLibrary
InheritPlatform $(objects) : $(lib) ; InheritPlatform $(objects) : $(lib) ;
if $(TARGET_CC_IS_LEGACY_GCC_$(TARGET_PACKAGING_ARCH)) = 0
&& [ on $(lib) return $(NO_HIDDEN_VISIBILITY) ] != 1 {
CCFLAGS on $(objects) += -fvisibility=hidden ;
C++FLAGS on $(objects) += -fvisibility=hidden ;
}
StaticLibraryFromObjects $(lib) : $(objects) $(otherObjects) ; StaticLibraryFromObjects $(lib) : $(objects) $(otherObjects) ;
Objects $(2) ; Objects $(2) ;
} }
+1
View File
@@ -92,6 +92,7 @@ BuildPlatformStaticLibrary libroot_build.a :
USES_BE_API on [ FGristFiles function_remapper$(SUFOBJ) ] = true ; USES_BE_API on [ FGristFiles function_remapper$(SUFOBJ) ] = true ;
NO_HIDDEN_VISIBILITY on <build>libroot_build_function_remapper.a = 1 ;
BuildPlatformStaticLibraryPIC libroot_build_function_remapper.a : BuildPlatformStaticLibraryPIC libroot_build_function_remapper.a :
function_remapper.cpp function_remapper.cpp
; ;
@@ -54,13 +54,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
: <$(architecture)>libshared.a : <$(architecture)>libshared.a
; ;
} else { } else {
if $(HAIKU_CC_IS_LEGACY_GCC_$(architecture)) = 0 {
# In order to not have conflicts between libraries built against
# different versions of libnetservices.a, prevent symbols from
# being re-exported from the static library.
SubDirC++Flags -fvisibility=hidden ;
}
StaticLibrary [ MultiArchDefaultGristFiles libnetservices.a ] : StaticLibrary [ MultiArchDefaultGristFiles libnetservices.a ] :
$(sources) $(sources)
Geolocation.cpp Geolocation.cpp
+4
View File
@@ -24,6 +24,10 @@ for architectureObject in [ MultiArchSubDirSetup ] {
# for BKeymap # for BKeymap
UsePrivateHeaders interface ; UsePrivateHeaders interface ;
# FIXME: These symbols should be hidden, but too many applications depend
# on them at present for that.
NO_HIDDEN_VISIBILITY on <$(architecture)>libshared.a = 1 ;
StaticLibrary <$(architecture)>libshared.a : StaticLibrary <$(architecture)>libshared.a :
AboutMenuItem.cpp AboutMenuItem.cpp
ArgumentVector.cpp ArgumentVector.cpp
+6
View File
@@ -20,12 +20,18 @@ UsePrivateHeaders shared ;
local architectureObject ; local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] { for architectureObject in [ MultiArchSubDirSetup ] {
on $(architectureObject) { on $(architectureObject) {
local architecture = $(TARGET_PACKAGING_ARCH) ;
local sourceDir ; local sourceDir ;
for sourceDir in $(sourceDirs) { for sourceDir in $(sourceDirs) {
SEARCH_SOURCE SEARCH_SOURCE
+= [ FDirName $(HAIKU_TOP) src libs icon $(sourceDir) ] ; += [ FDirName $(HAIKU_TOP) src libs icon $(sourceDir) ] ;
} }
# Too many applications depend on libicon APIs being visible in libbe;
# so for now, prevent -fvisiblity=hidden from being set.
NO_HIDDEN_VISIBILITY on [ MultiArchDefaultGristFiles libicon.a ] = 1 ;
StaticLibrary [ MultiArchDefaultGristFiles libicon.a ] : StaticLibrary [ MultiArchDefaultGristFiles libicon.a ] :
# flat_icon # flat_icon
FlatIconFormat.cpp FlatIconFormat.cpp
+2
View File
@@ -15,6 +15,8 @@ UseBuildFeatureHeaders freetype ;
Includes [ FGristFiles AlphaMask.cpp AlphaMaskCache.cpp DrawingEngine.cpp ] Includes [ FGristFiles AlphaMask.cpp AlphaMaskCache.cpp DrawingEngine.cpp ]
: [ BuildFeatureAttribute freetype : headers ] ; : [ BuildFeatureAttribute freetype : headers ] ;
NO_HIDDEN_VISIBILITY on libasdrawing.a = 1 ;
StaticLibrary libasdrawing.a : StaticLibrary libasdrawing.a :
AlphaMask.cpp AlphaMask.cpp
AlphaMaskCache.cpp AlphaMaskCache.cpp
+2
View File
@@ -23,6 +23,8 @@ local sources =
Includes [ FGristFiles $(sources) ] Includes [ FGristFiles $(sources) ]
: [ BuildFeatureAttribute freetype : headers ] ; : [ BuildFeatureAttribute freetype : headers ] ;
NO_HIDDEN_VISIBILITY on libstackandtile.a = 1 ;
StaticLibrary libstackandtile.a : StaticLibrary libstackandtile.a :
$(sources) $(sources)
; ;