gcc pragma pack on hpux
Eric Frias
efrias@syncad.com
Mon Dec 20 20:24:00 GMT 2004
John David Anglin wrote:
[regarding enabling #pragma pack on HP-UX, which for some reason is
disabled in gcc]
> The maximum alignment available for bss/common variables is 8 bytes
> with the 32-bit SOM linker. That's the only restriction that I'm
> aware of, Thus, it may be ok to define HANDLE_PRAGMA_PACK_PUSH_POP
> in the file hpux.h.
I've just tried running the GCC test suite (make check-gcc), and it
looks good. I did three tests: first with the gcc-3.4.2 distribution,
next with HANDLE_PRAGMA_PACK_PUSH_POP in pa/pa-hpux.h, and finally
defining HANDLE_PRAGMA_PACK defined instead. The results of all three
tests were identical:
=== gcc Summary ===
# of expected passes 24024
# of expected failures 69
# of unresolved testcases 22
# of untested testcases 7
# of unsupported tests 373
/devel/syncad/build-gcc-3.4.2/gcc/xgcc version 3.4.2
I don't know how you choose which version of #pragma pack should be
enabled for this platform. If the choice is based on what the native
compilers do, it looks like the non-push-pop version is closer to the
desired behavior. The native HP compiler's pragma pack is documented here:
http://docs.hp.com/en/8/pragmas.htm#pragma-pack
I'd like to make one of these #pragma pack options enabled by default on
HP-UX, unless there's a good reason why it should remain disabled.
Enabling it would make my life a lot easier and my source code a lot
cleaner (I'm not the only one, google turns up a two or three other
discussions where people had to work around the lack of #pragma pack on
hp). If this is possible, what can I do to help make it happen?
Thanks,
Eric
John David Anglin wrote:
>>I have a question about the HP-UX port of gcc, and from looking at the
>>gcc Contributors list it looks like you're the person to ask. I'm
>>working on porting some software (winelib) that makes heavy use of
>>#pragma pack, and gcc doesn't support this pragma on HP-UX. I was
>>hoping you could tell me why it is disabled.
>>
>>I tried adding the HANDLE_PRAGMA_PACK define to gcc's config files and
>>it looks like #pragma pack started working correctly (I haven't run the
>>regression tests yet to confirm it).
>
>
> I don't know. It hasn't come up in the period that I have been
> involved in GCC.
>
>
>>If necessary, I think I can use __attribute__((packed,aligned(x))) to
>>work around this, but it needs to be applied on a structure-by-structure
>>basis. The software I'm porting has about 10k lines surrounded by
>>pragma pack directives, so converting it to use attributes would be very
>>tedious.
>>
>>Do you know if turning on these options will break anything? Is there
>>any chance future releases of gcc will have this enabled by default?
>
More information about the Gcc
mailing list