From 9aa55d7e9dae5d6ff37b4fc81230d75664217e2b Mon Sep 17 00:00:00 2001 From: eschnett Date: Sun, 28 Oct 2012 21:48:32 +0000 Subject: Add configuration options allowing moving all object files into the executable Add configuration options allowing people to ensure that all thorn source files make it into the executable. Among other things, this ensures that each routine has a unique name. This is disabled by default. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4899 17b73243-c579-4c4c-a9d2-2d5706c11dac --- lib/make/configure | 22 +++++++++++++++------- lib/make/configure.in | 6 ++++++ lib/make/make.config.defn.in | 3 +++ lib/make/make.configuration | 16 ++++++++++++++-- lib/make/make.thornlib | 1 - 5 files changed, 38 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/make/configure b/lib/make/configure index 4f25710f..25af7de3 100755 --- a/lib/make/configure +++ b/lib/make/configure @@ -7627,10 +7627,10 @@ cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then @@ -8172,6 +8172,12 @@ LDFLAGS="$LDFLAGS $KNOWN_LDFLAGS" : ${LIBNAME_SUFFIX='.a'} +# How to link in all object files from an archive + +: ${BEGIN_WHOLE_ARCHIVE_FLAGS=''} + +: ${END_WHOLE_ARCHIVE_FLAGS=''} + # How to link the cactus libraries : ${CACTUSLIBLINKLINE='-L$(CCTK_LIBDIR) $(addprefix -l, $(ALLCACTUSLIBS))'} @@ -8307,7 +8313,7 @@ if test "x$CCTK_NEED_X" = 'xyes' ; then # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:8311: checking for X" >&5 +echo "configure:8317: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then @@ -8369,12 +8375,12 @@ if test "$ac_x_includes" = NO; then # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8378: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8384: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8443,14 +8449,14 @@ if test "$ac_x_libraries" = NO; then ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. @@ -8791,6 +8797,8 @@ s%@DIRSEP@%$DIRSEP%g s%@OPTIONSEP@%$OPTIONSEP%g s%@LIBNAME_PREFIX@%$LIBNAME_PREFIX%g s%@LIBNAME_SUFFIX@%$LIBNAME_SUFFIX%g +s%@BEGIN_WHOLE_ARCHIVE_FLAGS@%$BEGIN_WHOLE_ARCHIVE_FLAGS%g +s%@END_WHOLE_ARCHIVE_FLAGS@%$END_WHOLE_ARCHIVE_FLAGS%g s%@CACTUSLIBLINKLINE@%$CACTUSLIBLINKLINE%g s%@C_DEPEND@%$C_DEPEND%g s%@C_DEPEND_OUT@%$C_DEPEND_OUT%g diff --git a/lib/make/configure.in b/lib/make/configure.in index 08ae04f3..7c1a7e45 100644 --- a/lib/make/configure.in +++ b/lib/make/configure.in @@ -1260,6 +1260,12 @@ AC_SUBST(LIBNAME_PREFIX) AC_SUBST(LIBNAME_SUFFIX) : ${LIBNAME_SUFFIX='.a'} +# How to link in all object files from an archive +AC_SUBST(BEGIN_WHOLE_ARCHIVE_FLAGS) +: ${BEGIN_WHOLE_ARCHIVE_FLAGS=''} +AC_SUBST(END_WHOLE_ARCHIVE_FLAGS) +: ${END_WHOLE_ARCHIVE_FLAGS=''} + # How to link the cactus libraries AC_SUBST(CACTUSLIBLINKLINE) : ${CACTUSLIBLINKLINE='-L$(CCTK_LIBDIR) $(addprefix -l, $(ALLCACTUSLIBS))'} diff --git a/lib/make/make.config.defn.in b/lib/make/make.config.defn.in index 3a21ad52..1575ac58 100644 --- a/lib/make/make.config.defn.in +++ b/lib/make/make.config.defn.in @@ -141,6 +141,9 @@ export OPTIONSEP = @OPTIONSEP@ export LIBNAME_PREFIX = @LIBNAME_PREFIX@# Make sure there is no space at end. export LIBNAME_SUFFIX = @LIBNAME_SUFFIX@ +export BEGIN_WHOLE_ARCHIVE_FLAGS = @BEGIN_WHOLE_ARCHIVE_FLAGS@ +export END_WHOLE_ARCHIVE_FLAGS = @END_WHOLE_ARCHIVE_FLAGS@ + export CACTUSLIBLINKLINE = @CACTUSLIBLINKLINE@ # Dependency file generation diff --git a/lib/make/make.configuration b/lib/make/make.configuration index 81873574..abfcc05e 100644 --- a/lib/make/make.configuration +++ b/lib/make/make.configuration @@ -126,18 +126,30 @@ UTIL_DIR=$(EXEDIR)$(DIRSEP)$(CONFIG_NAME) # Build the list of all libraries +ifeq ($(strip $(BEGIN_WHOLE_ARCHIVE_FLAGS)),) +# Repeat Cactus only if --whole-archive is not used ALLCACTUSLIBS_BASE = $(notdir $(CACTUSLIBS) $(THORN_LINKLIST) $(CACTUSLIBS)) +else +ALLCACTUSLIBS_BASE = $(notdir $(THORNS) $(CACTUSLIBS)) +endif ALLCACTUSLIBS = $(ALLCACTUSLIBS_BASE:%=$(CCTK_LIBNAME_PREFIX)%) +$(CCTK_LIBDIR)/LINKLIST: $(patsubst %,$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX),$(notdir $(THORNS) $(CACTUSLIBS))) + cd $(CCTK_LIBDIR); \ + for thorn in $(notdir $(THORNS) $(CACTUSLIBS)); do \ + xargs -n 1 -I :OBJFILE: echo $$thorn/:OBJFILE: <$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)$$thorn$(LIBNAME_SUFFIX).objectlist; \ + done >$@.tmp + mv $@.tmp $@ + # Build the executable -$(EXEDIR)$(DIRSEP)$(EXE): $(CONFIG)/make.thornlist $(CONFIG)/cctki_version.h $(patsubst %,$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX),$(notdir $(THORNS) $(CACTUSLIBS))) +$(EXEDIR)$(DIRSEP)$(EXE): $(CONFIG)/make.thornlist $(CONFIG)/cctki_version.h $(patsubst %,$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX),$(notdir $(THORNS) $(CACTUSLIBS))) $(CCTK_LIBDIR)/LINKLIST @echo Creating $(EXE) in $(EXEDIR) from $(THORNS) datetime=`/bin/date +'%Y-%m-%dT%H:%M:%S%z' 2>&1` ; \ if [ $$? != 0 ]; then datetime=`/bin/date` ; fi ; \ $(CC) $(CFLAGS) -DCCTK_COMPILE_DATETIME="$$datetime" $(CCOMPILEONLY)$(OPTIONSEP)"$(call TRANSFORM_DIRS,$(TOP)/datestamp.o)" -I"$(call TRANSFORM_DIRS,$(CCTK_HOME)/src/include)" -I"$(call TRANSFORM_DIRS,$(CONFIG))" "$(call TRANSFORM_DIRS,$(DATESTAMP))" if [ ! -d $(EXEDIR) ]; then $(MKDIR) $(MKDIRFLAGS) $(EXEDIR) ; fi - $(LD) $(CREATEEXE)$(OPTIONSEP)"$(call TRANSFORM_DIRS,$@)" $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(EXTRAFLAGS) "$(call TRANSFORM_DIRS,$(TOP)/datestamp.o)" $(CACTUSLIBLINKLINE) $(GENERAL_LIBRARIES) + $(LD) $(CREATEEXE)$(OPTIONSEP)"$(call TRANSFORM_DIRS,$@)" $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(EXTRAFLAGS) "$(call TRANSFORM_DIRS,$(TOP)/datestamp.o)" $(BEGIN_WHOLE_ARCHIVE_FLAGS) $(CACTUSLIBLINKLINE) $(END_WHOLE_ARCHIVE_FLAGS) $(GENERAL_LIBRARIES) $(NOTIFY_DIVIDER) # Version file diff --git a/lib/make/make.thornlib b/lib/make/make.thornlib index f6f640ee..1690025a 100644 --- a/lib/make/make.thornlib +++ b/lib/make/make.thornlib @@ -89,7 +89,6 @@ $(NAME): $(addsuffix /make.checked, $(SUBDIRS) $(THORNBINDINGS)) ## in batches not larger than $(OBJS-words-max) files at a time. $(MAKE) -f $(MAKE_DIR)/make.thornlib $(NAME).objectlist xargs -n $(OBJS-words-max) $(AR) $(ARFLAGS) $@ < $(NAME).objectlist - $(RM) $(NAME).objectlist ## Alternatively, we could create a single object file from the object ## files and put it into an archive. # ld -r -o $@.o $(OBJS) -- cgit v1.2.3