Skip to content

runtime: ingest LLVMSupport into the runtime #31665

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 3 commits into from
May 15, 2020

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented May 8, 2020

This adds a new copy of LLVMSupport into the runtime. This is the final
step before changing the inline namespace for the runtime support. This
will allow us to avoid the ODR violations from the header definitions of
LLVMSupport.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

@compnerd
Copy link
Member Author

compnerd commented May 8, 2020

CC: @mikeash @jckarter

@compnerd compnerd requested a review from mikeash May 8, 2020 23:24
@compnerd
Copy link
Member Author

compnerd commented May 8, 2020

I'll be updating the commit message to include this, but LLVMSupport was forked at 22492eead218ec91d349c8c50439880fbeacf2b7. The allocation updates are corresponding to upstream changes.

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

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

Yaay

@jckarter
Copy link
Contributor

jckarter commented May 9, 2020

Do we need all of llvmSupport? Can we bring over only the bits we use?

@compnerd
Copy link
Member Author

compnerd commented May 9, 2020

@jckarter I believe that we dont need all of LLVMSupport. My intention is to bring it in its entirety to compile. Im going to more or less immediately follow this up with 2 changes:

  1. introduce an inline namespace for avoiding the ODR violation that this causes (which is the original motivation for all the work)
  2. begin to strip this down to just the pieces that we are actually using.

I want to introduce the library in its complete form because its much easier to track the provenance that way. It makes it simpler to split the operation into copy, delete rather than do it as one. However, Im happy to just stack that into this change and merge the entire thing at once, as long as the steps remain to help make it easier to follow what happened.

@compnerd
Copy link
Member Author

compnerd commented May 9, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented May 9, 2020

Build failed
Swift Test OS X Platform
Git Sha - 9212b373c5713e280a16cc6baac3b84fd089efee

@swift-ci
Copy link
Contributor

swift-ci commented May 9, 2020

Build failed
Swift Test Linux Platform
Git Sha - 9212b373c5713e280a16cc6baac3b84fd089efee

@compnerd
Copy link
Member Author

Please test with following PRs:
swiftlang/llvm-project#1205

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9212b373c5713e280a16cc6baac3b84fd089efee

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 9212b373c5713e280a16cc6baac3b84fd089efee

@compnerd
Copy link
Member Author

Please test with following PRs:
swiftlang/llvm-project#1206

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ff38fb4729fc480710b8f1d873cc14e13a0fa62a

@compnerd
Copy link
Member Author

Please test with following PRs:
swiftlang/llvm-project#1206

@swift-ci please test macOS platform

@compnerd
Copy link
Member Author

Please test with following PRs:
swiftlang/llvm-project#1206

@swift-ci please test windows platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ff38fb4729fc480710b8f1d873cc14e13a0fa62a

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ff38fb4729fc480710b8f1d873cc14e13a0fa62a

@compnerd
Copy link
Member Author

Please test with following PRs:
swiftlang/llvm-project#1206

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 09eaf69951b75037d6b78790ca9a22940d91cb72

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 09eaf69951b75037d6b78790ca9a22940d91cb72

@compnerd compnerd force-pushed the indigestion branch 2 times, most recently from 51afc8b to 70d4f34 Compare May 11, 2020 19:42
@compnerd
Copy link
Member Author

Please test with following PRs:
swiftlang/llvm-project#1206

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 09eaf69951b75037d6b78790ca9a22940d91cb72

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 70d4f3454e13ddf98274f04f2d8cec7cd359c041

@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 15983dfb10b51d85a6f126bdd74521cec4a26cb2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 70d4f3454e13ddf98274f04f2d8cec7cd359c041

@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 15983dfb10b51d85a6f126bdd74521cec4a26cb2

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 147d6afe954da2a9740f40154117c09887edf5a8

@compnerd
Copy link
Member Author

@swift-ci please test windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Linux platform

@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - fafbdeb3abe2c4d3787575ce7d810a4b3ebec501

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

$ nm --defined-only -demangle ./lib/swift/macosx/x86_64/libswiftCore.dylib | grep -v -e '__swift::__runtime::llvm' | grep -e 'llvm::'
00000000003cb3c0 t (anonymous namespace)::OldDemangler::demangleIdentifier(llvm::Optional<swift::Demangle::Node::Kind>)
0000000000441c30 s (anonymous namespace)::OldDemangler::demangleIdentifier(llvm::Optional<swift::Demangle::Node::Kind>)::op_char_table

This symbol is actually leaked on all the platforms, and can be cleaned up subsequently

@compnerd
Copy link
Member Author

@swift-ci please test macOS platform

@compnerd
Copy link
Member Author

$ nm --defined-only --demangle lib/swift/linux/libswiftCore.so | grep -v
 -e '__swift::__runtime::llvm' | grep llvm::
0000000000589810 t (anonymous namespace)::OldDemangler::demangleIdentifier(llvm::Optional<swift::Demangle::Node::Kind>)
000000000001a6f0 r (anonymous namespace)::OldDemangler::demangleIdentifier(llvm::Optional<swift::Demangle::Node::Kind>)::op_char_table

Linux is also in sync with macOS here

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - fafbdeb3abe2c4d3787575ce7d810a4b3ebec501

compnerd added 3 commits May 15, 2020 09:55
This adds a new copy of LLVMSupport into the runtime.  This is the final
step before changing the inline namespace for the runtime support.  This
will allow us to avoid the ODR violations from the header definitions of
LLVMSupport.

LLVMSupport forked at: 22492eead218ec91d349c8c50439880fbeacf2b7
Changes made to LLVMSupport from that revision:
  process.inc forward declares `_beginthreadex` due to compilation issues due to custom flag handling

API changes required that we alter the `Deallocate` routine to account
for the alignment.

This is a temporary state, meant to simplify the process.  We do not use
the entire LLVMSupport library and there is no value in keeping the
entire library.  Subsequent commits will prune the library to the needs
for the runtime.
This adds the `__swift::__runtime` inline namespace to the LLVMSupport
interfaces.  This avoids an ODR violation when LLVM and Swift are in the
same address space.  It also will aid in the process of pruning the
LLVMSupport library by ensuring that accidental leakage of the llvm
namespace does not allow us to remove symbols which we rely on.
Reduce LLVMSupport to the subset required for the runtime.  This reduces
the TCB and the overheads of the runtime.  The inline namespace's
preservation ensures that ODR violations do not occur.
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

Spoke with JoeG and MikeA about this offline. We all agree that this is bringing us into a better state for stability moving forward, addresses the ODR violation issue.

This allows for a transitioning state where we could start vending the ADTs as part of the runtime and work towards removing the some of the C++-ness of the ABI definitions to allow for easier sharing between the runtime and the compiler. It would also allow for easier use of the ABI type definitions in the Swift code.

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