This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch/RFC] Enable PCH for mingw32


Hi

The attached patch gets PCH working on mingw32 host.

1) asm_out_file needs to be opened in binary mode, to match the
binary mode of the .pch file. This causes no problems at all for
GNU as.

2) After finishing reading asm_out_file in c-pch.c:c_common_write_pch,
we need to ensure that the next write operation will be permitted. Either
a call to a file-positioning function or setting _IOEOF is necessary to
comply with ISO C.

3) The alignment required for *reserving* address space on win32 hosts
differs from the alignment for *committing* memory in that space. The
allocation granularity is also required when mmap'ing a file at an offset.
I've added a new host macro to allow that to happen.

4) HOST_HOOKS_GT_PCH_GET_ADDRESS and HOST_HOOKS_GT_PCH_USE_ADDRESS
are implemented  using VirtualAlloc and MapViewOfFileEx w32api functions.

The patch causes no new regressions.  Prior to patch all pch testsuites
failed.  Now I get this with RUNTESTFLAGS=pch.exp

  === gcc Summary ===

# of expected passes  875
# of unexpected failures 7
# of untested testcases  28

The failures are all inline-3.c assembly comparisons, of the form:
line #100
<  .def _fmod; .scl 3; .type 32; .endef
> 
line #101
<  .def _rint; .scl 3; .type 32; .endef
> 

  === g++ Summary ===

# of expected passes  63
# of unexpected failures 9

The failures are assembly comparisons in system-1.C, system-2.C, static-
1.C and effectively the same as above, namely the files compiled with
pch lack the end-of-file list of .def directives for undefined external
functions.

I do not believe the failures are critical.. Indeed if I assemble and
compare dumps of the object files rather than assembly output, there are
no differences due to use of pch.  

The list of undefined external functions are output by
winnt.c:i386_pe_file_end. I do not know how these directives are used by
GNU as, but they do not seem to be needed. In fact, if I undefine
ASM_OUTPUT_EXTERNAL (where the external symbols are saved into a list)
in cygming.h, I can still build working executables and dlls (and the
pch testsuite failures are resolved). Am I missing something or are
these end-of-file directives just for compatability with other
assemblers/linkers as suggested by this comment in winnt.c. 

/* The Microsoft linker requires that every function be marked as
   DT_FCN.  When using gas on cygwin, we must emit appropriate .type
   directives.  */
 

Any comments on this would be appreciated.  I have tested only on
NT4 and XP, so if anybody could test on W9x I would be grateful.


Changelog

2004-05-31  Danny Smith  <dannysmith@users.sourceforge.net>

        * toplev.c (init_asm_output): Add explicit 'b' to mode when
        opening asm_out_file. 
        * c-pch.c (c_common_write_pch): Set EOF on asm_out_file when
        finished reading.
        * system.h (HOST_MMAP_ALLOC_GRANULARITY): New macro, defaulting
        to getpagesize().
        * gcc-common.c (gt_pch_save): Use HOST_MMAP_ALLOC_GRANULARITY
        rather than getpagesize when padding offset.
        * config.host (i[34567]86-*-mingw32*): Set out_host_hook_obj.
        * config/i386/xm-mingw32.h (HOST_MMAP_ALLOC_GRANULARITY):
        Override default.
        * config/i386/host-mingw32.c: New file.
        * config/i386/x-mingw32: Add rule for host-mingw32.o.

Danny

Attachment: mingw32-pch.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]