GCC On IRIX -- a lot of stuff I'm learning about this
#1
GCC On IRIX -- a lot of stuff I'm learning about this
Ok, so the GCC guides and build systems out there that allow GCC building, all in all are filled with well-intentioned but often outright contrary to proper GCC guidelines for building a working compiler without a lot of pain. Part of this is why I'm doing something about this. 

Let's start:

1. Many patches directly edit fixincl.x, for the fixincludes part of GCC. This is not supposed to be done. I know /why/ many people do this, mind you, but it makes it hard to port patches between GCC versions. This requires autogen and guile to be installed, and thus is a bit more of a pain in the ass, but I will not, for any future source tree patches I publish. Otoh, for prepatched code that's ready to go, and has sufficient instructions, this is probably not an issue. Thankfully, many of the patch authors have also applied them to the include definitions that are called to build fixincl.x, so that's helpful at the very least if you need to regenerate that. 

2. I've been building the libs and such out of tree, but everything I've read from GCC literature, as well as the advice of a good friend whose developed for GCC in the past, has indicated to me this is not the right way to do it. You should use contrib/download_prerequisites whenever possible, or if you have your own versions of GMP, MPC, MPFR etc to build against, put those in tree. This is also easier if you intend, as I do, to have multiple GCC versions installed. I would rather, because all of these are basically reinstatements of GCC, have as much coverage through known-good versions and multiple points of potential failure; if a particular version of GCC does better with a certain program, we can help keep track of this between ourselves. I do usually put GMP out of tree, but that's because I have a lot of small patches for it and some custom configure scripts I haven't figured out how to pass to GCC downstream. I WILL be updating the script with the particulars of what versions I used, and the commands I used for them.

3. IRIX tar has path length limitations that cause some path names on GCC to get corrupted, usually for libstdc++ and parts of the testsuite. star, gnu tar, and bsdtar from libarchive all work. I have a schily tar tardist available as well that makes this easy. 

4. After I get the GCC versions all built, I plan to go back and see how hard is it for us to patch them using IRIX ld and IRIX as. I don't know if this will make any differences code or performance-wise, but like many of us here, I'm leery of binutils. Danielhams' patches are pretty good and I've had only a few weirdness issues from them that I was able to solve with some ease; sometimes though I wonder if IRIX's ld or as can do better, as a few users here prefer the use of IRIX's as for perceived ASM benefits. I found some longstanding bugs that broke bootstrapping, and some unfixed GMP bugs that an old pkgsrc post came up with. 

5. LTO appears to be broken, both for the didbs builds, and for Erno's builds, as well as Nekoware's GCC. This is also true of mine

6. I am releasing a new Nekoware I GCC compiler. This will mostly be for the benefit of those who have any interest in Nekoware 1 -- Nekoware II is gonna happen... eventually.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-09-2021, 09:55 PM
#2
RE: GCC On IRIX -- a lot of stuff I'm learning about this
Multilib also appears broken, in particular stuff with libgomp. If someone's interested in n64 or o32 GCC, i can probably figure it out, but I'm gonna focus on n32 GCC for now.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-10-2021, 06:54 PM
#3
RE: GCC On IRIX -- a lot of stuff I'm learning about this
(06-10-2021, 06:54 PM)Raion Wrote:  Multilib also appears broken, in particular stuff with libgomp. If someone's interested in n64 or o32 GCC, i can probably figure it out, but I'm gonna focus on n32 GCC for now.

Many thanks for this work! The n32 target is probably the most important.

I am no longer posting from the moose, SGI O2 with R10k/250, 1GB RAM,  IRIX 6.5.27, unfortunately.
O2  1600SW  1600SW  Indy Indy Indigo  Indigo  Indigo2 R10000/IMPACT  Octane
jirka
Octane

Trade Count: (0)
Posts: 121
Threads: 4
Joined: May 2018
Location: Ostrava, Czech Republic
Find Reply
06-10-2021, 08:04 PM
#4
RE: GCC On IRIX -- a lot of stuff I'm learning about this
Building everything in-tree:

This is broken with SGUG builds and patches. There's also some crucial omissions that were made, likely not intentional, that caused some weird issues with this. This is not a dig against them, mind you, just me sharing what I've learnt:

Patching GMP: 

https://pkgsrc-bugs.netbsd.narkive.com/b...ld-on-irix

These patches must be applied to make GMP build in tree. 

Patching Libgomp:

Originally brought to my attention by Larbob, libgomp on IRIX doesn't properly detect multiple CPUs. 

Code:
diff -urnp libgomp-orig/config/posix/proc.c libgomp/config/posix/proc.c
*** libgomp-orig/config/posix/proc.c    Sat Dec  8 14:57:52 2012
--- libgomp/config/posix/proc.c Sat Dec  8 14:58:43 2012
***************
*** 38,43 ****
--- 38,48 ----
  #endif
 
 
+ #ifdef __sgi
+ #define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+ #endif
+
+
  /* At startup, determine the default number of threads.  It would seem
     this should be related to the number of cpus online.  */


To fix bootstrapping builds, you need to patch gcc/dwarf2cfi.c:

Code:
--- dwarf2cfi.c    2012-01-10 00:28:55.000000000 -0800
+++ dwarf2cfi_patch.c    2018-07-20 14:42:17.251616220 -0700
@@ -1240,6 +1240,10 @@

   add_cfi_restore (regno);
   update_row_reg_save (cur_row, regno, NULL);
+  if (REG_P (INCOMING_RETURN_ADDR_RTX)
+    && regno == dwf_regno (INCOMING_RETURN_ADDR_RTX)
+    && regno != DWARF_FRAME_RETURN_COLUMN)
+    reg_save (DWARF_FRAME_RETURN_COLUMN, regno, 0);
}

/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_WINDOW_SAVE.

Make sure download_prerequists symlinks everything. On GCC 4.9.x and before, you can use Cloog for graphite optimizations. I don't recommend ppl, because it's a pain to build in tree, unless you patch getopt.h to include libxg's <compat/getopt.h> which I've never tested, and add -lxg to ppl to add getopt support. isl though, is fine. symlink cloog to your actual unpacked cloog directory name. 

For libstdc++v3, SGUG's RSE includes patches that add to sections of configure and acinclude.m4 $OPT_LDFLAGS to prevent pthread linking issues. 

https://raw.githubusercontent.com/sgidev...pp01.patch

https://raw.githubusercontent.com/sgidev...pp02.patch

You may need to manually find and apply the lines on older versions, but I'll be releasing standalone, compound patches for helping with this. I will also explicitly be cleaning up a lot of messiness in danielhams' didbs packages (many things in there only apply to MINGW/DJGPP, which is not relevant for us) as well as looking into trying to get GNAT working perhaps. I can't guarantee it, though. If someone who knows alt languages wants Fortran, ObjC, or even Java support, I can try to help. I'm not thrilled about this, mind you, because GCC is annoying in places, but I've accepted that this is pragmatic to go ahead and use the stuff SGUG's userbase has graciously tested, and perhaps some of what I reveal here can be given back to them if they want. All I would ask for is credit for any issues I independently discover, the stuff here though, just lift straight up since I don't know who originally discovered some of these patches. 

I also recommend not doing what I did, not realizing it can break things, and build in a separate directory from GCC's tree. I used dejagnu from didbs, but I suspect Nekoware's would work too. 

Expect the new GCC soonish. i want to see if it can compile newer versions of GCC without compounding erroneous builds, and I have a mountain of older GCC patches and notes and forum posts to go through, plus help from a friend. GCC 4.8.5 testsuite results: https://pastebin.com/dXmcaeUv -- some of these are probably due to removed support for IRIX. I'd like to get them minimized, so if anyone has any ideas or helpful stuff I may have overlooked, I'd appreciate it.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-12-2021, 12:24 AM
#5
RE: GCC On IRIX -- a lot of stuff I'm learning about this
GCC 4.8.5 cannot build 4.9.5 due to changes in libiberty.h that aren't quite understood. Rather than hack it, I just removed the offending macro:

Code:
--- libiberty.h-4.8    2021-06-12 13:42:19.996095000 -0400
+++ libiberty.h-4.9    2021-06-12 13:42:41.491232000 -0400
@@ -1,7 +1,7 @@
/* Function declarations for libiberty.

    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
   
    Note - certain prototypes declared in this header file are for
    functions whoes implementation copyright does not belong to the
@@ -85,11 +85,11 @@

/* Expand "@file" arguments in argv.  */

-extern void expandargv PARAMS ((int *, char ***));
+extern void expandargv (int *, char ***);

/* Write argv to an @-file, inserting necessary quoting.  */

-extern int writeargv PARAMS ((char **, FILE *));
+extern int writeargv (char **, FILE *);

/* Return the number of elements in argv.  */

@@ -107,7 +107,7 @@
    is 1, we found it so don't provide any declaration at all.  */
#if !HAVE_DECL_BASENAME
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME)
-extern char *basename (const char *);
+extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
#else
/* Do not allow basename to be used if there is no prototype seen.  We
    either need to use the above prototype or have one from
@@ -118,18 +118,18 @@

/* A well-defined basename () that is always compiled in.  */

-extern const char *lbasename (const char *);
+extern const char *lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);

/* Same, but assumes DOS semantics (drive name, backslash is also a
    dir separator) regardless of host.  */

-extern const char *dos_lbasename (const char *);
+extern const char *dos_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);

/* Same, but assumes Unix semantics (absolute paths always start with
    a slash, only forward slash is accepted as dir separator)
    regardless of host.  */

-extern const char *unix_lbasename (const char *);
+extern const char *unix_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);

/* A well-defined realpath () that is always compiled in.  */

@@ -139,7 +139,7 @@
    the last argument of this function, to terminate the list of
    strings.  Allocates memory using xmalloc.  */

-extern char *concat (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL;
+extern char *concat (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;

/* Concatenate an arbitrary number of strings.  You must pass NULL as
    the last argument of this function, to terminate the list of
@@ -148,7 +148,7 @@
    pointer to be freed after the new string is created, similar to the
    way xrealloc works.  */

-extern char *reconcat (char *, const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL;
+extern char *reconcat (char *, const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;

/* Determine the length of concatenating an arbitrary number of
    strings.  You must pass NULL as the last argument of this function,
@@ -161,14 +161,14 @@
    to terminate the list of strings.  The supplied memory is assumed
    to be large enough.  */

-extern char *concat_copy (char *, const char *, ...) ATTRIBUTE_SENTINEL;
+extern char *concat_copy (char *, const char *, ...) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;

/* Concatenate an arbitrary number of strings into a GLOBAL area of
    memory.  You must pass NULL as the last argument of this function,
    to terminate the list of strings.  The supplied memory is assumed
    to be large enough.  */

-extern char *concat_copy2 (const char *, ...) ATTRIBUTE_SENTINEL;
+extern char *concat_copy2 (const char *, ...) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;

/* This is the global area used by concat_copy2.  */

@@ -226,7 +226,7 @@

/* Choose a temporary directory to use for scratch files.  */

-extern char *choose_temp_base (void) ATTRIBUTE_MALLOC;
+extern char *choose_temp_base (void) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;

/* Return a temporary file name or NULL if unable to create one.  */

@@ -256,7 +256,7 @@

/* ANSI's strerror(), but more robust.  */

-extern char *xstrerror (int);
+extern char *xstrerror (int) ATTRIBUTE_RETURNS_NONNULL;

/* Return the maximum signal number for which strsignal will return a
    string.  */
@@ -298,30 +298,30 @@
    message to stderr (using the name set by xmalloc_set_program_name,
    if any) and then call xexit.  */

-extern void *xmalloc (size_t) ATTRIBUTE_MALLOC;
+extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;

/* Reallocate memory without fail.  This works like xmalloc.  Note,
    realloc type functions are not suitable for attribute malloc since
    they may return the same address across multiple calls. */

-extern void *xrealloc (void *, size_t);
+extern void *xrealloc (void *, size_t) ATTRIBUTE_RETURNS_NONNULL;

/* Allocate memory without fail and set it to zero.  This works like
    xmalloc.  */

-extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC;
+extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;

/* Copy a string into a memory buffer without fail.  */

-extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
+extern char *xstrdup (const char *) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;

/* Copy at most N characters from string into a buffer without fail.  */

-extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC;
+extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;

/* Copy an existing memory buffer to a new memory buffer without fail.  */

-extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC;
+extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;

/* Physical memory routines.  Return values are in BYTES.  */
extern double physmem_total (void);
@@ -399,7 +399,7 @@
    Returns NULL on error.  */

extern struct pex_obj *pex_init (int flags, const char *pname,
-                 const char *tempbase);
+                 const char *tempbase) ATTRIBUTE_RETURNS_NONNULL;

/* Flags for pex_run.  These are bits to be or'ed together.  */

This is allowing 4.9.5 or 5.x to be built by 4.8.5 and before.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-12-2021, 05:51 PM
#6
RE: GCC On IRIX -- a lot of stuff I'm learning about this
gfortran appears to compile on IRIX OK, for anyone interested in that. GNAT requires, well, gnat, and I haven't a working version of that yet. I haven't tried GCJ, but should someone really want GCJ for some reason, I can try. I won't be building gfortran likely in every version of GCC I produce, but I'll add it to the recent one.

Is anyone interested in ObjC?

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-13-2021, 01:37 AM
#7
RE: GCC On IRIX -- a lot of stuff I'm learning about this
(06-13-2021, 01:37 AM)Raion Wrote:  gfortran appears to compile on IRIX OK, for anyone interested in that. GNAT requires, well, gnat, and I haven't a working version of that yet. I haven't tried GCJ, but should someone really want GCJ for some reason, I can try. I won't be building gfortran likely in every version of GCC I produce, but I'll add it to the recent one.

Is anyone interested in ObjC?

Why not try GNAT 1.3 for Irix in Archive.org?  There was a gnat 1.4 but I've only seen a disc pic, ever seen files.

https://archive.org/details/sgi_Ada95_Co....4_and_6.5
weblacky
I play an SGI Doctor, on daytime TV.

Trade Count: (10)
Posts: 1,716
Threads: 88
Joined: Jan 2019
Location: Seattle, WA
Find Reply
06-13-2021, 02:30 AM
#8
RE: GCC On IRIX -- a lot of stuff I'm learning about this
It's not likely to work man. GNAT for this version of GCC requires a much later GNAT version. I may try with this sooner or later:

http://ftp.irixnet.org/nekoware/obsolete....1.tardist

that would be my best plan of attack.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-13-2021, 02:54 AM
#9
RE: GCC On IRIX -- a lot of stuff I'm learning about this
(06-13-2021, 01:37 AM)Raion Wrote:  Is anyone interested in ObjC?

No.

O2 Indigo2 R10000/IMPACT
synthetix
gcc -O3

Trade Count: (0)
Posts: 45
Threads: 11
Joined: Aug 2020
Location: 🇺🇸
Find Reply
06-13-2021, 07:09 AM
#10
RE: GCC On IRIX -- a lot of stuff I'm learning about this
(06-13-2021, 07:09 AM)synthetix Wrote:  No.

Quite definitive LAWL. I only ask as the GCC versions in Nekoware had Ada, GCJ, ObjC etc. Didn't know if someone had a specific need for them.

I can probably try the d frontend at some point, but no guarantees; I've never worked with that.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-13-2021, 03:02 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)