You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2018/01/09 20:32:02 UTC
mesos git commit: Enabled function sections.
Repository: mesos
Updated Branches:
refs/heads/master 3290b401d -> ca7d00025
Enabled function sections.
If we tell the compiler to place each function in a separate
section, this allows the linker to garbage collect unused
sections. This significantly decreases the size of the final
build artifacts and provides some modest improvements in build
times.
Review: https://reviews.apache.org/r/64743/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ca7d0002
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ca7d0002
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ca7d0002
Branch: refs/heads/master
Commit: ca7d00025bd5325cb3cac36c2898a3d09c829176
Parents: 3290b40
Author: James Peach <jp...@apache.org>
Authored: Tue Jan 9 12:31:36 2018 -0800
Committer: James Peach <jp...@apache.org>
Committed: Tue Jan 9 12:31:36 2018 -0800
----------------------------------------------------------------------
cmake/CompilationConfigure.cmake | 24 +++++++++++++++++++++
configure.ac | 39 +++++++++++++++++++++++++++++++++++
docs/configuration/autotools.md | 9 ++++++++
docs/configuration/cmake.md | 9 ++++++++
4 files changed, 81 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ca7d0002/cmake/CompilationConfigure.cmake
----------------------------------------------------------------------
diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index 0ae0504..50cddf9 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+include(CMakePushCheckState)
+
# GENERAL OPTIONS.
##################
option(VERBOSE
@@ -255,6 +257,28 @@ if (NOT WIN32)
set(LIB_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/libmesos)
endif ()
+option(ENABLE_GC_UNUSED
+ "Enable garbage collection of unused program segments"
+ FALSE)
+
+if (ENABLE_GC_UNUSED)
+ CMAKE_PUSH_CHECK_STATE()
+
+ set(CMAKE_REQUIRED_FLAGS "-ffunction-sections -fdata-sections -Wl,--gc-sections")
+ CHECK_CXX_COMPILER_FLAG("" GC_FUNCTION_SECTIONS)
+ if (GC_FUNCTION_SECTIONS)
+ string(APPEND CMAKE_CXX_FLAGS " -ffunction-sections -fdata-sections")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--gc-sections")
+ else ()
+ message(
+ FATAL_ERROR
+ "The compiler ${CMAKE_CXX_COMPILER} does not support the necessary options to "
+ "enable garbage collection of unused sections.")
+ endif()
+
+ CMAKE_POP_CHECK_STATE()
+endif()
# LINUX CONFIGURATION.
######################
http://git-wip-us.apache.org/repos/asf/mesos/blob/ca7d0002/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index b6eb98b..5650d6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,6 +172,11 @@ AC_ARG_ENABLE([hardening],
protection and position independent library code]),
[], [enable_hardening=yes])
+AC_ARG_ENABLE([gc-unused],
+ AS_HELP_STRING([--enable-gc_unused],
+ [enable garbage collection of unused program segments]),
+ [], [enable_gc_unused=no])
+
AC_ARG_ENABLE([bundled],
AS_HELP_STRING([--disable-bundled],
[build against preinstalled dependencies instead
@@ -497,6 +502,40 @@ AS_IF([test "x$enable_lock_free_run_queue" = "xyes"],
# Check to see if we should harden or not.
AM_CONDITIONAL([ENABLE_HARDENING], [test x"$enable_hardening" = "xyes"])
+AC_MSG_CHECKING([whether to enable GC of unused sections])
+AC_MSG_RESULT([$enable_gc_unused])
+
+AS_IF([test "x$enable_gc_unused" = "xyes"], [
+ AC_LANG_PUSH([C++])
+ saved_CXXFLAGS="$CXXFLAGS"
+ saved_LDFLAGS="$LDFLAGS"
+
+ CXXFLAGS="-ffunction-sections -fdata-sections"
+ LDFLAGS="-Wl,--gc-sections"
+ AC_LINK_IFELSE(
+ [ AC_LANG_PROGRAM([], [return 0;]) ],
+ [],
+ [
+ AC_MSG_ERROR([cannot enable GC of unused sections
+-------------------------------------------------------------------
+The current toolchain does not support the necessary options to
+enable garbage collection of unused sections.
+-------------------------------------------------------------------
+ ])
+ ]
+ )
+
+ CXXFLAGS="$saved_CXXFLAGS"
+ LDFLAGS="$saved_LDFLAGS"
+ AC_LANG_POP()
+])
+
+AS_IF([test "x${enable_gc_unused}" = "xyes"], [
+ CCFLAGS="$CCFLAGS -ffunction-sections -fdata-sections"
+ CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
+ LDFLAGS="$LDFLAGS -Wl,--gc-sections"
+])
+
AS_CASE($ax_cv_cxx_compiler_vendor,
[clang], [
# Check if -Wno-unused-local-typedef is needed by checking a sample
http://git-wip-us.apache.org/repos/asf/mesos/blob/ca7d0002/docs/configuration/autotools.md
----------------------------------------------------------------------
diff --git a/docs/configuration/autotools.md b/docs/configuration/autotools.md
index c6ac196..3c3c59a 100644
--- a/docs/configuration/autotools.md
+++ b/docs/configuration/autotools.md
@@ -87,6 +87,15 @@ layout: documentation
</tr>
<tr>
<td>
+ --enable-gc-unused
+ </td>
+ <td>
+ Enable garbage collection of unused program segments. This option
+ significantly reduces the size of the final build artifacts. [default=no]
+ </td>
+ </tr>
+ <tr>
+ <td>
--disable-libtool-lock
</td>
<td>
http://git-wip-us.apache.org/repos/asf/mesos/blob/ca7d0002/docs/configuration/cmake.md
----------------------------------------------------------------------
diff --git a/docs/configuration/cmake.md b/docs/configuration/cmake.md
index 5364b1e..1e34657 100644
--- a/docs/configuration/cmake.md
+++ b/docs/configuration/cmake.md
@@ -40,6 +40,15 @@ See more information in the [CMake documentation](../cmake.md).
</tr>
<tr>
<td>
+ -DENABLE_GC_UNUSED=(TRUE|FALSE)
+ </td>
+ <td>
+ Enable garbage collection of unused program segments. This option
+ significantly reduces the size of the final build artifacts. [default=FALSE]
+ </td>
+ </tr>
+ <tr>
+ <td>
-DENABLE_PRECOMPILED_HEADERS=(TRUE|FALSE)
</td>
<td>