[m-rev.] [b.schmidt at ugrad.unimelb.edu.au: PPC Darwin linking fix] (fwd)

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Dec 18 17:12:36 AEDT 2006



---------- Forwarded message ----------
Date: Thu, 14 Dec 2006 19:39:06 +1100
From: Zoltan Somogyi <zs at csse.unimelb.edu.au>
To: juliensf at csse.unimelb.edu.au
Subject: [b.schmidt at ugrad.unimelb.edu.au: PPC Darwin linking fix]

Ben sent this to me; I don't know whether he also sent to you.

Zoltan.

----- Forwarded message from Ben Schmidt <b.schmidt at ugrad.unimelb.edu.au> -----

Date: Thu, 14 Dec 2006 16:52:38 +1100
From: Ben Schmidt <b.schmidt at ugrad.unimelb.edu.au>
To: Zoltan Somogyi <zs at csse.unimelb.edu.au>
Subject: PPC Darwin linking fix

Proposed diff and log message attached.

Unfortunately, I presume that I can't include all the files required for
the complete fix, as they are part of GCC and Darwin (as documented in
the fix here). If someone knows more about this, or how to enforce a
link order to work around the problem (as documented), let me know.

Ben.


Index: README.MacOS
=================================================================== RCS
file: /home/mercury/mercury1/repository/mercury/README.MacOS,v
retrieving revision 1.9 diff -u -r1.9 README.MacOS --- README.MacOS
31 Jan 2006 13:31:01 -0000	1.9 +++ README.MacOS	11 Dec 2006
23:51:00 -0000 @@ -60,9 +60,12 @@  *building* such distributions!) The
version of tar that comes with Mac OS X  10.3.3 doesn't have this
problem.   -The linker on OS X may also have problems linking large
executables in debug -grades.  This affects all versions of ld that we
have tested and there is -currently no known workaround. +On PowerPC
Darwin, large executables (requiring branches > +/- 32 MB) will +cause
complaints about relocation displacements being too large in crt1.o and
+crt2.o. To solve this problem, versions of crt1.o (Darwin module
'Csu') and +crt2.o (part of gcc) need to be compiled with gcc options
-mlongcall and +-mlong-branch (modify the Makefiles) and replace the
system-provided versions +of those files.
-----------------------------------  Known bugs and unsupported
features Index: compiler/compile_target_code.m
=================================================================== RCS
file:
/home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.92 diff -u -r1.92 compile_target_code.m ---
compiler/compile_target_code.m	22 Aug 2006 05:03:40 -0000
1.92 +++ compiler/compile_target_code.m	11 Dec 2006 23:51:03 -0000 @@
-715,6 +715,29 @@          AppleGCCRegWorkaroundOpt = ""      ),   +
% On PPC Darwin, large executables need to be compiled with -mlongcall
+    % (and in GCC  +/- 32 MB. The linker will choose  +    % whether
to ignore or use the glue code the compiler generates, +    % however,
so there should be no real speed penalty, only a size +    % penalty,
to always enabling this. Versions of crt1.o (Darwin  +    % module
'Csu') and crt2.o (part of gcc) also need to be compiled  +    % with
this option(s) (modify the Makefiles) and replace the +    %
system-provided ones for this to fully work, or a link order enforced +
    % so that the jumps from system initialisation code to the program +
    % (probably just to the entry point) are small. + +    ( +
string.prefix(FullArch, "powerpc-apple-darwin") +    -> +
AppleGCCLongCallOpt = "-mlongcall -mlong-branch" +    ; +
AppleGCCLongCallOpt = "" +    ), +      % Be careful with the order
here!  Some options override others,      % e.g. CFLAGS_FOR_REGS must
come after OptimizeOpt so that      % it can override
-fomit-frame-pointer with -fno-omit-frame-pointer. @@ -744,6 +767,7 @@
         InlineAllocOpt, " ",           AnsiOpt, " ",
AppleGCCRegWorkaroundOpt, " ",  +        AppleGCCLongCallOpt, " ",
      WarningOpt, " ",           CFLAGS,           " -c ", C_File, " ",
Index: scripts/mgnuc.in
=================================================================== RCS
file: /home/mercury/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.116 diff -u -r1.116 mgnuc.in --- scripts/mgnuc.in
15 Aug 2006 04:19:39 -0000	1.116 +++ scripts/mgnuc.in	11 Dec
2006 23:51:30 -0000 @@ -548,6 +548,25 @@      esac  esac   +# On PPC
Darwin, large executables need to be compiled with -mlongcall +# (and
in GCC  +/- 32 MB. The linker will choose  +# whether to ignore or use
the glue code the compiler generates, +# however, so there should be no
real speed penalty, only a size +# penalty, to always enabling this.
Versions of crt1.o (Darwin  +# module 'Csu') and crt2.o (part of gcc)
also need to be compiled  +# with this option(s) (modify the Makefiles)
and replace the +# system-provided ones for this to fully work, or a
link order enforced +# so that the jumps from system initialisation
code to the program +# (probably just to the entry point) are small. +
+case $FULLARCH in powerpc*apple*darwin*) +    ARCH_OPTS="$ARCH_OPTS
-mlongcall -mlong-branch" ;; +esac +  case $assemble in true)      case
$verbose in true)          echo $AS $AS_OPTS "$@" ;;




  Estimated hours taken: 2 + many (20ish) looking at GCC, Darwin, PPC,
etc. Branches:
Add compiler flags relevant to PPC Darwin (Mac OS X).
README.MacOS: 	Updated documentation; read it for more info.
compiler/compile_target_code.m: scripts/mgnuc.in: 	Add compiler
flags relevant to PPC Darwin (Mac OS X) when 	appropriate.






----- End forwarded message -----
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list