For those intererested, here is some information on building gpc-20051104 with gcc-3.4.4 on i686-apple-darwin8.
We need to build and install the right versions of sed, help2man, flex and bison first, but this has been discussed before (http://www.gnu-pascal.de/crystal/gpc/en/thread11480.html). Note that bison 2.1 is now needed (http://ftp.gnu.org/gnu/bison/).
Then, we need patches to gcc-3.4.4.
1. To build gcc-3.4.4 on Darwin-8 (Mac OS X 10.4) we need the following "Tiger" patch (see http://www.gnu-pascal.de/crystal/gpc/en/mail12302.html) as Apple changed the rules once again:
--- gcc/config/darwin.h.orig 2005-05-18 13:56:37.000000000 -0400 +++ gcc/config/darwin.h 2005-05-18 13:57:48.000000000 -0400 @@ -275,7 +275,8 @@ /* Machine dependent libraries. */
#undef LIB_SPEC -#define LIB_SPEC "%{!static:-lSystem}" +#define LIB_SPEC "%{!static:-lSystemStubs -lSystem}" +
/* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
2. Then, we need to fix a bug in i386/darwin.h (see http://www.gnu-pascal.de/crystal/gpc/en/mail12211.html).
--- gcc/config/i386/darwin.h.orig Thu Jun 16 01:10:29 2005 +++ gcc/config/i386/darwin.h Thu Jun 16 01:10:32 2005 @@ -43,7 +43,7 @@
/* Use the following macro for any Darwin/x86-specific command-line option translation. */ -#define SUBTARGET_OPTION_TRANSLATE_TABLE +#define SUBTARGET_OPTION_TRANSLATE_TABLE { 0, 0 }
#define ASM_SPEC "-arch i386 \ %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
3. Third, we have to fix a problem in config/darwin-crt2 with a system routine that is no longer present on i686-apple-darwin8 (see <http://www.opensource.apple.com/darwinsource/WWDC2004/keymgr-9/ keymgr.c>).
--- gcc/config/darwin-crt2.orig.c 2005-11-11 00:31:10.000000000 +0100 +++ gcc/config/darwin-crt2.c 2005-11-11 17:34:48.000000000 +0100 @@ -47,7 +47,14 @@ extern void __darwin_gcc3_preregister_frame_info (void);
/* These are from "keymgr.h". */ + +/* _init_keymgr is no longer needed and it breaks the build on i686-apple-darwin8, + see <http://www.opensource.apple.com/darwinsource/WWDC2004/keymgr-9/ keymgr.c> */ +#ifdef __PPC__ extern void _init_keymgr (void); +#endif + + extern void *_keymgr_get_and_lock_processwide_ptr (unsigned key); extern void _keymgr_set_and_unlock_processwide_ptr (unsigned key, void *ptr);
@@ -137,7 +144,9 @@ __darwin_gcc3_preregister_frame_info (void) { const _Tinfo_Node *info; +#ifdef __PPC__ _init_keymgr (); +#endif info = (_Tinfo_Node *)__keymgr_global[2]; if (info != NULL) {
4. Finally, there is gcc bug PR16649 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16649), one of the many bugs that never get fixed by the back-end guys, because of the ingenious excuses they have found for not fixing bugs:
1. it is not a bug but a "regression" 2. it is a "regression" but not a "serious regression" 3. it is a "serious regression" but not a "serious regression for a secondary target" 4. it is a "serious regression" but not a "serious regression for a primary target" 5. it is a "serious regression" but not "release critical" 6. it was never assigned to anybody 7. it was never targeted for a specific release 8. it was targeted for a specific release, but then retargeted by the "release manager" 9. we don't know how to fix it 10. we are not longer working on it 11. or (more honest) we are really not in the mood to fix it, adding another nonsensical optimizer phase is more sexy.
but here is the patch (see http://www.gnu-pascal.de/crystal/gpc/en/mail12213.html)
--- gcc/config/i386/i386.c.orig Wed Mar 16 16:23:40 2005 +++ gcc/config/i386/i386.c Thu Jun 16 13:33:02 2005 @@ -5810,6 +5810,28 @@
return term; } + +/* Allow {LABEL | SYMBOL}_REF - SYMBOL_REF-FOR-PICBASE for Mach-O as + this is used for to form addresses to local data when -fPIC is in + use. */ + +static bool +darwin_local_data_pic (rtx disp) +{ + if (GET_CODE (disp) == MINUS) + { + if (GET_CODE (XEXP (disp, 0)) == LABEL_REF + || GET_CODE (XEXP (disp, 0)) == SYMBOL_REF) + if (GET_CODE (XEXP (disp, 1)) == SYMBOL_REF) + { + const char *sym_name = XSTR (XEXP (disp, 1), 0); + if (! strcmp (sym_name, "<pic base>")) + return true; + } + } + + return false; +} /* Determine if a given RTX is a valid constant. We already know this satisfies CONSTANT_P. */ @@ -5829,6 +5851,9 @@ x = XEXP (x, 0); }
+ if (TARGET_MACHO && darwin_local_data_pic (x)) + return true; + /* Only some unspecs are valid as "constants". */ if (GET_CODE (x) == UNSPEC) switch (XINT (x, 1)) @@ -5980,18 +6005,8 @@ saw_plus = true; }
- /* Allow {LABEL | SYMBOL}_REF - SYMBOL_REF-FOR-PICBASE for Mach-O. */ - if (TARGET_MACHO && GET_CODE (disp) == MINUS) - { - if (GET_CODE (XEXP (disp, 0)) == LABEL_REF - || GET_CODE (XEXP (disp, 0)) == SYMBOL_REF) - if (GET_CODE (XEXP (disp, 1)) == SYMBOL_REF) - { - const char *sym_name = XSTR (XEXP (disp, 1), 0); - if (! strcmp (sym_name, "<pic base>")) - return 1; - } - } + if (TARGET_MACHO && darwin_local_data_pic (disp)) + return 1;
if (GET_CODE (disp) != UNSPEC) return 0;
5. Create a build directory, cd into it and configure with something like:
[Darwin:gpc-20051104/gpc344x1/build] adriaan% ../gcc-3.4.4/configure --enable-languages=c,pascal --enable-threads=posix --target=i686-apple-darwin8 --host=i686-apple-darwin8 --build=i686-apple-darwin8 --prefix=/Developer/Pascal/gpc344x1
6. Now, we can simply do a make with the system compiler that comes with Xcode 2.2 (gcc version 4.0.1 (Apple Computer, Inc. build 5247)) and a bootstrap is not needed.
[Darwin:gpc-20051104/gpc344x1/build] adriaan% make
7.Installation
[Darwin:gpc-20051104/gpc344x1/build] adriaan% sudo make install
8. And here we have the new compiler !
[Darwin:gcc/p/test] adriaan% gpc -v Reading specs from /Developer/Pascal/gpc344x1/lib/gcc/i686-apple-darwin8/3.4.4/specs Configured with: ../gcc-3.4.4/configure --enable-languages=c,pascal --enable-threads=posix --target=i686-apple-darwin8 --host=i686-apple-darwin8 --build=i686-apple-darwin8 --prefix=/Developer/Pascal/gpc344x1 Thread model: posix gpc version 20051104, based on gcc-3.4.4
(more about the testsuite in the next message)
Regards,
Adriaan van Os
In http://www.gnu-pascal.de/crystal/gpc/en/mail12869.html I wrote
- Third, we have to fix a problem in config/darwin-crt2 with a system
routine that is no longer present on i686-apple-darwin8 (see http://www.opensource.apple.com/darwinsource/WWDC2004/keymgr-9/ keymgr.c).
--- gcc/config/darwin-crt2.orig.c 2005-11-11 00:31:10.000000000 +0100 +++ gcc/config/darwin-crt2.c 2005-11-11 17:34:48.000000000 +0100 @@ -47,7 +47,14 @@ extern void __darwin_gcc3_preregister_frame_info (void);
/* These are from "keymgr.h". */
+/* _init_keymgr is no longer needed and it breaks the build on i686-apple-darwin8,
- see
http://www.opensource.apple.com/darwinsource/WWDC2004/keymgr-9/ keymgr.c */ +#ifdef __PPC__ extern void _init_keymgr (void); +#endif
- extern void *_keymgr_get_and_lock_processwide_ptr (unsigned key); extern void _keymgr_set_and_unlock_processwide_ptr (unsigned key,
void *ptr);
@@ -137,7 +144,9 @@ __darwin_gcc3_preregister_frame_info (void) { const _Tinfo_Node *info; +#ifdef __PPC__ _init_keymgr (); +#endif info = (_Tinfo_Node *)__keymgr_global[2]; if (info != NULL) {
That was wrong, I should have used __ppc__ instead of __PPC__ ! Interestingly, not calling _init_keymgr on powerpc-apple-darwin7 causes mir047h.pas to fail. Having a testsuite is really invaluable.
Regards,
Adriaan van Os