Bug 690878 - -dHAVE_FILE64 fails on 32 bit systems
Summary: -dHAVE_FILE64 fails on 32 bit systems
Status: RESOLVED FIXED
Alias: None
Product: GhostPCL
Classification: Unclassified
Component: PCL interpreter (show other bugs)
Version: unspecified
Hardware: Macintosh MacOS X
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks: 690776
  Show dependency tree
 
Reported: 2009-11-02 07:55 UTC by Henry Stiles
Modified: 2013-11-08 01:33 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
some autoconf stuff to auto-detect file64, etc (12.72 KB, patch)
2010-06-30 03:20 UTC, Hin-Tak Leung
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Henry Stiles 2009-11-02 07:55:18 UTC
The following patch crashes any job:

svn diff
Index: main/pcl6_gcc.mak
===================================================================
--- main/pcl6_gcc.mak   (revision 10247)
+++ main/pcl6_gcc.mak   (working copy)
@@ -178,13 +178,15 @@
 HAVE_STDINT_H_DEFINE?=-DHAVE_STDINT_H
 HAVE_MKSTEMP_DEFINE?=-DHAVE_MKSTEMP
 HAVE_HYPOT_DEFINE?=-DHAVE_HYPOT
+HAVE_FILE64_DEFINE?=-DHAVE_FILE64

-GCFLAGS?=-Wall -Wundef -Wstrict-prototypes -Wmissing-declarations \
+Gcflags?=-Wall -Wundef -Wstrict-prototypes -Wmissing-declarations \
         -Wmissing-prototypes -Wpointer-arith \
         -Wwrite-strings -Wno-strict-aliasing \
         -fno-builtin -fno-common \
          $(HAVE_STDINT_H_DEFINE) $(HAVE_MKSTEMP_DEFINE) $(HAVE_HYPOT_DEFINE) \
-          $(GX_COLOR_INDEX_DEFINE) $(PSICFLAGS) $(PDL_INCLUDE_FLAGS)
+          $(GX_COLOR_INDEX_DEFINE) $(PSICFLAGS) $(PDL_INCLUDE_FLAGS) \
+          $(HAVE_FILE64_DEFINE)

 CFLAGS?= $(GCFLAGS) $(XCFLAGS)

Index: pl/plmain.c
===================================================================
--- pl/plmain.c (revision 10247)
+++ pl/plmain.c (working copy)
@@ -790,7 +790,7 @@
 /* Process the options on the command line. */
 static FILE *
 pl_main_arg_fopen(const char *fname, void *ignore_data)
-{      return fopen(fname, "r");
+{      return gp_fopen_64(fname, "r");
 }

 static void
@@ -1235,7 +1235,7 @@
        if (fname[0] == '-' && fname[1] == 0)
           cursor->strm = mem->gs_lib_ctx->fstdin;
       else
-           cursor->strm = fopen(fname, "rb");
+           cursor->strm = gp_fopen_64(fname, "rb");
       if (!cursor->strm)
         return gs_error_ioerror;



make pcl XCFLAGS="-D_FILE_OFFSET_BITS=64" works without any code changes but it
was desired to use the portability layer and gp_fopen_64.
Comment 1 Ralph Giles 2009-11-02 23:26:57 UTC
Makefile variables are case sensitive, so the Gcflags you're setting your patch
isn't the same as GCFLAGS which is passed to the compiler. Apparently some of
the other options are required: if I use the all-upper case define, I don't get
a segfault.

Universally defining HAVE_FILE64 doesn't work on my mac (MacOS X 10.4 intel), so
some conditional define is necessary. Sorry, I forgot fopen64() etc. aren't
always available.

It's not ideal, but defining _FILE_OFFSET_BITS=64 just for the pcl build and
hoping for the best would work. I was arguing that you couldn't just delete the
gp_* stuff, not that it couldn't be cleaned up, or that the ghostpdl builds,
with their narrower platform support couldn't ignore the issue.
Comment 2 Henry Stiles 2009-11-03 07:44:49 UTC
Sorry that was a stupid finger fumble.

> Universally defining HAVE_FILE64 doesn't work on my mac (MacOS X 10.4 intel), so
> some conditional define is necessary. Sorry, I forgot fopen64() etc. aren't
> always available.
>
> It's not ideal, but defining _FILE_OFFSET_BITS=64 just for the pcl build and
> hoping for the best would work. I was arguing that you couldn't just delete the
> gp_* stuff, not that it couldn't be cleaned up, or that the ghostpdl builds,
> with their narrower platform support couldn't ignore the issue.

It doesn't help windows.  HAVE_FILE64 can be set in the pcl6_msvc.mak and
pcl6_gcc.mak as a commented out option with a comment to uncomment if 64 bit
access is needed and supported.

Assign it back to me if you want me to make the change.
Comment 3 Hin-Tak Leung 2010-05-02 03:13:09 UTC
Grabbing a Ralph's bugs.
Comment 4 Hin-Tak Leung 2010-05-19 14:52:00 UTC
a bit of autoconf doesn't need to hurt too much?
Comment 5 Hin-Tak Leung 2010-06-30 03:20:52 UTC
Created attachment 6411 [details]
some autoconf stuff to auto-detect file64, etc

some autoconf stuff to auto-detect file64, etc and insert them into main/pcl6_gcc.mak .

This mostly works like ghostscript's ./autogen.sh (except smaller and faster): it creates a ./configure script which tries to detect fopen64 and etc and put them in main/pcl6_gcc.mak , to avoid the editing.

There is only one option: "./configure --with-old", which revert main/pcl6_gcc.mak to how it was shipped. (this is mainly so that svn update can still work).
Comment 6 Hin-Tak Leung 2010-06-30 03:24:36 UTC
Work flow should work as it was - the user just has the new choice of optionally run ./autogen.sh  (or ./configure in a release) to massage main/pcl6_gcc.mak
before he runs "make", as usual.

(and "./autogen.sh --with-old" or "./configure --with-old" to revert all manual or automatic edits).
Comment 7 Hin-Tak Leung 2010-07-02 00:00:19 UTC
Re-assign back to reporter to test the patch. Some more code changes of fopen() to gp_fopen_64() etc probably are needed, but at least the new ./autgen.sh / ./configure should auto-detect the presence or absence of 64-bit file access support on 32-bit system and set (not set) -DHAVE_FILE64 .
Comment 8 Henry Stiles 2010-07-29 16:42:52 UTC
Please don't adopt the patches in this bug directly.  I think we need to talk to somebody in the know about LFS and reassess how ghostscript is handling LFS not just pcl.  Changing to P4 as the customer has a workaround.
Comment 9 Hin-Tak Leung 2010-07-29 16:55:20 UTC
FYI, there is(was?) a 64-bit migration guide on Apple's dev web site I remember coming across which discusses these issues. (as well as a sizeable portion of glibc's release notes on linux systems).
Comment 10 Chris Liddell (chrisl) 2013-11-08 01:33:16 UTC
GhostPDL now sets the HAVE_FILE64 compile flag the same as Ghostscript:

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=f59dba32