From: Emil Velikov Date: Wed, 30 Aug 2017 14:12:14 +0000 (+0100) Subject: Use hidden visibility with GCC and Clang X-Git-Tag: upstream/0.1.0^2^2~9^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fa7ebccc4159f4031ee7dde183b5714521b8b66;p=platform%2Fupstream%2FVK-GL-CTS.git Use hidden visibility with GCC and Clang The final result of the build are standalone executables, with all the code statically linked. Change the visibility to hidden, to avoid the symbol leakage and allow the compiler to discard some code. As a result the binary size is drastically decreased. Total executable size on my setup drops by ~20% 158M before 128M after Note: The binaries still export multiple unneeded symbols. Resolving those is left as an exercise for later. Test: full rebuild, running resulting binaries. Change-Id: Ife10bbd123d59f4480349794785f13978516df30 Signed-off-by: Emil Velikov --- diff --git a/framework/delibs/cmake/CFlags.cmake b/framework/delibs/cmake/CFlags.cmake index 8a4b9ad..bcb11ab 100644 --- a/framework/delibs/cmake/CFlags.cmake +++ b/framework/delibs/cmake/CFlags.cmake @@ -53,6 +53,11 @@ if (DE_COMPILER_IS_GCC OR DE_COMPILER_IS_CLANG) # Turn on -Wstrict-overflow=5 and check all warnings before removing set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fwrapv") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fwrapv") + + # Force compiler to not export any symbols. + # Any static libraries build are linked into the standalone executable binaries. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") elseif (DE_COMPILER_IS_MSC) # Compiler flags for msc