-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for testable executables on Windows #8515
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
@compnerd Would appreciate your input here on whether you think this is a reasonable solution, at least for the interim. For the longer term once Swift Build becomes the default build system we could consider generating an assembly file to define a hard alias if there are any downsides to this approach, but I'm not thinking of any right now. |
@swift-ci test |
@swift-ci test windows self hosted |
I'm not sure that this is the right approach. I've known about The long term solution here is to fix LLVM. When clang migrated to the New Pass Manager, it dropped the symbol rewriter from the module pass (mostly because of ARM64). We should restore that, and then generate the yaml configuration to rename the symbol during compile time at the LLVM IR level. This will provide us with a clean, completely portable solution. |
I know it doesn't have exactly the same semantics, but it might be close enough to work for our specific use case.
Meaning we'll no longer need to pass How much effort and how far out is that? Do you think it's worth landing this as an interim solution in the meantime? And/or the approach of generating a symbol alias in an assembly file? |
@swift-ci test windows self hosted |
And, what about using |
@swift-ci test self hosted windows |
Can we remove this in the Package.swift now?
There some tests in there that specifically test this too. (see |
Does it? If that works with
I'm hoping to work on that soon. I think that we could apply it downstream first before upstream to speed it up some. I don't think that it should be too bad to do that. It would be way better to do that over the symbol aliases or assembly thunks as it is pretty much target agnostic and entirely avoids some of the semantic issues around simply creating and using the alias and hoping that the main entry point goes away.
AFAIK, that would be bad. You would need define the contents of |
Not until this change lands in a released Swift toolchain, if we decide to move forward with it.
Yeah, I tried an example with a test target that linked an executable, and running the executable and running the tests which referenced symbols from that executable both worked. From what I understand, for executable targets, the Swift frontend flag
Good to know! I guess this would also bypass initialization in mainCRTStartup, which is probably bad too. |
Also, just want to clarify -- due to use of |
Ah, hah! That was the missing bit - okay, that makes sense now. I guess that the last piece that I think needs to be confirmed is that this would not impact the user's use of But, with that additional context, I think that this makes sense as an interim solution while we can get the symbol rewriter hooked up again. |
Why does I'm not able to build your swift-win32-application example with Swift 6.1 as I get:
|
This uses the /ALTERNATENAME flag to link.exe, which is roughly equivalent to -alias/--defsym. This has been verified to work in a sample project. See https://devblogs.microsoft.com/oldnewthing/20200731-00/ for more info. Closes #6367
f681864
to
dc2fed2
Compare
@swift-ci test |
@swift-ci test windows self hosted |
OK, I don't understand why I updated the patch to do this; I think this should cover all bases and be ready to land. |
They have different signatures, however, the signature that Swift cares about is:
This effectively matches any signature as a happy side-effect.
Ugh, symlinks have been an annoyance, but the inability to evolve the package manifest with compatibility is just as annoying. |
@swift-ci test windows |
1 similar comment
@swift-ci test windows |
@swift-ci test windows self hosted |
@swift-ci test windows |
@swift-ci test windows self hosted |
@swift-ci test windows |
@swift-ci test self hosted windows |
This uses the /ALTERNATENAME flag to link.exe, which is roughly equivalent to -alias/--defsym. This has been verified to work in a sample project.
See https://devblogs.microsoft.com/oldnewthing/20200731-00/ for more info.
Closes #6367