From: TRANLE@intellicorp.com (Minh Tran-Le)
Subject: Re: AIX PS/2 implementation
Reply-To: tranle@intellicorp.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 29 Jul 1992 18:44:50 GMT

big@broue.rot.qc.ca (Patrick Drolet) wrote:
|Did anyone of you guys compiled gcc-2.2.2 under AIX PS/2 ?  (I know, I know,
|AIX PS/2 is not Sun OS, but I'm stuck with it).
|Anyways, I have a problem wich I cannot solve.
|

To compile gcc-2.2.2 under AIX PS/2 you need a patch for gcc (include at
the end of this message) and a modified version of gas-1.92.3 (alpha).
I can put somewhere for anonymous ftp my whole gas-1.92.3 compiled if 
somebody has space.  Or I can mail the diff for gas-1.92.3 to whoever 
wants it.

Minh Tran-Le.

note: if you have aix ps/2 up to the latest patch you can enable linking
      gcc with shared libraries by uncommenting BOOT_LDFLAGS in:
      config/t-aix386.

---------------------------------------------------------------------------
*** ./config/t-aix386-	Mon Jun 15 00:24:13 1992
--- ./config/t-aix386	Mon Jun 15 00:24:13 1992
***************
*** 0 ****
--- 1,12 ----
+ # The one that comes with the system is POSIX-compliant.
+ LIMITS_H =
+ 
+ # For svr3 we build crtbegin.o and crtend.o which serve to add begin and
+ # end labels to the .ctors and .dtors section when we link using gcc.
+ 
+ EXTRA_PARTS=crtbegin.o crtend.o
+ 
+ CC = gcc
+ BOOT_CFLAGS = -O2 -fno-strength-reduce $(CFLAGS)
+ #BOOT_LDFLAGS = -shlib
+ CFLAGS = 
*** ./config/aix386.h-	Thu Mar 19 12:42:02 1992
--- ./config/aix386.h	Mon Jun 15 00:24:14 1992
***************
*** 1,5 ****
  /* Definitions for IBM PS2 running AIX/386.
!    From: Minh Tran-Le <TRANLE@intellicorp.com>
!    Copyright (C) 1988 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
--- 1,5 ----
  /* Definitions for IBM PS2 running AIX/386.
!    From: Minh Tran-Le <tranle@intellicorp.com>
!    Copyright (C) 1988-1992 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
***************
*** 19,22 ****
--- 19,30 ----
  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
+ /* Define USE_GAS if you have the new version of gas that can handle
+  * multiple segments and .section pseudo op.  This will allow gcc to
+  * use the .init section for g++ ctor/dtor.
+  *
+  * If you don't have gas then undefined USE_GAS.  You will also have
+  * to use collect if you want to use g++
+  */
+ #define USE_GAS
  
  #include "i386.h"
***************
*** 35,54 ****
  #define TARGET_DEFAULT 1
  
! /* Use crt1.o as a startup file and crtn.o as a closing file.  */
! 
! #define STARTFILE_SPEC  \
!   "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crtbegin.o%s"
  
! #define LIB_SPEC "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} -lc \
!   crtend.o%s crtn.o%s"
  
! /* Special flags for the linker.  I don't know what they do.  */
  
! #define LINK_SPEC "%{K} %{!K:-K} %{T*} %{z:-lm}"
  
  /* Specify predefined symbols in preprocessor.  */
  
! #define CPP_PREDEFINES "-D_I386 -Di386 -DAIX -D_AIX"
  
  /* special flags for the aix assembler to generate the short form for all
     qualifying forward reference */
--- 43,85 ----
  #define TARGET_DEFAULT 1
  
! #define LIB_SPEC \
!   "%{shlib:-lc_s} -lc"
  
! /* Use crt1.o as a startup file and crtn.o as a closing file.  */
! #ifdef USE_GAS
! # define STARTFILE_SPEC  \
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crtbegin.o%s"
! # define ENDFILE_SPEC \
!   "crtend.o%s crtn.o%s"
! 
! #else
! # define STARTFILE_SPEC  \
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}"
! # define ENDFILE_SPEC \
!   "crtn.o%s"
! #endif
  
! /* Special flags for the linker:
!  * -K	   Loads the a.out header into the first bytes of the text segment,
!  *	   followed by the text segments from the object modules.  This flag
!  *	   is required on the PS/2.
!  * -Tnum   Makes num the starting address for the text segment of the output
!  *         file.  If not specified, the text segment begins at location zero.
!  * -elabel Makes label the entry point of the executable output file.
!  * -N      Makes the text writeable.
!  * -s      Strips the symbol table, line number information, and relocation
!  *         information from the output.
!  * -x      Does not enter local symbols in the output symbol table; enters only
!  *         external and static symbols.
!  */
  
! #define LINK_SPEC "%{K}%{!K:-K} %{T*} %{e*} %{N} %{s} %{x}"
  
  /* Specify predefined symbols in preprocessor.  */
  
! #define CPP_PREDEFINES "-Dps2 -Di386"
  
+ #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}%{!posix:-DAIX} -D_I386 -D_AIX -D_MBCS"
+ 
  /* special flags for the aix assembler to generate the short form for all
     qualifying forward reference */
***************
*** 56,67 ****
  #define ASM_SPEC "-s2"
  
  #undef ASM_FILE_START
  #define ASM_FILE_START(FILE) 					\
!   do { fprintf (FILE, "\t.file\t\"%s\"\n", dump_base_name);	\
!        if (optimize)						\
!           ASM_FILE_START_1 (FILE); 				\
!        else							\
!           fprintf (FILE, "\t.noopt\n");				\
!      } while (0)
  
  /* This was suggested, but it shouldn't be right for DBX output. -- RMS
--- 87,102 ----
  #define ASM_SPEC "-s2"
  
+ /* The .file pseudo op can only handle 14 characters filenames */
  #undef ASM_FILE_START
  #define ASM_FILE_START(FILE) 					\
!   do {								\
!     char *p = (char *) strrchr (dump_base_name, '/');		\
!     if (!p)							\
!       p = dump_base_name;					\
!     else p++;							\
!     fprintf ((FILE), "\t.file\t\"%s\"\n", p);			\
!     if (!optimize)						\
!       fprintf (FILE, "\t.noopt\n");				\
!   } while (0)
  
  /* This was suggested, but it shouldn't be right for DBX output. -- RMS
***************
*** 109,112 ****
--- 144,148 ----
     ASM_OUTPUT_LABEL ((FILE), (NAME)),			\
     fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)))
+ 
  
  /* Define a few machine-specific details of the implementation of
***************
*** 114,125 ****
  
  #undef INIT_SECTION_ASM_OP
! #define INIT_SECTION_ASM_OP     ".section .init,\"x\""
  
! #define CTOR_LIST_BEGIN				\
    asm (INIT_SECTION_ASM_OP);			\
    asm ("pushl $0")
! #define CTOR_LIST_END CTOR_LIST_BEGIN
  
! #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)	\
    do {						\
      init_section ();				\
--- 150,182 ----
  
  #undef INIT_SECTION_ASM_OP
! #undef CTORS_SECTION_ASM_OP
! #undef DTORS_SECTION_ASM_OP
! 
! #ifdef USE_GAS
! # define INIT_SECTION_ASM_OP     ".section .init,\"x\""
! # define CTORS_SECTION_ASM_OP	INIT_SECTION_ASM_OP
! # define DTORS_SECTION_ASM_OP	INIT_SECTION_ASM_OP
  
! # define CTOR_LIST_BEGIN			\
    asm (INIT_SECTION_ASM_OP);			\
    asm ("pushl $0")
! # define CTOR_LIST_END CTOR_LIST_BEGIN
  
! # define DTOR_LIST_BEGIN 			\
!   extern int __global_ctors_done
! # define DTOR_LIST_END				\
!   asm(".data");					\
!   int __global_ctors_done = 0
! 
! /* We use the same __CTOR_LIST__ stack for both the ctors and dtors.
!  * We push the ctor function followed by 1 and
!  * we push the dtor function followed by 2.
!  * This is because AIX PS/2 ld can handle only 1 .init section
!  */
! 
! /* A C statement (sans semicolon) to output an element in the table of
!    global constructors.  */
! # undef ASM_OUTPUT_CONSTRUCTOR
! # define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)	\
    do {						\
      init_section ();				\
***************
*** 126,129 ****
      fprintf (FILE, "\tpushl $");		\
      assemble_name (FILE, NAME);			\
!     fprintf (FILE, "\n");			\
    } while (0)
--- 183,232 ----
      fprintf (FILE, "\tpushl $");		\
      assemble_name (FILE, NAME);			\
!     fprintf (FILE, "\n\tpushl $1\n");		\
    } while (0)
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global destructors.  */
+ # undef ASM_OUTPUT_DESTRUCTOR
+ # define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)	\
+   do {						\
+     init_section ();				\
+     fprintf (FILE, "\tpushl $");		\
+     assemble_name (FILE, NAME);			\
+     fprintf (FILE, "\n\tpushl $2\n");		\
+   } while (0)
+ 
+ /* We can handle only ctors for now */
+ # undef DO_GLOBAL_CTORS_BODY
+ # define DO_GLOBAL_CTORS_BODY				\
+ do {							\
+   func_ptr *__CTOR_LIST__ = __builtin_alloca (0), *p;	\
+   int fn_type;						\
+   extern int __global_ctors_done;			\
+   if (__global_ctors_done)				\
+     {							\
+       for (p = __CTOR_LIST__; *p; p++)			\
+ 	if (*p++ == (func_ptr)2)			\
+ 	  (*p) ();					\
+     }							\
+   else							\
+     {							\
+        for (p = __CTOR_LIST__; *p; p += 2)		\
+          ;						\
+        while (p != __CTOR_LIST__)			\
+ 	 {						\
+ 	   func_ptr *fn = --p;				\
+ 	   if (*--p == (func_ptr)1)			\
+ 	     (*fn) ();					\
+ 	 }						\
+        __global_ctors_done = 1;				\
+     }							\
+ } while (0)
+ 
+ # ifdef CRT_BEGIN
+ #  define INVOKE__main
+ # endif /* CRT_BEGIN */
+ 
+ # undef DO_GLOBAL_DTORS_BODY
+ # define DO_GLOBAL_DTORS_BODY __do_global_ctors ()
+ #endif /* USE_GAS */
*** ./config/x-aix386-	Fri Jan 17 23:42:17 1992
--- ./config/x-aix386	Mon Jun 15 00:24:14 1992
***************
*** 2,5 ****
  ALLOCA = alloca.o
  
! # Is this right?
! # INSTALL=cp
--- 2,5 ----
  ALLOCA = alloca.o
  
! INSTALL = /usr/ucb/install -c
! RANLIB = /bin/true
*** ./configure-	Thu Jun 11 12:46:42 1992
--- ./configure	Mon Jun 15 00:24:15 1992
***************
*** 275,279 ****
  		xm_file=xm-aix386.h
  		xmake_file=x-aix386
! 		broken_install=yes
  		;;
  	i386-sun-sunos*)		# Sun i386 roadrunner
--- 275,279 ----
  		xm_file=xm-aix386.h
  		xmake_file=x-aix386
! 		tmake_file=t-aix386
  		;;
  	i386-sun-sunos*)		# Sun i386 roadrunner
*** ./Makefile.in-	Sun Jun 14 14:40:34 1992
--- ./Makefile.in	Mon Jun 15 00:24:16 1992
***************
*** 1629,1643 ****
  # because alloca.o is newer, we permit these recursive makes to compile
  # alloca.o.  Then cc1 is newer, so it won't have to be relinked.
! 	$(MAKE) CC="stage1/gcc -Bstage1/" CFLAGS="$(BOOT_CFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  	$(MAKE) stage2
! 	$(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="$(BOOT_CFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  
  bootstrap2: force
! 	$(MAKE) CC="stage1/gcc -Bstage1/" CFLAGS="$(BOOT_CFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  	$(MAKE) stage2
! 	$(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="$(BOOT_CFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  
  bootstrap3: force
! 	$(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="$(BOOT_CFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  
  # Compare the object files in the current directory with those in the
--- 1629,1643 ----
  # because alloca.o is newer, we permit these recursive makes to compile
  # alloca.o.  Then cc1 is newer, so it won't have to be relinked.
! 	$(MAKE) CC="stage1/gcc -Bstage1/" CFLAGS="$(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  	$(MAKE) stage2
! 	$(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="$(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  
  bootstrap2: force
! 	$(MAKE) CC="stage1/gcc -Bstage1/" CFLAGS="$(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  	$(MAKE) stage2
! 	$(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="$(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  
  bootstrap3: force
! 	$(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="$(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) LANGUAGES="$(LANGUAGES)"
  
  # Compare the object files in the current directory with those in the
*** ./limits.h-	Tue May 26 21:36:59 1992
--- ./limits.h	Mon Jun 15 08:40:16 1992
***************
*** 80,83 ****
--- 80,119 ----
  #endif
  
+ /* POSIX limit values  */
+ 
+ /* pathconf() specific constants...	*/
+ 
+ #define LINK_MAX	32767	/* Max value of file's link count	*/
+ #define MAX_INPUT	255	/* Max no of bytes in term input queue	*/
+ #define MAX_CANON	255	/* Max no of bytes in canonical input	*/
+ #define NAME_MAX	255	/* Max no of bytes in file name		*/
+ #define PATH_MAX	1023	/* Max no of bytes in pathname		*/
+ #define PIPE_BUF	40960	/* Max no of bytes written to pipe	*/
+ 
+ /* sysconf() specific constants...  */
+ 
+ #define NGROUPS_MAX	32	/* Max no of group ID's per process	*/
+ #define OPEN_MAX	200	/* Max no of open files per process	*/
+ #define ARG_MAX		16384	/* Max length of args for exec		*/
+ 
+ #define _POSIX_ARG_MAX		4096
+ #define _POSIX_CHILD_MAX	6
+ #define _POSIX_LINK_MAX		8
+ #define _POSIX_MAX_CANON	255
+ #define _POSIX_MAX_INPUT	255
+ #define _POSIX_NAME_MAX		14
+ #define _POSIX_NGROUPS_MAX	0
+ #define _POSIX_OPEN_MAX		16
+ #define _POSIX_PATH_MAX		255
+ #define _POSIX_PIPE_BUF		512
+ 
+ #ifndef _POSIX_SOURCE
+ /* defines for message catalog usage */
+ #define NL_ARGMAX       9               /* max number of printf args */
+ #define NL_MSGMAX       65535           /* max number of messages per set */
+ #define NL_SETMAX       65535           /* max number of set per catalog */
+ #define NL_TEXTMAX      4096            /* max message length in bytes */
+ #endif /* NOT _POSIX_SOURCE */
+ 
  #endif /* _MACH_MACHLIMITS_H_ */
  #endif /* _LIMITS_H___ */
*** ./ChangeLog-	Sun Jun 14 15:14:35 1992
--- ./ChangeLog	Mon Jun 15 00:43:49 1992
***************
*** 1,2 ****
--- 1,15 ----
+ Mon Jun 15 00:42:56 1992  Minh Tran-Le  (mtranle@paris)
+ 
+ 	* Makefile.in: changed bootstrap to use LDFLAGS="$(BOOT_LDFLAGS)".
+ 
+ 	* config/aix386.h: added handling of -posix and -shlib.
+ 	Conditionalize the code not to use .init section if USE_GAS is
+ 	not defined.
+ 	changed for aix386 ld which can only 1 additional .init section.
+ 
+ 	* configure: for aix386 added tmake_file and removed broken_install
+ 
+ 	* config/t-aix386: new file for aix386.
+ 
  Sun Jun 14 16:30:07 1992  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
  
-------

Newsgroups: gnu.gcc.bug