Skip to content

Add arm64e and pointer authentication support for Swift #30112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 8, 2020

Conversation

kubamracek
Copy link
Contributor

This PR upstreams the internally developed support for arm64e and pointer authentication in Swift. For details about pointer authentication, see http://lists.llvm.org/pipermail/llvm-dev/2019-October/136091.html, and for the LLVM and Clang changes, see swiftlang/llvm-project#14. This work is primarily authored by John McCall, with many smaller contributions by several others at Apple including myself.

@rjmccall
Copy link
Contributor

rjmccall commented Mar 2, 2020

The IRGen test conflicts should be trivial to fix: in this patch, the 64-bit test line has been split into ptrauth and non-ptrauth variants, so non just copy the new symbol name from the single 64-bit line into both, preserving the .ptrauth suffix on the ptrauth line.

@swiftlang swiftlang deleted a comment from swift-ci Mar 5, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 5, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 5, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 5, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@swiftlang swiftlang deleted a comment from swift-ci Mar 6, 2020
@kubamracek
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 7, 2020

Build failed
Swift Test OS X Platform
Git Sha - ab6533a

@swift-ci
Copy link
Contributor

swift-ci commented Mar 7, 2020

Build failed
Swift Test Linux Platform
Git Sha - ab6533a

@kubamracek
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@kubamracek
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 7, 2020

Build failed
Swift Test OS X Platform
Git Sha - c0ab0c9

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 7, 2020

Build failed
Swift Test Linux Platform
Git Sha - c0ab0c9

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 7, 2020

Build failed
Swift Test Linux Platform
Git Sha - c0ab0c9

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek merged commit b2edf20 into master Mar 8, 2020
@kubamracek kubamracek deleted the mracek/arm64e branch March 8, 2020 04:38
Copy link
Contributor

@smeenai smeenai left a comment

Choose a reason for hiding this comment

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

This broke builds for me:

<swift>/stdlib/public/runtime/Metadata.cpp:4645:40: error: expression is not an integer constant expression
  witness = ptrauth_auth_data(witness, swift_ptrauth_key_associated_type,
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<clang>/usr/lib/clang/11.0.0/include/ptrauth.h:236:35: note: expanded from macro 'ptrauth_auth_data'
  __builtin_ptrauth_auth(__value, __old_key, __old_data)
                                  ^~~~~~~~~
<swift>/stdlib/public/runtime/Metadata.cpp:4767:40: error: expression is not an integer constant expression
  witness = ptrauth_auth_data(witness, swift_ptrauth_key_associated_type,
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<clang>/usr/lib/clang/11.0.0/include/ptrauth.h:236:35: note: expanded from macro 'ptrauth_auth_data'
  __builtin_ptrauth_auth(__value, __old_key, __old_data)
                                  ^~~~~~~~~
<swift>/stdlib/public/runtime/Metadata.cpp:4818:26: error: expression is not an integer constant expression
                witness, swift_ptrauth_key_associated_conformance,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<clang>/usr/lib/clang/11.0.0/include/ptrauth.h:236:35: note: expanded from macro 'ptrauth_auth_data'
  __builtin_ptrauth_auth(__value, __old_key, __old_data)
                                  ^~~~~~~~~
<swift>/stdlib/public/runtime/Metadata.cpp:4894:40: error: expression is not an integer constant expression
  witness = ptrauth_auth_data(witness, swift_ptrauth_key_associated_conformance,
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<clang>/usr/lib/clang/11.0.0/include/ptrauth.h:236:35: note: expanded from macro 'ptrauth_auth_data'
  __builtin_ptrauth_auth(__value, __old_key, __old_data)
                                  ^~~~~~~~~
4 errors generated.

@@ -4207,6 +4301,110 @@ static bool doesNotRequireInstantiation(
return true;
}

static const unsigned swift_ptrauth_key_associated_type =
Copy link
Contributor

Choose a reason for hiding this comment

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

Was it intentional to assign this variable to itself? Clang accepts this without warning :/

swift_ptrauth_init(slot, witness, reqt.Flags.getExtraDiscriminator());
}

static const unsigned swift_ptrauth_key_associated_conformance =
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -4207,6 +4301,110 @@ static bool doesNotRequireInstantiation(
return true;
}

static const unsigned swift_ptrauth_key_associated_type =
swift_ptrauth_key_associated_type;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any way to expand the context around my previous comment, so this is where the self-assignment is happening.

@smeenai
Copy link
Contributor

smeenai commented Mar 11, 2020

Ah, I see #30363.

smeenai added a commit to llvm/llvm-project that referenced this pull request Mar 12, 2020
swiftlang/swift#30112 makes the Swift standard
library for iOS build for arm64e. If you're building Swift against your
own LLVM, this in turn requires having the builtins built for arm64e,
otherwise you won't be able to use the builtins (which will in turn lead
to an undefined symbol for `__isOSVersionAtLeast`). Make the builtins
build for arm64e to fix this.

Differential Revision: https://reviews.llvm.org/D76041
arichardson pushed a commit to arichardson/llvm-project that referenced this pull request Apr 2, 2020
swiftlang/swift#30112 makes the Swift standard
library for iOS build for arm64e. If you're building Swift against your
own LLVM, this in turn requires having the builtins built for arm64e,
otherwise you won't be able to use the builtins (which will in turn lead
to an undefined symbol for `__isOSVersionAtLeast`). Make the builtins
build for arm64e to fix this.

Differential Revision: https://reviews.llvm.org/D76041
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
swiftlang/swift#30112 makes the Swift standard
library for iOS build for arm64e. If you're building Swift against your
own LLVM, this in turn requires having the builtins built for arm64e,
otherwise you won't be able to use the builtins (which will in turn lead
to an undefined symbol for `__isOSVersionAtLeast`). Make the builtins
build for arm64e to fix this.

Differential Revision: https://reviews.llvm.org/D76041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants