diff --git a/client.mk b/client.mk index 737e0059f4f..35a35563337 100644 --- a/client.mk +++ b/client.mk @@ -1162,4 +1162,4 @@ endif echo-variable-%: @echo $($*) -.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all +.PHONY: checkout real_checkout depend build profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 6ac5ce69497..f4143cdbdee 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -284,7 +284,9 @@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@ MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@ PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@ +PROFILE_GEN_LDFLAGS = @PROFILE_GEN_LDFLAGS@ PROFILE_USE_CFLAGS = @PROFILE_USE_CFLAGS@ +PROFILE_USE_LDFLAGS = @PROFILE_USE_LDFLAGS@ XCFLAGS = @XCFLAGS@ XLDFLAGS = @XLDFLAGS@ diff --git a/config/config.mk b/config/config.mk index 77b66f1d843..0129305ee56 100644 --- a/config/config.mk +++ b/config/config.mk @@ -278,16 +278,6 @@ endif endif # MOZ_DEBUG endif # WINNT && !GNU_CC - -# If we're applying MOZ_PROFILE_GENERATE to a non-static build, then we -# need to create a static build _with_ PIC. This allows us to generate -# profile data that will still be valid when the object files are linked into -# shared libraries. -ifdef MOZ_PROFILE_GENERATE -BUILD_STATIC_LIBS=1 -STATIC_BUILD_PIC=1 -endif - # # Build using PIC by default # Do not use PIC if not building a shared lib (see exceptions below) @@ -352,20 +342,6 @@ FORCE_SHARED_LIB=1 endif endif -ifdef STATIC_BUILD_PIC -ifndef _ENABLE_PIC -# If PIC hasn't been enabled now, object files in this directory will not -# ever be linked into a DSO. Turn PIC on and set ENABLE_PROFILE_GENERATE. -ENABLE_PROFILE_GENERATE=1 -_ENABLE_PIC=1 -endif -else -# For static builds, always enable profile generation for non-PIC objects. -ifndef _ENABLE_PIC -ENABLE_PROFILE_GENERATE=1 -endif -endif - # # Disable PIC if necessary # @@ -377,24 +353,28 @@ DSO_PIC_CFLAGS=-mdynamic-no-pic else DSO_PIC_CFLAGS= endif - -MKSHLIB= endif -# Enable profile-based feedback for non-PIC objects -ifdef ENABLE_PROFILE_GENERATE +# Enable profile-based feedback ifdef MOZ_PROFILE_GENERATE -DSO_PIC_CFLAGS += $(PROFILE_GEN_CFLAGS) -endif +# No sense in profiling tools +ifndef INTERNAL_TOOLS +OS_CFLAGS += $(PROFILE_GEN_CFLAGS) +OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS) +endif # INTERNAL_TOOLS +OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS) endif + # We always use the profile-use flags, even in cases where we didn't use the # profile-generate flags. It's harmless, and it saves us from having to # answer the question "Would these objects have been built using # the profile-generate flags?" which is not trivial. ifdef MOZ_PROFILE_USE -DSO_PIC_CFLAGS += $(PROFILE_USE_CFLAGS) +OS_CFLAGS += $(PROFILE_USE_CFLAGS) +OS_CXXFLAGS += $(PROFILE_USE_CFLAGS) endif + # Does the makefile specifies the internal XPCOM API linkage? ifneq (,$(MOZILLA_INTERNAL_API)$(LIBXUL_LIBRARY)) DEFINES += -DMOZILLA_INTERNAL_API diff --git a/configure.in b/configure.in index 74f716abbb8..ff86a03ee57 100644 --- a/configure.in +++ b/configure.in @@ -6507,7 +6507,9 @@ AC_TRY_COMPILE([], [return 0;], AC_MSG_RESULT([$result]) if test $result = "yes"; then + PROFILE_GEN_LDFLAGS="-fprofile-generate" PROFILE_USE_CFLAGS="-fprofile-use" + PROFILE_USE_LDFLAGS="-fprofile-use" else CFLAGS="$_SAVE_CFLAGS -fprofile-arcs" AC_MSG_CHECKING([whether C compiler supports -fprofile-arcs]) @@ -6518,12 +6520,17 @@ else if test $result = "yes"; then PROFILE_USE_CFLAGS="-fbranch-probabilities" fi + # don't really care, this is an old GCC + PROFILE_GEN_LDFLAGS= + PROFILE_USE_LDFLAGS= fi CFLAGS="$_SAVE_CFLAGS" AC_SUBST(PROFILE_GEN_CFLAGS) +AC_SUBST(PROFILE_GEN_LDFLAGS) AC_SUBST(PROFILE_USE_CFLAGS) +AC_SUBST(PROFILE_USE_LDFLAGS) AC_LANG_CPLUSPLUS