Skip to content

unittests/runtime: Add more stubs related to protocol conformance #14787

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

Conversation

AndrewSB
Copy link
Contributor

Found whilst attempting to build the runtime tests on Windows

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

This doesn't make much sense, these are type definitions, not actual variables. There is no associated storage for these. Instances of anonymous structures with those names would be fine, though that is an a MSVC/GNU extension. Just create a tag type for them to be portable.

@@ -29,6 +29,9 @@ void _swift_makeAnyHashableUsingDefaultRepresentation(
abort();
}

SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERNAL
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't have a CC associated with it, it is a structure.

@AndrewSB
Copy link
Contributor Author

I see. How does this look now?

@compnerd
Copy link
Member

They are duplicated with an anonymous and tagged type.

@AndrewSB
Copy link
Contributor Author

AndrewSB commented Feb 22, 2018

🤦‍♂️
ok, no dupes now

@compnerd
Copy link
Member

Seems plausible

@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

CC: @jckarter

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7ab917086e30c63430cbc35f06c265aece867cbf

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7ab917086e30c63430cbc35f06c265aece867cbf

SWIFT_RUNTIME_STDLIB_INTERNAL
const char $Ss3SetVMn[1] = {0};

// Mirror
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 we should go ahead and use a macro here

// stub symbols for the protocol witness table and the type metadata accessor
#define STUB_TYPE_INFO(type)                                                   \
  SWIFT_RUNTIME_STDLIB_INTERNAL const char $Ss12_##type##VMa[1] = {0};         \
  SWIFT_RUNTIME_STDLIB_INTERNAL const char $Ss12_##type##Vs01_B0sWP[1] = {0};


STUB_TYPE_INFO(ClassMirror)
STUB_TYPE_INFO(EnumMirror)
STUB_TYPE_INFO(MetatypeMirror)
STUB_TYPE_INFO(OpaqueMirror)
STUB_TYPE_INFO(StructMirror)
STUB_TYPE_INFO(TupleMirror)

Copy link
Contributor

Choose a reason for hiding this comment

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

12 is the identifier length, so it can't be buried in the macro unfortunately. We used to have a macro for this when we were staging in the new mangling, but it looks like it's been taken out since.

// Set

SWIFT_RUNTIME_STDLIB_INTERNAL
const char $Ss3SetVMn[1] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are char they may not end up sufficiently aligned to meet the expectations of runtime or stdlib code that assume these structures are 4- or 8-byte aligned. Stubbing them out as long long would be safer.

Found whilst attempting to build the runtime tests on Windows
@AndrewSB
Copy link
Contributor Author

@jckarter long long, it is.

@jckarter
Copy link
Contributor

Thanks!

This is reasonable in order to get the existing infrastructure working, but maybe we should rework how the runtime unittests get built, so that they can link against only the parts of the runtime they test and not the runtime as a whole. That would make these hacks unnecessary.

@AndrewSB
Copy link
Contributor Author

AndrewSB commented Feb 23, 2018

Yeah, I was thinking the same thing while implementing this. Maybe we can explore using the headers in the runtime, instead of stubbing out the symbols used. I don't know why the tests are built the way they are though - there probably is a reason - I'm just missing a bunch of context in the area 😛

Can we re-run CI? It looks like there was a spurious failure when @compnerd asked

@jckarter
Copy link
Contributor

@swift-ci Please test

@jckarter
Copy link
Contributor

jckarter commented Feb 23, 2018

I don't think there's any reason for the current build process except for inertia. These symbols come from the standard library written in Swift, so they don't really have a header you can include, but the parts of the runtime that have unit tests should be fairly well decoupled from the runtime as a whole.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cae535e38d9edf9051b8695a444bf36390d5de03

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cae535e38d9edf9051b8695a444bf36390d5de03

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

I think that the clean up that @jckarter suggested can be done in a follow up change. This at least gets building the tests on Windows going.

@compnerd compnerd merged commit 418c77e into swiftlang:master Feb 28, 2018
@jckarter
Copy link
Contributor

Agreed, I wasn't trying to hold up this patch, just suggesting that further cleanup was possible.

@AndrewSB AndrewSB deleted the mangling🤦‍♂️-stubs-for-protocol-conformances🤷‍♂️ branch February 28, 2018 16:43
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