Skip to content

[rebranch][Runtime] Remove attribute ordering hack #62497

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

Closed
wants to merge 2 commits into from

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Dec 9, 2022

Remove the split macro definitions and move the SWIFT_RUNTIME_EXPORT
macro to the beginning of the attributes list so that extern "C"
becomes the first attribute. This is possible since stable/20221013
where mixing GNU and standard attributes was fixed
(https://reviews.llvm.org/D137979).

Also remove an unnecessary include, which would prevent the compiler
itself being built on the released clang-15 (since the GNU/standard
attribute mixing fix isn't in clang-15).

@bnbarham
Copy link
Contributor Author

bnbarham commented Dec 9, 2022

@swift-ci please test

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.

Beautiful! Thank you!

@finagolfin
Copy link
Member

Still failing on CI: I noticed that Saleem's patch was backported to stable/20221013, swiftlang/llvm-project#5655, while trunk still uses stable/20220421, which would partially explain why this is failing (there appear to be other errors too).

@bnbarham
Copy link
Contributor Author

Interesting 🤔. I didn't think we needed Saleem's patch in stable/20220421 but ... apparently attributes are also broken there? It has quite a few conflicts so I'm not sure about cherry-picking it. Any thoughts @compnerd? Maybe we need to use this hack for main but switch rebranch to use this PR?

@compnerd
Copy link
Member

I think that leaving it on main for a little bit is fine. We can fix this on the rebranch. I can take a look at backporting the clang change to the current branch. Seems better to fix it before the next release.

Remove the split macro definitions and move the SWIFT_RUNTIME_EXPORT
macro to the beginning of the attributes list so that `extern "C"`
becomes the first attribute. This is possible since stable/20221013
where mixing GNU and standard attributes was fixed
(https://reviews.llvm.org/D137979).

Also remove an unnecessary include, which would prevent the compiler
itself being built on the released clang-15 (since the GNU/standard
attribute mixing fix isn't in clang-15).
@bnbarham bnbarham force-pushed the fix-runtime-attributes branch from 2e4df58 to 6b2a97b Compare December 19, 2022 17:25
@bnbarham bnbarham changed the base branch from main to rebranch December 19, 2022 17:25
@bnbarham bnbarham changed the title [Runtime] Fix up incorrect attribute ordering [rebranch][Runtime] Remove attribute ordering hack Dec 19, 2022
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@@ -30,7 +30,6 @@
#include "swift/ClangImporter/ClangModule.h"
#include "swift/Demangling/ManglingMacros.h"
#include "swift/IRGen/Linking.h"
#include "swift/Runtime/HeapObject.h"
Copy link
Member

Choose a reason for hiding this comment

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

Was this meant to be rebranch only? Seems like this can go on main as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can put it on main if you want, I was just going to leave it until the rebranch is merged.

@bnbarham
Copy link
Contributor Author

Note: we're apparently still failing on

extern "C" __attribute__((__visibility__("default"))) [[nodiscard]]
int myTest();

ie. mixed attributes with extern "C".

@bnbarham
Copy link
Contributor Author

bnbarham commented Jan 9, 2023

@swift-ci please test

@bnbarham
Copy link
Contributor Author

bnbarham commented Jan 9, 2023

Re-running now that swiftlang/llvm-project#5869 is merged

@bnbarham
Copy link
Contributor Author

@swift-ci please test macOS platform

@bnbarham
Copy link
Contributor Author

@swift-ci please clean test

@bnbarham
Copy link
Contributor Author

@swift-ci please test Linux platform

@bnbarham
Copy link
Contributor Author

So that I don't keep forgetting the problem here:

  1. Clang 15 introduced a change that broke our attribute order. To workaround that we split SWIFT_RUNTIME_EXPORT into two.
  2. compnerd fixed that issue in newer Clang's, but we can't revert to the old use because the runtime headers are included in compiler libraries that are built with the host compiler (which could be Clang 15). We also can't change to moving SWIFT_RUNTIME_EXPORT to the start because that has always been broken in Clang (until comp nerd's fix).

The proper fix here will be to properly split the runtime headers - the function declarations should only be available to the runtime, which is required to be built with the just-built compiler. This would also help in not accidentally including compiler headers in the runtime.

Once that's done we can use SWIFT_RUNTIME_EXPORT again as the bootstrapped compiler will be the only compiler that touches those decls.

@bnbarham bnbarham closed this Jan 13, 2023
@bnbarham bnbarham deleted the fix-runtime-attributes branch January 13, 2023 01:15
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.

The Swift compiler cannot be built with clang 15 on linux/Android
4 participants