Commit f9ab5d2c authored by Dick Hollenbeck's avatar Dick Hollenbeck

Add -fvisibility options to significantly reduce binary sizes.

Switch to boost::context for all platforms, almost.
Please try your platform by commenting out fcontext.s in common/CMakeLists.txt.
parent cae7a6ff
......@@ -114,6 +114,14 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG" )
if( GXX_HAS_VISIBILITY_FLAG )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden" )
endif()
if( GXX_HAS_VISIBILITY_INLINES_FLAG )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" )
endif()
if( MINGW )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
......@@ -132,8 +140,8 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
# Disable this response file for includes ( See Windows-GNU.cmake module )
if( WIN32 AND MSYS AND NOT CMAKE_CROSSCOMPILING )
# fixme: it is needed only with MSYS+MINGW32? or always under MINGW
if (${CMAKE_SIZEOF_VOID_P} MATCHES 4)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0)
if( ${CMAKE_SIZEOF_VOID_P} MATCHES 4 )
set( CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0 )
endif()
endif()
......@@ -160,13 +168,13 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs" )
endif()
if( APPLE )
if( APPLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__ASSERTMACROS__" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ASSERTMACROS__" )
endif()
endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( KICAD_KEEPCASE )
add_definitions( -DKICAD_KEEPCASE )
......@@ -251,7 +259,7 @@ include( Functions )
include( ExternalProject )
if ( APPLE )
if ( APPLE )
set( KICAD_BUILD_STATIC ON)
if( NOT CMAKE_CXX_COMPILER )
......@@ -286,13 +294,13 @@ if ( KICAD_BUILD_STATIC )
set( PKG_CONFIG_EXECUTABLE "${PKGCONFIG_ROOT}/bin/pkg-config")
include( download_glew )
set( GLEW_GLEW_LIBRARY "${GLEW_ROOT}/lib/libGLEW.a")
set( GLEW_INCLUDE_DIR "${GLEW_ROOT}/include")
set( GLEW_INCLUDE_DIR "${GLEW_ROOT}/include")
include( download_pixman )
set( PIXMAN_LIBRARY "${PIXMAN_ROOT}/lib/libpixman-1.a")
include( download_libpng )
include( download_cairo )
set( CAIRO_INCLUDE_DIR "${CAIRO_ROOT}/include/cairo")
set( CAIRO_LIBRARY "${CAIRO_ROOT}/lib/libcairo.a")
set( CAIRO_LIBRARY "${CAIRO_ROOT}/lib/libcairo.a")
endif( KICAD_BUILD_STATIC )
#####################
......
......@@ -36,17 +36,21 @@
# Consider it a benchmark when writing your own feature tests.
#
macro(perform_feature_checks)
macro( perform_feature_checks )
include(CheckIncludeFile)
#include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckIncludeFileCXX)
include(CheckCXXSymbolExists)
include(CheckCXXSourceCompiles)
include( CheckIncludeFile )
#include( CheckFunctionExists )
include( CheckLibraryExists )
include( CheckSymbolExists )
include( CheckIncludeFileCXX )
include( CheckCXXSymbolExists )
include( CheckCXXSourceCompiles )
include( CheckCXXCompilerFlag )
check_include_file("malloc.h" HAVE_MALLOC_H)
check_cxx_compiler_flag( -fvisibility=hidden GXX_HAS_VISIBILITY_FLAG )
check_cxx_compiler_flag( -fvisibility-inlines-hidden GXX_HAS_VISIBILITY_INLINES_FLAG )
check_include_file( "malloc.h" HAVE_MALLOC_H )
# FIXME: Visual C++ does not support the "not" keyword natively. It is
# defined as a macro in <iso646.h>. There should be a cmake macro
......@@ -54,7 +58,7 @@ macro(perform_feature_checks)
# then check for <iso646.h> and include it. Although it doesn't
# appear to cause any problems with other compilers, that doesn't
# mean won't fail somewhere down the line.
check_include_file("iso646.h" HAVE_ISO646_H)
check_include_file( "iso646.h" HAVE_ISO646_H )
# The STDINT header file test is required because MinGW under Windows
# doesn't define HAVE_STDINT_H even though it does have it.
......@@ -62,7 +66,7 @@ macro(perform_feature_checks)
# We need to add it to the global compiler definitions as config.h is not
# included in pyport.h which is where the problem ocurrs without this
# fix.
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file( "stdint.h" HAVE_STDINT_H )
if( HAVE_STDINT_H )
add_definitions( -DHAVE_STDINT_H )
......@@ -73,40 +77,41 @@ macro(perform_feature_checks)
# re-introduce this.
# check_include_file("strings.h" HAVE_STRINGS_H)
check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP)
check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP)
check_symbol_exists(strncasecmp "string.h" HAVE_STRNCASECMP)
check_symbol_exists(strncasecmp "strings.h" HAVE_STRNCASECMP)
check_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP )
check_symbol_exists( strcasecmp "strings.h" HAVE_STRCASECMP )
check_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP )
check_symbol_exists( strncasecmp "strings.h" HAVE_STRNCASECMP )
check_symbol_exists( strtok_r "string.h" HAVE_STRTOKR )
# Some platforms define malloc and free in malloc.h instead of stdlib.h.
check_symbol_exists(malloc "stdlib.h" MALLOC_IN_STDLIB_H)
check_symbol_exists( malloc "stdlib.h" MALLOC_IN_STDLIB_H )
# Check for functions in math.h.
check_include_file("math.h" HAVE_MATH_H)
check_include_file( "math.h" HAVE_MATH_H )
# Check for functions in C++ cmath.
check_include_file_cxx(cmath HAVE_CXX_CMATH)
check_cxx_symbol_exists(asinh cmath HAVE_CMATH_ASINH )
check_cxx_symbol_exists(acosh cmath HAVE_CMATH_ACOSH )
check_cxx_symbol_exists(atanh cmath HAVE_CMATH_ATANH )
check_include_file_cxx( cmath HAVE_CXX_CMATH )
check_cxx_symbol_exists( asinh cmath HAVE_CMATH_ASINH )
check_cxx_symbol_exists( acosh cmath HAVE_CMATH_ACOSH )
check_cxx_symbol_exists( atanh cmath HAVE_CMATH_ATANH )
# CMakes check_cxx_symbol_exists() doesn't work for templates so we must create a
# small program to verify isinf() exists in cmath.
check_cxx_source_compiles( "#include <cmath>\nint main(int argc, char** argv)\n{\n (void)argv;\n std::isinf(1.0); (void)argc;\n return 0;\n}\n" HAVE_CMATH_ISINF )
#check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) non-standard library, does not work
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
#check_symbol_exists( clock_gettime "time.h" HAVE_CLOCK_GETTIME ) non-standard library, does not work
check_library_exists( rt clock_gettime "" HAVE_CLOCK_GETTIME )
# HAVE_GETTIMEOFDAY is already in use within 2.9 wxWidgets, so use HAVE_GETTIMEOFDAY_FUNC
check_symbol_exists(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY_FUNC)
check_symbol_exists( gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY_FUNC )
# Check for Posix getc_unlocked() for improved performance over getc(). Fall back to
# getc() on platforms where getc_unlocked() doesn't exist.
check_symbol_exists(getc_unlocked "stdio.h" HAVE_FGETC_NOLOCK)
check_symbol_exists( getc_unlocked "stdio.h" HAVE_FGETC_NOLOCK )
# Generate config.h.
configure_file(${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
${CMAKE_BINARY_DIR}/config.h)
configure_file( ${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
${CMAKE_BINARY_DIR}/config.h
)
endmacro(perform_feature_checks)
endmacro( perform_feature_checks )
......@@ -41,14 +41,9 @@ set( BOOST_ROOT "${PROJECT_SOURCE_DIR}/boost_root" )
# Chosen libraries are based on AVHTTP requirements, and possibly
# unit_test_framework for its own worth.
# tool_manager.cpp -> coroutine -> context (_jump_fcontext) (on OSX)
if( APPLE )
set( BOOST_EXTRA_LIBS "context" )
else()
set( BOOST_EXTRA_LIBS "" )
endif()
set( BOOST_LIBS_BUILT
${BOOST_EXTRA_LIBS}
context
#coroutine
date_time
#exception
......@@ -98,9 +93,9 @@ string( REPLACE "unit_test_framework" "test" boost_libs_list "${BOOST_LIBS_BUILT
set( BOOST_TOOLSET "toolset=gcc" )
if( KICAD_BUILD_STATIC )
set(BOOST_LINKTYPE "link=static")
set( BOOST_LINKTYPE "link=static" )
else()
set( BOOST_LINKTYPE "#link=static")
unset( BOOST_LINKTYPE )
endif()
......@@ -129,14 +124,15 @@ else()
unset( b2_libs )
endif()
if( APPLE )
# I set this to being compatible with wxWidgets
# wxWidgets still using libstdc++ (gcc), meanwhile OSX
# has switched to libc++ (llvm) by default
set(BOOST_CXXFLAGS "cxxflags=-mmacosx-version-min=10.5 -fno-common" )
set(BOOST_LINKFLAGS "linkflags=-mmacosx-version-min=10.5 -fno-common" )
set(BOOST_TOOLSET "toolset=darwin" )
set( BOOST_CXXFLAGS "cxxflags=-mmacosx-version-min=10.5 -fno-common" )
set( BOOST_LINKFLAGS "linkflags=-mmacosx-version-min=10.5 -fno-common" )
set( BOOST_TOOLSET "toolset=darwin" )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(BOOST_CXXFLAGS "${BOOST_CXXFLAGS} -fno-lto" )
set(BOOST_LINKFLAGS "${BOOST_LINKFLAGS} -fno-lto" )
......@@ -146,9 +142,9 @@ if( APPLE )
if( (CMAKE_OSX_ARCHITECTURES MATCHES "386" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc ") AND
(CMAKE_OSX_ARCHITECTURES MATCHES "64"))
message("-- BOOST found 32/64 Address Model")
message( "-- BOOST found 32/64 Address Model" )
set(BOOST_ADDRESSMODEL "address-model=32_64")
set( BOOST_ADDRESSMODEL "address-model=32_64" )
endif()
if( (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "386") AND
......@@ -166,9 +162,9 @@ if( APPLE )
set(BOOST_ARCHITECTURE "architecture=ppc")
endif()
set(BOOST_CFLAGS "${BOOST_CFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
set(BOOST_CXXFLAGS "${BOOST_CXXFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
set(BOOST_LINKFLAGS "${BOOST_LINKFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
set( BOOST_CFLAGS "${BOOST_CFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
set( BOOST_CXXFLAGS "${BOOST_CXXFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
set( BOOST_LINKFLAGS "${BOOST_LINKFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" )
endif()
endif()
......@@ -187,9 +183,21 @@ ExternalProject_Add( boost
# PATCH_COMMAND continuation (any *_COMMAND here can be continued with COMMAND):
COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost_minkowski.patch"
COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost_cstdint.patch"
COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost_macosx_x86.patch" #https://svn.boost.org/trac/boost/ticket/8266
# tell bzr about new files added by last patch so above "bzr revert" works:
COMMAND bzr add libs/context/src/asm/jump_i386_x86_64_sysv_macho_gas.S
COMMAND bzr add libs/context/src/asm/make_i386_x86_64_sysv_macho_gas.S
COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost_macosx_x86_build.patch" #https://svn.boost.org/trac/boost/ticket/8266
COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost_mingw.patch" #https://svn.boost.org/trac/boost/ticket/7262
# tell bzr about new files added by last patch so above "bzr revert" works:
COMMAND bzr add libs/context/src/asm/make_i386_ms_pe_gas.S
COMMAND bzr add libs/context/src/asm/jump_i386_ms_pe_gas.S
COMMAND bzr add libs/context/src/asm/make_x86_64_ms_pe_gas.S
COMMAND bzr add libs/context/src/asm/jump_x86_64_ms_pe_gas.S
# [Mis-]use this step to erase all the boost headers and libraries before
# replacing them below.
UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${BOOST_ROOT}"
......@@ -240,8 +248,8 @@ endif()
set( boost_libs "" )
set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs )
set( Boost_LIBRARIES ${boost_libs} CACHE FILEPATH "Boost libraries directory" )
set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" CACHE FILEPATH "Boost include directory" )
set( Boost_LIBRARIES ${boost_libs} )
set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" )
mark_as_advanced( Boost_LIBRARIES Boost_INCLUDE_DIR )
......
include_directories(BEFORE ${INC_BEFORE})
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
./dialogs
./dialog_about
......@@ -62,7 +62,7 @@ if(WIN32 AND MSYS)
add_definitions(-DGLEW_STATIC)
endif(WIN32 AND MSYS)
set(COMMON_ABOUT_DLG_SRCS
set( COMMON_ABOUT_DLG_SRCS
dialog_about/AboutDialog_main.cpp
dialog_about/dialog_about.cpp
dialog_about/dialog_about_base.cpp
......@@ -78,7 +78,7 @@ set(COMMON_ABOUT_DLG_SRCS
dialogs/dialog_page_settings_base.cpp
)
set(COMMON_PAGE_LAYOUT_SRCS
set( COMMON_PAGE_LAYOUT_SRCS
page_layout/title_block_shapes.cpp
page_layout/class_worksheet_dataitem.cpp
page_layout/class_worksheet_layout.cpp
......@@ -88,7 +88,7 @@ set(COMMON_PAGE_LAYOUT_SRCS
page_layout/page_layout_reader.cpp
)
set(COMMON_SRCS
set( COMMON_SRCS
${COMMON_ABOUT_DLG_SRCS}
${COMMON_PAGE_LAYOUT_SRCS}
base_struct.cpp
......@@ -153,17 +153,14 @@ if( NOT HAVE_STRTOKR )
set( COMMON_SRCS ${COMMON_SRCS} strtok_r.c )
endif()
enable_language(C CXX ASM)
set_source_files_properties(system/fcontext.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
set(COMMON_SRCS
set( COMMON_SRCS
${COMMON_SRCS}
view/view.cpp
view/view_item.cpp
view/view_group.cpp
math/math_util.cpp
system/fcontext.s
tool/tool_base.cpp
tool/tool_manager.cpp
......@@ -179,9 +176,19 @@ set(COMMON_SRCS
geometry/shape_index.cpp
)
add_library(common STATIC ${COMMON_SRCS})
# TODO: remove this whole if test and remove the sytem/*.s sources once every platform is tested with
# boost::context library
if( UNIX AND NOT APPLE )
else()
enable_language( C CXX ASM )
set_source_files_properties( system/fcontext.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp" )
list( APPEND COMMON_SRCS system/fcontext.s )
endif()
add_library( common STATIC ${COMMON_SRCS} )
set(PCB_COMMON_SRCS
set( PCB_COMMON_SRCS
base_screen.cpp
eda_text.cpp
class_page_info.cpp
......@@ -235,7 +242,7 @@ set(PCB_COMMON_SRCS
fp_lib_table.cpp
)
set(PCB_COMMON_SRCS
set( PCB_COMMON_SRCS
${PCB_COMMON_SRCS}
../pcbnew/pcb_painter.cpp
)
......@@ -245,7 +252,7 @@ set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
COMPILE_DEFINITIONS "PCBNEW"
)
add_library(pcbcommon STATIC ${PCB_COMMON_SRCS})
add_library( pcbcommon STATIC ${PCB_COMMON_SRCS} )
# auto-generate specctra_lexer.h and specctra_keywords.cpp
make_lexer(
......
install(DIRECTORY complex_hierarchy ecc83 electric flat_hierarchy
kit-dev-coldfire-xilinx_5213 interf_u microwave
pic_programmer pspice "sonde xilinx" test_xil_95108 video
DESTINATION ${KICAD_DEMOS}
COMPONENT resources
PATTERN ".svn" EXCLUDE)
install( DIRECTORY complex_hierarchy
ecc83 electric flat_hierarchy
kit-dev-coldfire-xilinx_5213 interf_u microwave
pic_programmer pspice "sonde xilinx" test_xil_95108 video
DESTINATION ${KICAD_DEMOS}
COMPONENT resources
)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment