Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Enable link-time optimization for release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Jul 31, 2018
1 parent c77aa79 commit 697e19c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions platform/ios/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ macro(initialize_ios_target target)
set_xcode_property(${target} ENABLE_BITCODE "YES")
set_xcode_property(${target} BITCODE_GENERATION_MODE bitcode)
set_xcode_property(${target} ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
set_xcode_property(${target} LLVM_LTO $<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebugInfo>>:YES>)

target_compile_options(${target}
PRIVATE -fobjc-arc
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3781,6 +3781,7 @@
INFOPLIST_FILE = framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LLVM_LTO = YES;
OTHER_CFLAGS = "-fvisibility=hidden";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
Expand Down Expand Up @@ -3866,6 +3867,7 @@
"$(mbgl_core_INCLUDE_DIRECTORIES)",
"$(mbgl_filesource_LINK_LIBRARIES)",
);
LLVM_LTO = YES;
OTHER_CFLAGS = "-fvisibility=hidden";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
Expand Down
21 changes: 21 additions & 0 deletions platform/macos/config.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11)

macro(initialize_macos_target target)
set_xcode_property(${target} LLVM_LTO $<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebugInfo>>:YES>)
endmacro()

include(cmake/loop-darwin.cmake)
initialize_macos_target(mbgl-loop-darwin)

macro(mbgl_platform_core)
initialize_macos_target(mbgl-core)

target_sources(mbgl-core
# Misc
PRIVATE platform/darwin/mbgl/storage/reachability.h
Expand Down Expand Up @@ -67,6 +74,8 @@ endmacro()


macro(mbgl_filesource)
initialize_macos_target(mbgl-filesource)

target_sources(mbgl-filesource
# File source
PRIVATE platform/darwin/src/http_file_source.mm
Expand All @@ -87,6 +96,8 @@ endmacro()


macro(mbgl_platform_glfw)
initialize_macos_target(mbgl-glfw)

target_link_libraries(mbgl-glfw
PRIVATE mbgl-filesource
PRIVATE mbgl-loop-darwin
Expand All @@ -95,6 +106,8 @@ endmacro()


macro(mbgl_platform_render)
initialize_macos_target(mbgl-render)

target_link_libraries(mbgl-render
PRIVATE mbgl-filesource
PRIVATE mbgl-loop-darwin
Expand All @@ -103,6 +116,8 @@ endmacro()


macro(mbgl_platform_offline)
initialize_macos_target(mbgl-offline)

target_link_libraries(mbgl-offline
PRIVATE mbgl-filesource
PRIVATE mbgl-loop-darwin
Expand All @@ -111,6 +126,8 @@ endmacro()


macro(mbgl_platform_test)
initialize_macos_target(mbgl-test)

target_sources(mbgl-test
PRIVATE platform/default/mbgl/test/main.cpp
)
Expand All @@ -132,6 +149,8 @@ macro(mbgl_platform_test)
endmacro()

macro(mbgl_platform_benchmark)
initialize_macos_target(mbgl-benchmark)

target_sources(mbgl-benchmark
PRIVATE benchmark/src/main.cpp
)
Expand All @@ -149,6 +168,8 @@ macro(mbgl_platform_benchmark)
endmacro()

macro(mbgl_platform_node)
initialize_macos_target(mbgl-node)

target_link_libraries(mbgl-node INTERFACE
-exported_symbols_list ${CMAKE_SOURCE_DIR}/platform/node/symbol-list
-dead_strip
Expand Down
1 change: 1 addition & 0 deletions platform/macos/macos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,7 @@
INFOPLIST_FILE = "$(SRCROOT)/sdk/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
LLVM_LTO = YES;
OTHER_CFLAGS = "-fvisibility=hidden";
OTHER_LDFLAGS = (
"$(mbgl_core_LINK_LIBRARIES)",
Expand Down

0 comments on commit 697e19c

Please sign in to comment.