Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

CodeGen: ensure 8-byte aligned String Swift CF ABI #348

Merged
merged 1 commit into from Aug 13, 2019

Conversation

compnerd
Copy link
Collaborator

CFStrings should be 8-byte aligned when built for the Swift CF runtime
ABI as the atomic CF info field must be properly aligned. This is a
problem on 32-bit platforms which would give the structure 4-byte
alignment rather than 8-byte alignment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368471 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit ee5531b)

CFStrings should be 8-byte aligned when built for the Swift CF runtime
ABI as the atomic CF info field must be properly aligned.  This is a
problem on 32-bit platforms which would give the structure 4-byte
alignment rather than 8-byte alignment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368471 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit ee5531b)
@compnerd compnerd changed the base branch from stable to swift-5.1-branch August 10, 2019 17:24
@compnerd
Copy link
Collaborator Author

CC: @dexonsmith @millenomi

This is needed to repair Foundation on non-Darwin 32-bit targets. Since this is controlled by the -fcf-runtime-abi= flag, with the default being ObjC, this has no impact on the Darwin path as Darwin targets do not currently use the Swift runtime ABI (due to historical accidents). Additionally, this patch only changes things on 32-bit targets (watchOS is excluded as it is a Darwin target), as 64-bit targets would use sizeof(void *) as the alignment (which would be 8-bytes). Even there, it is increasing the alignment (4 -> 8) and should be safe for interoperability (even though there is not ABI guarantees yet on non-Darwin targets).

@dexonsmith dexonsmith self-requested a review August 13, 2019 03:01
Copy link
Contributor

@dexonsmith dexonsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@compnerd compnerd merged commit a85b02e into apple:swift-5.1-branch Aug 13, 2019
@compnerd compnerd deleted the r368471 branch August 13, 2019 03:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants