Skip to content

stdlib: fix the build with macOS long tests #13132

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 1 commit into from
Nov 30, 2017

Conversation

compnerd
Copy link
Member

When building swift on macOS with long tests, the build would fail with
undefined references to these symbols. The undefined symbols were
expected to be present in swiftCore against which we link. However,
because the symbols are marked as internal, they would be dead stripped
before the dylib was constructed. As a result, we would end up with
undefined references to these symbols. Expose the additional internal
interfaces for now so that we can build the tests.

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

CC: @jrose-apple

Sorry Jordan, don't really know who is a good person to run this past.

@compnerd
Copy link
Member Author

@swift-ci please smoke test

@jrose-apple
Copy link
Contributor

What the heck is @_silgen_name("")? I've never seen that before, and it doesn't seem valid to me.

@jrose-apple
Copy link
Contributor

The right answer here is probably to either use @_versioned internal or @_silgen_name("somethingActuallyValid") internal, both of which preserve Swift-side access control while allowing linking from the runtime .o files.

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

(need to figure out intent here)

@compnerd
Copy link
Member Author

@jrose-apple well, the interesting thing is that the names are used in the mangled form, so Im not sure that the @_silgen_name is needed at all. @_versioned internal sounds reasonable, but that won't export it will it?

@jrose-apple
Copy link
Contributor

That does export it, but ideally this wouldn't be exported, just not dead-stripped. Maybe that's what _silgen_name("") is trying to do? But it'd be better to just pick a name and not bother with the mangled form.

@compnerd
Copy link
Member Author

@jrose-apple unfortunately, it would need to be exported for the tests to actually use it from the stdlib.

@jrose-apple
Copy link
Contributor

But there aren't any tests using it from the stdlib.

@compnerd
Copy link
Member Author

@jrose-apple oh, I thought I mentioned that this was being used by the long tests.

@compnerd
Copy link
Member Author

@swift-ci please smoke test

@jrose-apple
Copy link
Contributor

I saw that, but I can't find a test that is actually doing it.

@compnerd
Copy link
Member Author

The references are from the runtime:

Undefined symbols for architecture x86_64:
"__T0s13_getErrorCodeSiSPyxGs0B0RzlF", referenced from:
__swift_stdlib_bridgeErrorToNSError in ErrorObject.mm.o
"__T0s23_getErrorDomainNSStringyXlSPyxGs0B0RzlF", referenced from:
__swift_stdlib_bridgeErrorToNSError in ErrorObject.mm.o
"__T0s29_getErrorUserInfoNSDictionaryyXlSgSPyxGs0B0RzlF", referenced from:
__swift_stdlib_bridgeErrorToNSError in ErrorObject.mm.o
"__T0s32_getErrorEmbeddedNSErrorIndirectyXlSgSPyxGs0B0RzlF", referenced from:
dynamicCastValueToNSError(swift::OpaqueValue*, swift::TargetMetadataswift::InProcess const*, swift::WitnessTable const*, swift::DynamicCastFlags) in Casting.cpp.o
_dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadataswift::InProcess const*, swift::TargetExistentialTypeMetadataswift::InProcess const*, swift::DynamicCastF

These show up when building:
unittests/runtime/LongTests/SwiftRuntimeLongTests
unittests/runtime/SwiftRuntimeTests

@gparker42
Copy link
Contributor

@_silgen_name("") is a temporary hack that has the same effects on symbol visibility as @_silgen_name("whatever") but does not change the symbol's name.

@jrose-apple
Copy link
Contributor

@gparker42 Can we just…not do that? I don't see any reason why the runtime would want to reference these by mangled name rather than non-mangled name.

@jrose-apple
Copy link
Contributor

The runtime tests shouldn't be linking to both the runtime .a and the standard library. We should pick one and stick with it. This has been causing problems elsewhere too (warnings on Darwin about duplicate class implementations).

Can we fix that instead? Or is that hard to fix?

@compnerd
Copy link
Member Author

Hah, I just saw that and was about to look into that error too. I didnt see the .a in the linker invocation, which is why I was under the impression that it was supposed to pull it from the stdlib. If that is simply me being incapable of reading, then, I think fixing that is better if it isn't too terribly difficult (for some value of terribly difficult).

@jrose-apple
Copy link
Contributor

It links the runtime .a, which references symbols in the stdlib. But it already loads the stdlib, I think. (If not, we should make the .a symbols weak or something so that the runtime tests can still build.)

@jrose-apple
Copy link
Contributor

(It might link a bunch of runtime object files directly. I don't remember.)

@compnerd
Copy link
Member Author

Yes, it does link against the runtime, but does not include the stdlib objects. I suppose that we should be able to avoid the double runtime link.

@gparker42
Copy link
Contributor

IIRC the test executable links directly to the runtime's C++ code but not its Swift code. unittests/runtime/Stdlib.cpp contains empty placeholders for some Swift functions that are required to build but not to run. We may need to add these functions to that file.

@gparker42
Copy link
Contributor

(And the test executable does this because it calls some non-exported runtime functions directly.)

@jrose-apple jrose-apple dismissed their stale review November 29, 2017 22:33

Greg has explained the way forward!

When building swift on macOS with long tests, the build would fail with
undefined references to these symbols.  The undefined symbols were
expected to be present in swiftCore against which we link.  However,
because the symbols are marked as internal, they would be dead stripped
before the dylib was constructed.  As a result, we would end up with
undefined references to these symbols.  Expose the additional internal
interfaces for now so that we can build the tests.
@compnerd
Copy link
Member Author

@swift-ci please smoke test

@compnerd
Copy link
Member Author

The linux build is a out of space issue, I think that this should be okay, it also locally passes for me. @jrose-apple or @gparker42 could we get this merged?

@compnerd
Copy link
Member Author

@swift-ci please smoke test Linux platform

@compnerd compnerd merged commit 0c53bbf into swiftlang:master Nov 30, 2017
@compnerd compnerd deleted the testable branch November 30, 2017 00:22
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.

3 participants