Project

General

Profile

Feature #4609

add HANDLE_PRAGMA_PACK_PUSH_POP to gcc-4.4.4-il-3

Added by Richard PALO over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
tools - gate/build tools
Start date:
2014-02-17
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:

Description

[posted as an issue in github, and copied here]

As documented here (http://gcc.gnu.org/onlinedocs/gcc-3.2.1/gccint/Misc.html), I'd like to request adding `HANDLE_PRAGMA_PACK_PUSH_POP`. Gcc's future (post 4.4) is that this will become the default when `HANDLE_PRAGMA_PACK` is defined.
```
HANDLE_PRAGMA_PACK_PUSH_POP
Define this macro (to a value of 1) if you want to support the Win32 style pragmas #pragma pack(push,n) and #pragma pack(pop). The pack(push,n) pragma specifies the maximum alignment (in bytes) of fields within a structure, in much the same way as the aligned and packed _attribute_s do. A pack value of zero resets the behavior to the default. Successive invocations of this pragma cause the previous values to be stacked, so that invocations of #pragma pack(pop) will return to the previous value.
```

Currently, only `HANDLE_PRAGMA_PACK_WITH_EXPANSION` is defined in gcc/config/sol2.h.

`HANDLE_PRAGMA_PACK_PUSH_POP` could be defined there, or perhaps in sol2-10.h

To do a quick and dirty test without patching, I built oi-userland/components/illumos-gcc with the following:

richard@x3200:~/src/oi-userland/components/illumos-gcc$ git diff .
diff --git a/components/illumos-gcc/Makefile b/components/illumos-gcc/Makefile
index df86dd8..e984f21 100644
--- a/components/illumos-gcc/Makefile
+++ b/components/illumos-gcc/Makefile
@@ -26,6 +26,7 @@ include $(WS_TOP)/make-rules/configure.mk
 include $(WS_TOP)/make-rules/ips.mk

 CC_BITS=
+CPPFLAGS=      -DHANDLE_PRAGMA_PACK_PUSH_POP
 CFLAGS=                -g -O2
 CONFIG_SHELL=  /bin/sh

@@ -51,6 +52,7 @@ CONFIGURE_OPTIONS +=  --with-pkgversion="Illumos $(ILLUMOS_VERSION)" 
 CONFIGURE_OPTIONS +=   --with-bugurl="http://github.com/illumos/gcc/issues" 

 COMPONENT_BUILD_ENV=           SHELL=$(CONFIG_SHELL) CFLAGS="$(CFLAGS)" STAGE1_CFLAGS="$(CFLAGS)" CFLAGS_FOR_TARGET="$(CFLAGS)" 
+COMPONENT_BUILD_ENV+=          CPPFLAGS="$(CPPFLAGS)" STAGE1_CPPFLAGS="$(CPPFLAGS)" CPPFLAGS_FOR_TARGET="$(CPPFLAGS)" 
 COMPONENT_BUILD_GMAKE_ARGS=    -j8
 COMPONENT_BUILD_TARGETS=       bootstrap

The motivation to add this concerns acpica-unix2-20140214 integration, where (the following is an extract from changes.txt):
```
ACPICA headers: Deployed the use of #pragma pack(push) and #pragma
pack(pop) directives to ensure that the ACPICA headers are independent of
compiler settings or other host headers.
```
And a build produces the following:
```
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actypes.h:47: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actypes.h:1320: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acexcep.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acexcep.h:350: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl1.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl1.h:1146: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl2.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl2.h:1421: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl3.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl3.h:737: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/actbl.h:445: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acoutput.h:47: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acoutput.h:469: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acrestyp.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acrestyp.h:702: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acpiosxf.h:53: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acpiosxf.h:556: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acconfig.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acconfig.h:239: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acbuffer.h:48: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acbuffer.h:249: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acpixf.h:57: error: #pragma pack(push[, id], <n>) is not supported on this target [-Wpragmas]
/home/richard/ws/illumos-gate/usr/src/common/acpica/include/acpixf.h:836: error: #pragma pack(pop[, id], <n>) is not supported on this target [-Wpragmas]
```
Although I have requested upstream ACPICA to reconsider using only the `#pragma pack([n])` syntax, there are no garantees it will be respun.

Again, recent gcc versions, have this by default and clang does as well.

ps by inspection of c-pragma.[ch], I see no reason to believe any bad surprises could come from supporting this, for `c` programs anyway.
Although clang believes the following (from http://clang.llvm.org/docs/UsersManual.html):

clang supports the Microsoft #pragma pack feature for controlling record layout. GCC also contains support for this feature, however where MSVC and GCC are incompatible clang follows the MSVC definition.

History

#1

Updated by Rich Lowe over 6 years ago

  • Status changed from New to Closed

I have no problem with doing this if it helps with ACPI updates (though presumably patching it to just pack normally is always possible.

I'm also happy (happier, actually) dealing with illumos-gcc issues on github, rather than in the illumos-gate tracker, so I'll close this and (continue to) respond there. Sorry it took a few days for me to get to.

Also available in: Atom PDF