git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: John David Anglin <dave.anglin@bell.net>
To: git@vger.kernel.org
Subject: Porting git version 2.25.0.rc2 to hppa2.0w-hp-hpux11.11 using gcc-8.3.1
Date: Sun, 12 Jan 2020 14:28:47 -0500	[thread overview]
Message-ID: <c9aa5047-7438-8f2f-985c-1c8771354211@bell.net> (raw)

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@bell.net

                 reply	other threads:[~2020-01-12 19:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9aa5047-7438-8f2f-985c-1c8771354211@bell.net \
    --to=dave.anglin@bell.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).