configure: Improve profile build related.

This commit is contained in:
Jason Volk 2020-11-24 11:04:19 -08:00
parent 0f851d1d98
commit 910dafbb85
3 changed files with 65 additions and 7 deletions

View File

@ -381,30 +381,54 @@ dnl
dnl Profiling mode
dnl
AC_MSG_CHECKING(whether to do a profile build)
AC_ARG_ENABLE(profile, RB_HELP_STRING([--enable-profile], [Enable profiling]),
AC_MSG_CHECKING(whether to instrument build for runtime profile generation)
AC_ARG_ENABLE(profile, RB_HELP_STRING([--enable-profile], [Generate profile at runtime]),
[
profiling="yes"
AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
AM_COND_IF(GCC,
[
AC_MSG_RESULT([yes, adding -pg])
RB_VAR_PREPEND([CXXFLAGS], ["-pg"])
AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
])
AM_COND_IF(CLANG,
[
AC_MSG_RESULT([yes, adding profiling flags])
RB_VAR_PREPEND([CXXFLAGS], ["-fprofile-instr-generate"])
RB_VAR_PREPEND([CXXFLAGS], ["-fcoverage-mapping"])
RB_VAR_PREPEND([LDFLAGS], ["-fprofile-instr-generate"])
AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
#RB_VAR_PREPEND([CXXFLAGS], ["-fprofile-generate"])
#RB_VAR_PREPEND([LDFLAGS], ["-Wl,-fprofile-generate"])
dnl TODO: $enableval=instr?
dnl RB_VAR_PREPEND([CXXFLAGS], ["-fprofile-instr-generate"])
dnl RB_VAR_PREPEND([CXXFLAGS], ["-fcoverage-mapping"])
dnl RB_VAR_PREPEND([LDFLAGS], ["-Wl,-fprofile-instr-generate"])
])
], [
AC_MSG_RESULT([no])
profiling="no"
])
AC_MSG_CHECKING(whether to use a specific runtime profile)
AC_ARG_WITH(profile, RB_HELP_STRING([--with-profile[[[=$PWD]]]], [Path to profdata]),
[
profiling_use=$withval
AC_MSG_RESULT([yes, "$profiling_use"])
AC_SUBST(PROFILE_USE, $profiling_use)
dnl AM_COND_IF(CLANG,
dnl [
dnl RB_VAR_PREPEND([CXXFLAGS], [-fprofile-use="$profiling_use"])
dnl ])
], [
AC_MSG_RESULT([no])
])
AM_CONDITIONAL([PROFILE], [[[[ "$profiling" = "yes" ]]]])
dnl
dnl Precompiled headers
dnl
@ -2593,6 +2617,7 @@ echo "Developer profiling ............... $profiling"
echo "Precompiled headers ............... $build_pch"
echo "Optimized compile ................. $optimize"
echo "Optimized linking ................. $lto"
echo "Optimized runtime ................. $profiling_used"
echo "Optimization level ................ $optimize_level"
echo "Machine tuned ..................... $machine_tuning"
echo

View File

@ -36,6 +36,12 @@ AM_LDFLAGS = \
$(EXTRA_LDFLAGS) \
###
if PROFILE
if CLANG
AM_CXXFLAGS += -fprofile-generate
endif
endif
bin_PROGRAMS = construct
construct_LDFLAGS = \

View File

@ -61,6 +61,18 @@ AM_LDFLAGS += -Wl,--enable-runtime-pseudo-reloc
AM_LDFLAGS += -export-symbols-regex '*'
endif
if PROFILE
if CLANG
AM_CXXFLAGS += -fprofile-generate
AM_LDFLAGS += -Wl,-fprofile-generate
#TODO: XXX
#AM_CXXFLAGS += -fprofile-instr-generate
#AM_CXXFLAGS += -fcoverage-mapping
#AM_LDFLAGS += -Wl,-fprofile-instr-generate
#AM_LDFLAGS += -Wl,-fcoverage-mapping
endif
endif
#
# libircd
#
@ -108,6 +120,13 @@ libircd_la_LIBADD = \
$(EXTRA_LIBS) \
###
if PROFILE
if CLANG11
#TODO: XXX
libircd_la_LIBADD += /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.profile-x86_64.a
endif
endif
#
# Unit list
#
@ -221,6 +240,14 @@ libircd_la_SOURCES += ircd.cc
# Specific unit configurations
#
if CLANG
if !PROFILE
if !DEBUG
SPIRIT_UNIT_CXXFLAGS += -fprofile-use
endif
endif
endif
client.lo: AM_CPPFLAGS := ${ASIO_UNIT_CPPFLAGS} ${AM_CPPFLAGS}
ctx_x86_64.lo: AM_CPPFLAGS := -I$(top_srcdir)/include
ctx.lo: AM_CPPFLAGS := ${ASIO_UNIT_CPPFLAGS} ${AM_CPPFLAGS}