Since the GCC project is switching to a git archive, there was a need to port git to hpux11.11. In particular, we need git to continue support for the hppa64 target as linux doesn't yet have a 64-bit runtime. This mail documents the changes that I needed to build git on hppa2.0w-hp-hpux11.11. 1) SCNuMAX is missing from inttypes.h I needed to add back a define in git-compat-util.h. I will probably fix this in gcc in the near future. 2) strtoll() and strtoull() are not supported This causes a problem in t/helper/test-progress.c. Regardless of what configure thinks, the target supports strtoimax() and strtoumax(). So, I changed t/helper/test-progress.c to use uintmax_t and strtoumax(). strtoimax() and strtoumax() are used in other places, so this makes test-progress.c consistent with the other usage. Internally, strtoumax() is implemented is __strtoull(). So, the strtoumax() version has the same range as the strtoull() version. It would be possible to implement strtoull() and strtoll() with an include hack in gcc but most packages use the versions in libiberty and gnulib. 3) Bus error in recv_sideband See: http://git.661346.n2.nabble.com/git-failure-on-HP-UX-td6335104.html This error occurs when one tries to clone an archive: Dump of assembler code for function recv_sideband: 0x0017fe30 <+0>: stw rp,-14(sp) 0x0017fe34 <+4>: addil L%10000,sp,r1 0x0017fe38 <+8>: ldo 80(r1),sp => 0x0017fe3c <+12>: stw r14,-70(sp) (gdb) bt #0 0x0017fe3c in recv_sideband () from /opt/gnu/libexec/git-core/git #1 0x0012e874 in sideband_demux () from /opt/gnu/libexec/git-core/git #2 0x001b5e80 in run_thread () from /opt/gnu/libexec/git-core/git #3 0xc005b290 in __pthread_body () from /opt/langtools/lib/libpthread.1 int recv_sideband(const char *me, int in_stream, int out) { char buf[LARGE_PACKET_MAX + 1]; ... The bus error occurs because the frame size needed for buf and the other locals exceeds the default thread stack size. This can be changed using the PTHREAD_DEFAULT_STACK_SIZE environment variable. For example, export PTHREAD_DEFAULT_STACK_SIZE=131072 It also could be adjusted using pthread_default_stacksize_np(). However, it seemed better to me to allocate buf using malloc and avoid the issue entirely. 4) NO_PREAD is required Without NO_PREAD, we get the following error: fatal: premature end of pack file, 106 bytes missing fatal: index-pack failed This occurs on the first pread() call. There is some kind of sequencing issue as doing a fprintf to stderr changes the behavior. However, it doesn't fix the error. 5) -pthread is required The libc library contains pthread stub routines. -pthread is needed to cause gcc to correctly link with thread support. The following summarizes the code changes: diff --git a/git-compat-util.h b/git-compat-util.h index aed0b5d4f9..bcc0d925bf 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1335,4 +1335,8 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset) ((uintptr_t)&(ptr)->member - (uintptr_t)(ptr)) #endif /* !__GNUC__ */ +#ifndef SCNuMAX +#define SCNuMAX PRIuMAX +#endif + #endif diff --git a/pkt-line.c b/pkt-line.c index a0e87b1e81..5024325c81 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -444,7 +444,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out) int recv_sideband(const char *me, int in_stream, int out) { - char buf[LARGE_PACKET_MAX + 1]; + char *buf = xmalloc(LARGE_PACKET_MAX + 1); int len; struct strbuf scratch = STRBUF_INIT; enum sideband_type sideband_type; @@ -460,6 +460,7 @@ int recv_sideband(const char *me, int in_stream, int out) write_or_die(out, buf + 1, len - 1); break; default: /* errors: message already written */ + free(buf); return sideband_type; } } diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c index 42b96cb103..b96a20237a 100644 --- a/t/helper/test-progress.c +++ b/t/helper/test-progress.c @@ -54,18 +54,18 @@ int cmd__progress(int argc, const char **argv) char *end; if (skip_prefix(line.buf, "progress ", (const char **) &end)) { - uint64_t item_count = strtoull(end, &end, 10); + uintmax_t item_count = strtoumax(end, &end, 10); if (*end != '\0') die("invalid input: '%s'\n", line.buf); display_progress(progress, item_count); } else if (skip_prefix(line.buf, "throughput ", (const char **) &end)) { - uint64_t byte_count, test_ms; + uintmax_t byte_count, test_ms; - byte_count = strtoull(end, &end, 10); + byte_count = strtoumax(end, &end, 10); if (*end != ' ') die("invalid input: '%s'\n", line.buf); - test_ms = strtoull(end + 1, &end, 10); + test_ms = strtoumax(end + 1, &end, 10); if (*end != '\0') die("invalid input: '%s'\n", line.buf); progress_test_ns = test_ms * 1000 * 1000; The following summarizes the changes to config.mak.autogen after running configure: --- config.mak.autogen.save 2020-01-12 13:17:09 +0000 +++ config.mak.autogen 2020-01-12 13:14:54 +0000 @@ -75,13 +75,15 @@ NO_MEMMEM=YesPlease NO_STRLCPY=YesPlease NO_UINTMAX_T= -NO_STRTOUMAX=YesPlease +NO_STRTOULL=YesPlease +NO_STRTOUMAX= NO_SETENV=YesPlease NO_UNSETENV=YesPlease NO_MKDTEMP=YesPlease NO_INITGROUPS= HAVE_GETDELIM= HAVE_BSD_SYSCTL= -PTHREAD_CFLAGS= +PTHREAD_CFLAGS=-pthread PTHREAD_LIBS= NO_PTHREADS= +NO_PREAD=YesPlease Regards, Dave -- John David Anglin dave.anglin@xxxxxxxx