threads / patch / 20079

patch, 5 partsHow I compile on IRIX 6.5 with the MIPSpro compiler and ksh

Subject: [PATCH FYI 0/5] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh

## tl;dr

8 messages between Jul 10, 2009 and Jul 11, 2009. Diffs are folded; open one to read it.

replies: 7people: 2as markdown or json

Brandon Casey· Jul 10, 2009, 17:10 UTC · lore
From: Brandon Casey <drafnel@gmail.com>

This email describes how I have successfully compiled git on IRIX6.5 with the native MIPSpro compiler version 7.4.4m and successfully run nearly all of the tests using the Korn shell.

A config.mak file is provided at the end of this email.

The GIT_SKIP_TESTS environment variable was used to skip tests which still fail. The number of tests which must be skipped has been greatly reduced. When I sent this email last year, 23 individual tests were skipped plus all of t3901. With current master, only 13 tests must be skipped. The remaining tests which fail are due to the installed iconv lacking support for the tested languages.

Two lingering concerns:
  1) Building with -Ofast produces an executable which segfaults and can not
     pass the tests.
  2) Building with mmap support produces an executable which segfaults on
     t1400-update-ref when it calls
         'git rev-parse --verify "master@{May 25 2005}"'
     Previously, this fault was avoided when THREADED_DELTA_SEARCH was set,
     but there is a warning during compilation when THREADED_DELTA_SEARCH is
     enabled that suggests Variable Length Arrays should not be used when
     threads are used.  So it is left unset, and now NO_MMAP is set.
     From my notes:
     I tracked the mmap issue down to the mmap in refs.c:read_ref_at().  The
     mmap succeeds, and the loop is executed properly until rec is rewound
     into the first line (reflog entry) of the file. I don't know why it
     fails, the code looks correct. I can't reproduce it with a similarly
     structured stand-alone test program.  For the mentioned test that fails
     above, if the rev-parse argument is changed to something that does not
     reference the first entry in the log file, then it will succeed
     e.g. "master@{3}".
I have no debugger.

Otherwise, I've been using this executable somewhat and have not experienced any problems. Maybe it will be useful to others.

Are there actually any IRIX users out there?

These patches are all submitted For-Your-Information only. Junio, feel free to apply any of them or none, and to add my Signed-off-by.

-brandon
Brandon Casey (5):
  unpack-trees.c: work around run-time array initialization flaw on
    IRIX 6.5
  git-compat-util.h: adjust for SGI IRIX 6.5
  Makefile: add NEEDS_LIBGEN to optionally add -lgen to compile
    arguments
  Makefile: add section for SGI IRIX 6.5
  test-lib.sh: work around ksh's trap shortcomings
 Makefile          |   18 ++++++++++++++++++
 configure.ac      |    6 ++++++
 git-compat-util.h |    3 ++-
 t/lib-git-svn.sh  |   15 ++++++++++-----
 t/test-lib.sh     |    3 ++-
 unpack-trees.c    |    2 +-
 6 files changed, 39 insertions(+), 8 deletions(-)
--->8--- config.mak --->8---
GIT_SKIP_TESTS := \
   t3900.1[129] t3900.2[0234] \
   t5100.5 t5100.1[06] \
   t8005.[234]
export GIT_SKIP_TESTS

SHELL_PATH = /bin/ksh TAR = gtar CC = c99 CFLAGS = -n32 -O2 NO_C99_FORMAT = 1 NO_CURL = 1 NO_OPENSSL = 1 NO_TCLTK = 1

Brandon Casey· Jul 10, 2009, 17:10 UTC · re: Brandon Casey · lore

[PATCH FYI 1/5] unpack-trees.c: work around run-time array initialization flaw on IRIX 6.5

The c99 MIPSpro Compiler version 7.4.4m on IRIX 6.5 does not properly
initialize run-time initialized arrays.  An array which is initialized with
fewer elements than the length of the array should have the unitialized
elements initialized to zero.  This compiler only initializes the remaining
elements when the last element is a static parameter.  So work around it
by adding a "NULL" initialization parameter.
---
 unpack-trees.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to unpack-trees.c +1 −1
diff --git a/unpack-trees.c b/unpack-trees.c
index 05d0bb1..7894c07 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -128,7 +128,7 @@ static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_o
 
 static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o)
 {
-	struct cache_entry *src[5] = { ce, };
+	struct cache_entry *src[5] = { ce, NULL, };
 
 	o->pos++;
 	if (ce_stage(ce)) {
-- 
1.6.4.rc0.5.g76f7cf
Brandon Casey· Jul 10, 2009, 17:10 UTC · re: Brandon Casey · lore

[PATCH FYI 2/5] git-compat-util.h: adjust for SGI IRIX 6.5

Don't define _XOPEN_SOURCE Do define _SGI_SOURCE

Defining _XOPEN_SOURCE prevents many of the common functions and macros
from being defined. _Not_ setting _XOPEN_SOURCE, and instead setting
_SGI_SOURCE, provides all of the XPG4, XPG5, BSD, POSIX functions and
declarations, _BUT_ provides a horribly broken snprintf(). SGI does have
a working snprintf(), but it is only provided when _NO_XOPEN5 evaluates
to zero, and this only happens if _XOPEN_SOURCE is defined which, as
mentioned above, prevents many other common functions and defines.
---
 git-compat-util.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to git-compat-util.h +2 −1
diff --git a/git-compat-util.h b/git-compat-util.h
index 9609eaa..913f41a 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -52,7 +52,7 @@
 # else
 # define _XOPEN_SOURCE 500
 # endif
-#elif !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX)
+#elif !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #ifndef __sun__
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
@@ -62,6 +62,7 @@
 #define _GNU_SOURCE 1
 #define _BSD_SOURCE 1
 #define _NETBSD_SOURCE 1
+#define _SGI_SOURCE 1
 
 #include <unistd.h>
 #include <stdio.h>
-- 
1.6.4.rc0.5.g76f7cf
Brandon Casey· Jul 10, 2009, 17:10 UTC · re: Brandon Casey · lore

[PATCH FYI 3/5] Makefile: add NEEDS_LIBGEN to optionally add -lgen to compile arguments

From: Brandon Casey <drafnel@gmail.com>

Commit 003b33a8 recently added a call to basename(). On IRIX 6.5, this function resides in libgen and -lgen is required for the linker.

Update configure.ac too. ---

configure.ac changes are untested.
-brandon
 Makefile     |    5 +++++
 configure.ac |    6 ++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
Show changes to 2 files +11 −0

Makefile, configure.ac

diff --git a/Makefile b/Makefile
index 311ce7d..faaab5e 100644
--- a/Makefile
+++ b/Makefile
@@ -61,6 +61,8 @@ all::
 #
 # Define NO_LIBGEN_H if you don't have libgen.h.
 #
+# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
+#
 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
 #
 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
@@ -1019,6 +1021,9 @@ ifdef NEEDS_LIBICONV
 	endif
 	EXTLIBS += $(ICONV_LINK) -liconv
 endif
+ifdef NEEDS_LIBGEN
+	EXTLIBS += -lgen
+endif
 ifdef NEEDS_SOCKET
 	EXTLIBS += -lsocket
 endif
diff --git a/configure.ac b/configure.ac
index 1885674..74d0af5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -485,6 +485,12 @@ AC_CHECK_LIB([resolv], [hstrerror],
 AC_SUBST(NEEDS_RESOLV)
 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
 
+AC_CHECK_LIB([gen], [basename],
+[NEEDS_LIBGEN=],
+[NEEDS_LIBGEN=YesPlease])
+AC_SUBST(NEEDS_LIBGEN)
+test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
+
 ## Checks for header files.
 AC_MSG_NOTICE([CHECKS for header files])
 #
-- 
1.6.4.rc0.5.g76f7cf
Brandon Casey· Jul 10, 2009, 17:10 UTC · re: Brandon Casey · lore

[PATCH FYI 4/5] Makefile: add section for SGI IRIX 6.5

---
 Makefile |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Show changes to Makefile +13 −0
diff --git a/Makefile b/Makefile
index faaab5e..d404524 100644
--- a/Makefile
+++ b/Makefile
@@ -830,6 +830,19 @@ ifeq ($(uname_S),GNU)
 	NO_STRLCPY=YesPlease
 	NO_MKSTEMPS = YesPlease
 endif
+ifeq ($(uname_S),IRIX)
+	NO_SETENV = YesPlease
+	NO_UNSETENV = YesPlease
+	NO_STRCASESTR = YesPlease
+	NO_MEMMEM = YesPlease
+	NO_MKSTEMPS = YesPlease
+	NO_MKDTEMP = YesPlease
+	NO_MMAP = YesPlease
+	NO_EXTERNAL_GREP = UnfortunatelyYes
+	SNPRINTF_RETURNS_BOGUS = YesPlease
+	SHELL_PATH = /usr/gnu/bin/bash
+	NEEDS_LIBGEN = YesPlease
+endif
 ifeq ($(uname_S),IRIX64)
 	NO_IPV6=YesPlease
 	NO_SETENV=YesPlease
-- 
1.6.4.rc0.5.g76f7cf
Brandon Casey· Jul 10, 2009, 17:10 UTC · re: Brandon Casey · lore

[PATCH FYI 5/5] test-lib.sh: work around ksh's trap shortcomings

From: Brandon Casey <casey@argon.nrlssc.navy.mil>

In ksh, if trap is called within a function with 0 or EXIT as its signal, then the trap will be executed at the time the function returns. This causes a problem in the test functions since 'trap - EXIT' is called within the test_done function in order to remove the trap which calls die() on exit. This means trap has to be called from the scripts top-level. Do so by renaming the test_done function to test_done_func, and then, remove the trap and call test_done_func from within a new alias named test_done.

Additionally, there is some strangeness with respect to aliases and sourced
script files; the alias is not available within the sourced file. So call
'trap - EXIT' directly in lib-git-svn.sh before calling the test_done_func
function.
---
 t/lib-git-svn.sh |   15 ++++++++++-----
 t/test-lib.sh    |    3 ++-
 2 files changed, 12 insertions(+), 6 deletions(-)
Show changes to 2 files +12 −6

t/lib-git-svn.sh, t/test-lib.sh

diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 5654962..c49971c 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -6,11 +6,13 @@ git_svn_id=git""-svn-id
 if test -n "$NO_SVN_TESTS"
 then
 	say 'skipping git svn tests, NO_SVN_TESTS defined'
-	test_done
+	trap - EXIT
+	test_done_func
 fi
 if ! test_have_prereq PERL; then
 	say 'skipping git svn tests, perl not available'
-	test_done
+	trap - EXIT
+	test_done_func
 fi
 
 GIT_DIR=$PWD/.git
@@ -21,7 +23,8 @@ svn >/dev/null 2>&1
 if test $? -ne 1
 then
     say 'skipping git svn tests, svn not found'
-    test_done
+    trap - EXIT
+    test_done_func
 fi
 
 svnrepo=$PWD/svnrepo
@@ -46,7 +49,8 @@ then
 		err='Perl SVN libraries not found or unusable, skipping test'
 	fi
 	say "$err"
-	test_done
+	trap - EXIT
+	test_done_func
 fi
 
 rawsvnrepo="$svnrepo"
@@ -159,7 +163,8 @@ require_svnserve () {
     if test -z "$SVNSERVE_PORT"
     then
         say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
-        test_done
+	trap - EXIT
+	test_done_func
     fi
 }
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 5fdc5d9..d7c12db 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -504,7 +504,7 @@ test_create_repo () {
 	cd "$owd"
 }
 
-test_done () {
+test_done_func () {
 	GIT_EXIT_OK=t
 	test_results_dir="$TEST_DIRECTORY/test-results"
 	mkdir -p "$test_results_dir"
@@ -544,6 +544,7 @@ test_done () {
 
 	esac
 }
+alias test_done='trap - EXIT && test_done_func'
 
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in 'trash directory' subdirectory.
-- 
1.6.4.rc0.5.g76f7cf
Brandon Casey· Jul 10, 2009, 18:31 UTC · re: Brandon Casey · lore

[PATCH FYI 6/5] Makefile: update IRIX64 section

From: Brandon Casey <drafnel@gmail.com>
---

Here's the update for the 64-bit version of IRIX. This has been tested to the same extent that the 32-bit version has been tested. The 64-bit test system is a little bit older than the 32-bit system, so a few more tests are skipped (related to a too old gtar), and NO_STRLCPY and NO_DEFLATE_BOUND macros are set.

-brandon
 Makefile |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Show changes to Makefile +6 −6
diff --git a/Makefile b/Makefile
index d404524..baa0296 100644
--- a/Makefile
+++ b/Makefile
@@ -844,17 +844,17 @@ ifeq ($(uname_S),IRIX)
 	NEEDS_LIBGEN = YesPlease
 endif
 ifeq ($(uname_S),IRIX64)
-	NO_IPV6=YesPlease
 	NO_SETENV=YesPlease
+	NO_UNSETENV = YesPlease
 	NO_STRCASESTR=YesPlease
 	NO_MEMMEM = YesPlease
 	NO_MKSTEMPS = YesPlease
-	NO_STRLCPY = YesPlease
-	NO_SOCKADDR_STORAGE=YesPlease
+	NO_MKDTEMP = YesPlease
+	NO_MMAP = YesPlease
+	NO_EXTERNAL_GREP = UnfortunatelyYes
+	SNPRINTF_RETURNS_BOGUS = YesPlease
 	SHELL_PATH=/usr/gnu/bin/bash
-	BASIC_CFLAGS += -DPATH_MAX=1024
-	# for now, build 32-bit version
-	BASIC_LDFLAGS += -L/usr/lib32
+	NEEDS_LIBGEN = YesPlease
 endif
 ifeq ($(uname_S),HP-UX)
 	NO_IPV6=YesPlease
-- 
1.6.4.rc0.5.g76f7cf
Junio C Hamano· Jul 11, 2009, 06:44 UTC · re: Brandon Casey · lore

Re: [PATCH FYI 0/5] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh

Brandon Casey <casey@nrlssc.navy.mil> writes:
> Otherwise, I've been using this executable somewhat and have not experienced
> any problems.  Maybe it will be useful to others.
>
> Are there actually any IRIX users out there?

I thought at some point Dscho was suffering from IRIX but perhaps he got out of it?

> These patches are all submitted For-Your-Information only.  Junio, feel free
> to apply any of them or none, and to add my Signed-off-by.

Except for 5/5 all of them looked trivially safe and none of them looked iffy. Will queue, possibly with minor tweaks.

← back to recent threads