Merge branch 'ak/profile-feedback-build'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Jul 2014 18:17:47 +0000 (11:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Jul 2014 18:17:47 +0000 (11:17 -0700)
* ak/profile-feedback-build:
Fix profile feedback with -jN and add profile-fast
Run the perf test suite for profile feedback too
Don't define away __attribute__ on gcc
Use BASIC_FLAGS for profile feedback

1  2 
Makefile
git-compat-util.h
diff --combined Makefile
index 840057cba7ebd5fea25d84af367e49f0fcfc41c7,a760402370de322d8a1eb2c38080a37b641d55c1..a49acb5ec621709e43714670289029571c60eed7
+++ b/Makefile
@@@ -552,7 -552,6 +552,7 @@@ TEST_PROGRAMS_NEED_X += test-ctyp
  TEST_PROGRAMS_NEED_X += test-date
  TEST_PROGRAMS_NEED_X += test-delta
  TEST_PROGRAMS_NEED_X += test-dump-cache-tree
 +TEST_PROGRAMS_NEED_X += test-dump-split-index
  TEST_PROGRAMS_NEED_X += test-genrandom
  TEST_PROGRAMS_NEED_X += test-hashmap
  TEST_PROGRAMS_NEED_X += test-index-version
@@@ -876,7 -875,6 +876,7 @@@ LIB_OBJS += sha1_name.
  LIB_OBJS += shallow.o
  LIB_OBJS += sideband.o
  LIB_OBJS += sigchain.o
 +LIB_OBJS += split-index.o
  LIB_OBJS += strbuf.o
  LIB_OBJS += streaming.o
  LIB_OBJS += string-list.o
@@@ -1001,7 -999,6 +1001,7 @@@ BUILTIN_OBJS += builtin/update-ref.
  BUILTIN_OBJS += builtin/update-server-info.o
  BUILTIN_OBJS += builtin/upload-archive.o
  BUILTIN_OBJS += builtin/var.o
 +BUILTIN_OBJS += builtin/verify-commit.o
  BUILTIN_OBJS += builtin/verify-pack.o
  BUILTIN_OBJS += builtin/verify-tag.o
  BUILTIN_OBJS += builtin/write-tree.o
@@@ -1555,13 -1552,13 +1555,13 @@@ endi
  PROFILE_DIR := $(CURDIR)
  
  ifeq ("$(PROFILE)","GEN")
-       CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
+       BASIC_CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
        EXTLIBS += -lgcov
        export CCACHE_DISABLE = t
        V = 1
  else
  ifneq ("$(PROFILE)","")
-       CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
+       BASIC_CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
        export CCACHE_DISABLE = t
        V = 1
  endif
@@@ -1646,12 -1643,20 +1646,20 @@@ SHELL = $(SHELL_PATH
  all:: shell_compatibility_test
  
  ifeq "$(PROFILE)" "BUILD"
- ifeq ($(filter all,$(MAKECMDGOALS)),all)
- all:: profile-clean
+ all:: profile
+ endif
+ profile:: profile-clean
        $(MAKE) PROFILE=GEN all
        $(MAKE) PROFILE=GEN -j1 test
- endif
- endif
+       $(MAKE) PROFILE=GEN -j1 perf
+       $(MAKE) PROFILE=USE all
+ profile-fast: profile-clean
+       $(MAKE) PROFILE=GEN all
+       $(MAKE) PROFILE=GEN -j1 perf
+       $(MAKE) PROFILE=USE all
  
  all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
  ifneq (,$X)
@@@ -2338,6 -2343,12 +2346,12 @@@ mergetools_instdir_SQ = $(subst ','\'',
  
  install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
  
+ profile-install: profile
+       $(MAKE) install
+ profile-fast-install: profile-fast
+       $(MAKE) install
  install: all
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
diff --combined git-compat-util.h
index 0b53c9a4af3c7e1d5611065b35ef38f3f1f5e5be,01e8695a2db88cb6fa1c80bde7a9740e6996c4c5..63d72db5539d47cd7064536a2cb7497dcdade58e
@@@ -291,10 -291,12 +291,12 @@@ extern char *gitbasename(char *)
  #else
  #define NORETURN
  #define NORETURN_PTR
+ #ifndef __GNUC__
  #ifndef __attribute__
  #define __attribute__(x)
  #endif
  #endif
+ #endif
  
  /* The sentinel attribute is valid from gcc version 4.0 */
  #if defined(__GNUC__) && (__GNUC__ >= 4)
@@@ -347,66 -349,15 +349,66 @@@ extern void set_error_routine(void (*ro
  extern void set_die_is_recursing_routine(int (*routine)(void));
  
  extern int starts_with(const char *str, const char *prefix);
 -extern int ends_with(const char *str, const char *suffix);
  
 -static inline const char *skip_prefix(const char *str, const char *prefix)
 +/*
 + * If the string "str" begins with the string found in "prefix", return 1.
 + * The "out" parameter is set to "str + strlen(prefix)" (i.e., to the point in
 + * the string right after the prefix).
 + *
 + * Otherwise, return 0 and leave "out" untouched.
 + *
 + * Examples:
 + *
 + *   [extract branch name, fail if not a branch]
 + *   if (!skip_prefix(ref, "refs/heads/", &branch)
 + *    return -1;
 + *
 + *   [skip prefix if present, otherwise use whole string]
 + *   skip_prefix(name, "refs/heads/", &name);
 + */
 +static inline int skip_prefix(const char *str, const char *prefix,
 +                            const char **out)
  {
        do {
 -              if (!*prefix)
 -                      return str;
 +              if (!*prefix) {
 +                      *out = str;
 +                      return 1;
 +              }
        } while (*str++ == *prefix++);
 -      return NULL;
 +      return 0;
 +}
 +
 +/*
 + * If buf ends with suffix, return 1 and subtract the length of the suffix
 + * from *len. Otherwise, return 0 and leave *len untouched.
 + */
 +static inline int strip_suffix_mem(const char *buf, size_t *len,
 +                                 const char *suffix)
 +{
 +      size_t suflen = strlen(suffix);
 +      if (*len < suflen || memcmp(buf + (*len - suflen), suffix, suflen))
 +              return 0;
 +      *len -= suflen;
 +      return 1;
 +}
 +
 +/*
 + * If str ends with suffix, return 1 and set *len to the size of the string
 + * without the suffix. Otherwise, return 0 and set *len to the size of the
 + * string.
 + *
 + * Note that we do _not_ NUL-terminate str to the new length.
 + */
 +static inline int strip_suffix(const char *str, const char *suffix, size_t *len)
 +{
 +      *len = strlen(str);
 +      return strip_suffix_mem(str, len, suffix);
 +}
 +
 +static inline int ends_with(const char *str, const char *suffix)
 +{
 +      size_t len;
 +      return strip_suffix(str, suffix, &len);
  }
  
  #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
@@@ -613,6 -564,13 +615,6 @@@ static inline size_t xsize_t(off_t len
        return (size_t)len;
  }
  
 -static inline int has_extension(const char *filename, const char *ext)
 -{
 -      size_t len = strlen(filename);
 -      size_t extlen = strlen(ext);
 -      return len > extlen && !memcmp(filename + len - extlen, ext, extlen);
 -}
 -
  /* in ctype.c, for kwset users */
  extern const char tolower_trans_tbl[256];