[cfe-dev] [RFC] Pragma pack/align

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Wed May 23 14:29:02 PDT 2018


On 5/23/2018 1:46 PM, Jason Liu via cfe-dev wrote:
>
> Currently Clang implements|pragma pack|mostly in the same way of what 
> Microsoft Windows compiler 
> does:https://msdn.microsoft.com/en-us/library/2e70t5y1.aspx
> However, there are platforms where|pragma pack|has different 
> syntax/semantics. For example,
> https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.2/com.ibm.xlc131.aix.doc/compiler_ref/pragma_pack.html
>

As far as I know, the current implementation of pragma pack in clang is 
compatible with both MSVC and gcc. "-fapple-pragma-pack" is a 
compatibility flag for transitioning old code which expected Apple gcc 
semantics (which was different from the regular gcc rules).

If you need -faix-pragma-pack, that's okay; there isn't really any 
better approach.  (You can turn it on by default for AIX targets in the 
clang driver, if you think that's appropriate?)

> There are two options I can try to pursue here:
>
>  1. Implement the new stack effect model for all platforms.
>     Pros : new mental model behind the stack effect might make more
>     sense for some users.
>     Cons: but it would break existing user code (if user are actually
>     using those|pragma align|). Hopefully|pragma align|is not used
>     pervasively on existing platforms, otherwise, it is a deal breaker.
>  2. Implement the new stack effect only on specific platform(AIX),
>     keep existing behavior for existing platforms.
>     Pros: no existing user code will get break.
>     Cons: it might be ugly to have different stack effect for
>     different platforms.
>
> I’m leaning towards on option 1 at this time because it’s cleaner 
> solution if people think the new mental model is better, and are okay 
> with the fact that some user code will get compiled differently if 
> they use|pragma align|and|pragma pack|together already.
>
> Please let me know if there are any concerns or questions about my 
> current proposal and design. Your feedback is appreciated.
>
>

We can't change the stack rules for pragma align on Apple targets; it's 
very likely to break existing code.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180523/bb15e114/attachment.html>


More information about the cfe-dev mailing list