[m-rev.] diff: improve PIC option handling
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Feb 14 20:52:35 AEDT 2003
On 13-Feb-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 13-Feb-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 13-Feb-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > >
> > > compiler/handle_options.m:
> > > Make `--mercury-linkage shared' imply `--pic-reg'.
> >
> > What about systems on which shared libraries don't require PIC,
> > in particular Windows DLLs?
>
> On those systems `--pic-reg' should have no effect.
Well, that's not currently the case. But it is probably a good idea.
Hence the following patch.
----------
Estimated hours taken: 1.5
Branches: main
Ensure that we ignore the `--pic-reg' option on Windows.
`--pic-reg' is not needed on Windows, since Windows DLLs
do not require position independent code.
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h:
Move the setting of MR_PIC and MR_PIC_REG from here...
runtime/mercury_conf_param.h:
... to here. Also, ensure that MR_PIC_REG is not set if
__CYGWIN__ or _WIN32 is defined.
compiler/compile_target_code.m:
Improve a slightly misleading comment.
Workspace: /home/ceres/fjh/mercury
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.38
diff -u -d -r1.38 compile_target_code.m
--- compiler/compile_target_code.m 12 Feb 2003 00:27:56 -0000 1.38
+++ compiler/compile_target_code.m 14 Feb 2003 09:17:03 -0000
@@ -1468,7 +1468,7 @@
% files if `-DMR_PIC_REG' has an
% effect, which currently is only
% with grades using GCC global
- % registers on x86.
+ % registers on x86 Unix.
( LinkWithPicObjExt = ObjExt
; HighLevelCode = yes
; GCCGlobals = no
Index: runtime/machdeps/i386_regs.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/machdeps/i386_regs.h,v
retrieving revision 1.21
diff -u -d -r1.21 i386_regs.h
--- runtime/machdeps/i386_regs.h 18 Feb 2002 07:01:27 -0000 1.21
+++ runtime/machdeps/i386_regs.h 14 Feb 2003 09:30:53 -0000
@@ -16,8 +16,8 @@
** (ebx, esi, edi). If we're using position-independent code (PIC),
** i.e. if this code is being compiled with `-fpic' or `-fPIC',
** then ebx is reserved, so we use only esi and edi.
-** We also avoid using ebx if compiled with -DPIC_REG;
-** compiling with -DPIC_REG but not -fpic allows one to
+** We also avoid using ebx if compiled with -DMR_PIC_REG;
+** compiling with -DMR_PIC_REG but not -fpic allows one to
** preserve link-compatibility with PIC code while generating
** non-PIC code.
**
@@ -37,20 +37,6 @@
** there are some functions for which gcc cannot avoid the use of
** the frame pointer. (E.g. the one containing io__init_state/2.)
*/
-
-/*
-** Are we using PIC?
-*/
-#if (defined(__PIC__) || defined(__pic__)) && !defined(MR_PIC)
- #define MR_PIC 1
-#endif
-
-/*
-** Should we keep the GOT register (ebx) free for PIC code?
-*/
-#if MR_PIC && !defined(MR_PIC_REG)
- #define MR_PIC_REG 1
-#endif
#if MR_PIC_REG
#define MR_NUM_REAL_REGS 2
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.67
diff -u -d -r1.67 mercury_conf_param.h
--- runtime/mercury_conf_param.h 2 Dec 2002 11:25:46 -0000 1.67
+++ runtime/mercury_conf_param.h 14 Feb 2003 09:37:36 -0000
@@ -365,6 +365,32 @@
#define MR_BOXED_FLOAT 1
#endif
+/*
+** MR_PIC means that we are generating position independent code,
+** i.e. that the file was compiled with the gcc option `-fpic' or equivalent.
+*/
+#if (defined(__pic__) || defined(__PIC__))
+ #define MR_PIC 1
+#endif
+
+/*
+** Should we keep the GOT register (e.g. ebx on i386) free for PIC code?
+** We need to do this if we are generating position independent code
+** (MR_PIC), or if we are linking with position independent Mercury code
+** (in which case -DMR_PIC_REG will be passed on the command line).
+**
+** The GOT register is only needed for Unix-style shared libraries.
+** Windows DLLs do not use the GOT register. So don't do this if
+** __CYGWIN__ or _WIN32 is defined, even if -DMR_PIC_REG was passed
+** on the command line.
+*/
+#if defined(MR_PIC)
+ #define MR_PIC_REG 1
+#endif
+#if defined(__CYGWIN__) || defined(_WIN32)
+ #undef MR_PIC_REG
+#endif
+
/* MR_LOWLEVEL_DEBUG implies MR_DEBUG_GOTOS and MR_CHECK_FOR_OVERFLOW */
#ifdef MR_LOWLEVEL_DEBUG
#define MR_DEBUG_GOTOS
Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.34
diff -u -d -r1.34 mercury_goto.h
--- runtime/mercury_goto.h 4 Feb 2003 04:51:16 -0000 1.34
+++ runtime/mercury_goto.h 14 Feb 2003 09:29:19 -0000
@@ -189,13 +189,10 @@
#define MR_JUMP(label) MR_ASM_JUMP(label)
/*
- ** If we're using position-independent code on i386, then we need to
- ** set up the correct value of the GOT register (ebx).
+ ** If we're using position-independent code, then we need to
+ ** set up the correct value of the GOT register (ebx on 386
+ ** or a5 on m68000).
*/
-
- #if (defined(__pic__) || defined(__PIC__)) && !defined(MR_PIC)
- #define MR_PIC 1
- #endif
#if MR_PIC
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list