Skip to content

Add .note.swift_reflection_metadata #26479

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

Conversation

alexander-shaposhnikov
Copy link

Introduce .note.swift_reflection_metadata.

@alexander-shaposhnikov
Copy link
Author

cc: @compnerd , @jckarter
P.S. I have factored out the minimal changes required for SwiftRT-ELF.cpp (while still keeping the build green) from #26419

@alexander-shaposhnikov alexander-shaposhnikov force-pushed the modify_swift_rt_elf branch 3 times, most recently from c948998 to 5c8debe Compare August 4, 2019 03:34
@dcci
Copy link
Member

dcci commented Aug 5, 2019

@swift-ci test

@dcci dcci requested a review from jckarter August 5, 2019 20:01
@swift-ci
Copy link
Contributor

swift-ci commented Aug 5, 2019

Build failed
Swift Test OS X Platform
Git Sha - 9289453084808d0edb636a209e365dc64c2917bf

@swift-ci
Copy link
Contributor

swift-ci commented Aug 5, 2019

Build failed
Swift Test Linux Platform
Git Sha - 9289453084808d0edb636a209e365dc64c2917bf

Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this one! The general idea looks fine [I also talked with Joe offline and he seems onboard].

Looks like there's a build failure though.

13:25:20 
/home/buildnode/jenkins/workspace/swift-PR-Linux/branch-master/swift/stdlib/public/runtime/SwiftRT-ELF.cpp:82:32: error: 'S' causes a section type conflict with 'MagicString'
13:25:20 const swift::MetadataSections *S = &sections;
13:25:20                                ^
13:25:20 /home/buildnode/jenkins/workspace/swift-PR-Linux/branch-master/swift/stdlib/public/runtime/SwiftRT-ELF.cpp:76:12: note: declared here
13:25:20 const char MagicString[] = SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING;
13:25:20            ^

@alexander-shaposhnikov
Copy link
Author

Fixed the build failure

SWIFT_SECTION_RANGE(swift5_replac2),
SWIFT_SECTION_RANGE(swift5_builtin),
SWIFT_SECTION_RANGE(swift5_capture),
};
Copy link
Member

Choose a reason for hiding this comment

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

Does this not create a constructor? There is now a C++ constructor which runs separately than the actual constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. Maybe it gets optimized away by LLVM GlobalOpt, but we should double-check. What I had meant in the previous PR was that we could generate the symbol and its definition in a global asm block, since the section ranges can be represented as constant expressions in assembly language, but not C.

__attribute__((__used__))
__attribute__((__section__(".note.swift_reflection_metadata")))
__attribute__((__aligned__(1)))
const swift::MetadataSections *S = &sections;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this works. The compiler is completely within its right to re-order the entries here. So we can end up with an invalid section here.

@alexander-shaposhnikov
Copy link
Author

Addressed comments

@alexander-shaposhnikov
Copy link
Author

Fixed typo

@dcci
Copy link
Member

dcci commented Aug 6, 2019

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 6, 2019

Build failed
Swift Test Linux Platform
Git Sha - 5c8debe7c68003348db92a831e8d315df548bed6

@swift-ci
Copy link
Contributor

swift-ci commented Aug 6, 2019

Build failed
Swift Test OS X Platform
Git Sha - 5c8debe7c68003348db92a831e8d315df548bed6

@alexander-shaposhnikov
Copy link
Author

khm, sorry about the disturbance, it seems to me @swift-ci has tested some old commit instead of the latest one, maybe smb can kick off testing again

@gmittert
Copy link
Contributor

gmittert commented Aug 6, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 6, 2019

Build failed
Swift Test Linux Platform
Git Sha - 623584ef670359fc93ab2756b8feb497e5e5ec03

@gmittert
Copy link
Contributor

gmittert commented Aug 6, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 6, 2019

Build failed
Swift Test Linux Platform
Git Sha - 623584ef670359fc93ab2756b8feb497e5e5ec03

@swift-ci
Copy link
Contributor

swift-ci commented Aug 6, 2019

Build failed
Swift Test OS X Platform
Git Sha - 623584ef670359fc93ab2756b8feb497e5e5ec03

@dcci
Copy link
Member

dcci commented Aug 6, 2019

This is a peculiar failure

03:00:01 **** FAILURE EXECUTING SUBPROCESS ****
03:00:01 output: 
03:00:01 
stderr: /home/buildnode/jenkins/workspace/swift-PR-Linux/branch-master/tmp/DependencyResolution_External_Complex.BZPCCg/app: error: manifest parse error(s):
03:00:01 <unknown>:0: warning: missing submodule 'SwiftOverlayShims'
03:00:01 <unknown>:0: error: missing required module 'SwiftOverlayShims'
03:00:01 

and definitely unrelated to the PR. Trying again.

@dcci
Copy link
Member

dcci commented Aug 6, 2019

@swift-ci test linux platform

__attribute__((__section__(".note.swift_reflection_metadata")))
__attribute__((__aligned__(1)))
struct {
const char MagicString[sizeof(SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING)];
Copy link
Member

Choose a reason for hiding this comment

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

I think that doing sizeof(SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING)/sizeof(*SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING) is better.

@compnerd compnerd dismissed their stale review August 7, 2019 01:28

addressed

@compnerd
Copy link
Member

compnerd commented Aug 7, 2019

I'm fine with these changes assuming that @jckarter is also happy with it.

@jckarter
Copy link
Contributor

jckarter commented Aug 7, 2019

Seems reasonable to me.

@compnerd
Copy link
Member

compnerd commented Aug 7, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 7, 2019

Build failed
Swift Test Linux Platform
Git Sha - 1bb9d4633db96cb01f78524029e42f04cee26ede

@swift-ci
Copy link
Contributor

swift-ci commented Aug 7, 2019

Build failed
Swift Test OS X Platform
Git Sha - 1bb9d4633db96cb01f78524029e42f04cee26ede

@compnerd
Copy link
Member

compnerd commented Aug 7, 2019

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Aug 7, 2019

Build failed
Swift Test Linux Platform
Git Sha - 9a322f3404c0603bdda90fc9c6995fd12033ec3d

@gmittert
Copy link
Contributor

gmittert commented Aug 8, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - 9a322f3404c0603bdda90fc9c6995fd12033ec3d

@compnerd
Copy link
Member

compnerd commented Aug 8, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - 9a322f3404c0603bdda90fc9c6995fd12033ec3d

@swift-ci
Copy link
Contributor

swift-ci commented Aug 8, 2019

Build failed
Swift Test OS X Platform
Git Sha - 9a322f3404c0603bdda90fc9c6995fd12033ec3d

@compnerd
Copy link
Member

compnerd commented Aug 9, 2019

@swift-ci please test macOS platform

@compnerd compnerd merged commit f1861c3 into swiftlang:master Aug 10, 2019
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.

6 participants