Commit f9ab5d2c authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

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
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -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" )

+33 −28
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ macro(perform_feature_checks)
    include( CheckIncludeFileCXX )
    include( CheckCXXSymbolExists )
    include( CheckCXXSourceCompiles )
    include( CheckCXXCompilerFlag )

    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 )

@@ -107,6 +111,7 @@ macro(perform_feature_checks)

    # Generate config.h.
    configure_file( ${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
                   ${CMAKE_BINARY_DIR}/config.h)
        ${CMAKE_BINARY_DIR}/config.h
        )

endmacro( perform_feature_checks )
+27 −19
Original line number Diff line number Diff line
@@ -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
@@ -100,7 +95,7 @@ set( BOOST_TOOLSET "toolset=gcc" )
if( KICAD_BUILD_STATIC )
    set( BOOST_LINKTYPE  "link=static" )
else()
    set( BOOST_LINKTYPE "#link=static")
    unset( BOOST_LINKTYPE )
endif()


@@ -129,6 +124,7 @@ else()
    unset( b2_libs )
endif()


if( APPLE )
    # I set this to being compatible with wxWidgets
    # wxWidgets still using libstdc++ (gcc), meanwhile OSX
@@ -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 )

+19 −12
Original line number Diff line number Diff line
@@ -153,8 +153,6 @@ 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
    ${COMMON_SRCS}
@@ -163,7 +161,6 @@ set(COMMON_SRCS
    view/view_group.cpp

    math/math_util.cpp
    system/fcontext.s

    tool/tool_base.cpp
    tool/tool_manager.cpp
@@ -179,6 +176,16 @@ set(COMMON_SRCS
    geometry/shape_index.cpp
)

# 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
+7 −6
Original line number Diff line number Diff line
install(DIRECTORY complex_hierarchy ecc83 electric flat_hierarchy
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)
    )
Loading