bug 240267 - link error when doing make profiledbuild. r=bsmedberg
authorted.mielczarek@gmail.com
Sat, 16 Feb 2008 14:23:07 -0800
changeset 11787 7ce2abc0c6daf003bdf1ace2cfffa6b67d9b34a3
parent 11786 5b2d273ccec2232627602b104c72ab5a148b9531
child 11788 5b3f13678e6b224907815e939479a1af88e5632a
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs240267
milestone1.9b4pre
bug 240267 - link error when doing make profiledbuild. r=bsmedberg
client.mk
config/autoconf.mk.in
config/config.mk
configure.in
--- a/client.mk
+++ b/client.mk
@@ -1157,9 +1157,9 @@ cleansrcdir:
 	fi;
 
 # (! IS_FIRST_CHECKOUT)
 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
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -279,17 +279,19 @@ WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS
 
 MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
 MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
 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@
 XLIBS		= @XLIBS@
 
 WIN_TOP_SRC	= @WIN_TOP_SRC@
 CYGWIN_WRAPPER	= @CYGWIN_WRAPPER@
 AS_PERL         = @AS_PERL@
--- a/config/config.mk
+++ b/config/config.mk
@@ -273,26 +273,16 @@ ifdef NS_TRACE_MALLOC
 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
 OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF -OPT:nowin98
 endif
 # NS_TRACE_MALLOC
 
 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)
 #
 
 ifndef BUILD_STATIC_LIBS
 _ENABLE_PIC=1
 endif
@@ -347,59 +337,49 @@ ifdef XPI_NAME
 _ENABLE_PIC=1
 ifdef IS_COMPONENT
 EXPORT_LIBRARY=
 FORCE_STATIC_LIB=
 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
 #
 
 ifndef _ENABLE_PIC
 DSO_CFLAGS=
 ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
 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)
+# 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
-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
 endif
 
 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
 # building libxul libraries
 ifdef MOZ_ENABLE_LIBXUL
--- a/configure.in
+++ b/configure.in
@@ -6502,33 +6502,40 @@ CFLAGS="$CFLAGS -fprofile-generate"
 
 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
 AC_TRY_COMPILE([], [return 0;],
                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
                  result="yes" ], result="no")
 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])
   AC_TRY_COMPILE([], [return 0;],
                  [ PROFILE_GEN_CFLAGS="-fprofile-arcs"
                    result="yes" ], result="no")
   AC_MSG_RESULT([$result])
   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
 
 dnl ========================================================
 dnl Test for -pedantic bustage
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(pedantic,
 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],