Skip to content

Conversation

@compnerd
Copy link
Member

@compnerd compnerd commented Oct 6, 2022

Although the runtime exported symbols must be exported with "C" linkage and decoration, we split out the externalisation in the C++ mode. This is required to ensure that we are able to attribute the functions without following the more stringent rules that clang now enforces which place the attributes following the identifier to which they appertain, resulting in the attributes interleaving within the signature. The resulting spelling is more difficult to process for humans as well as more difficult to identify as function declarations making code perusal a challenge, particularly for the uninitiated.

@tbkka
Copy link
Contributor

tbkka commented Oct 21, 2022

Any reason we're still waiting on this? This is a growing problem for Linux builds. (On recent Ubuntu, "clang" defaults to clang-15, which trips over this.)

@tbkka
Copy link
Contributor

tbkka commented Oct 21, 2022

@swift-ci Please test

@tbkka
Copy link
Contributor

tbkka commented Oct 21, 2022

Trying to build locally on Linux with this change gives me:

.../swift/include/swift/Runtime/Debug.h:124:1: error: unknown type name 'SWIFT_MACRO_IF_SWIFT_IMAGE_EXPORTS_LIBRARY'
SWIFT_RUNTIME_EXPORT
^
.../swift/stdlib/public/SwiftShims/swift/shims/Visibility.h:217:30: note: expanded from macro 'SWIFT_RUNTIME_EXPORT'
#define SWIFT_RUNTIME_EXPORT SWIFT_EXPORT_FROM_ATTRIBUTE(LIBRARY)
                             ^
.../swift/stdlib/public/SwiftShims/swift/shims/Visibility.h:202:3: note: expanded from macro 'SWIFT_EXPORT_FROM_ATTRIBUTE'
  SWIFT_MACRO_IF(SWIFT_IMAGE_EXPORTS_##LIBRARY,                       \
  ^
.../swift/stdlib/public/SwiftShims/swift/shims/Visibility.h:62:3: note: expanded from macro 'SWIFT_MACRO_IF'
  SWIFT_MACRO_CONCAT(SWIFT_MACRO_IF_, COND)(IF_TRUE, IF_FALSE)
  ^

and a number of other similar-looking errors.

Copy link
Contributor

@tbkka tbkka left a comment

Choose a reason for hiding this comment

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

I tried building on Ubuntu 22.10 with clang-15 and got a couple of failures.

Copy link
Contributor

Choose a reason for hiding this comment

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

SWIFT_EXPORT_FROM() is used in several other places, so you cannot drop this definition.

Copy link
Contributor

Choose a reason for hiding this comment

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

But SWIFT_EXPORT_FROM_ATTRIBUTE is not used outside of this file, so you could just rename that to SWIFT_EXPORT_FROM

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be SWIFT_EXPORT_FROM_ATTRIBUTE(swiftCore)

eeckstein added a commit to eeckstein/swift that referenced this pull request Nov 3, 2022
This fix might be replaced by something better, e.g. swiftlang#61476
eeckstein added a commit to eeckstein/swift that referenced this pull request Nov 4, 2022
This fix might be replaced by something better, e.g. swiftlang#61476
@dcci
Copy link
Member

dcci commented Nov 8, 2022

@swift-ci please test

@dcci
Copy link
Member

dcci commented Nov 8, 2022

Re-testing this one in the hope of merging it soon.

eeckstein added a commit to eeckstein/swift that referenced this pull request Nov 8, 2022
This is required to a clang change. Attribute need to be in a certain order when building with a newer clang.

This fix might be replaced by something better, e.g. swiftlang#61476
@compnerd
Copy link
Member Author

compnerd commented Nov 8, 2022

@swift-ci please test

1 similar comment
@compnerd
Copy link
Member Author

compnerd commented Nov 9, 2022

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Nov 9, 2022

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Nov 9, 2022

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Nov 9, 2022

@swift-ci please test

Although the runtime exported symbols must be exported with "C" linkage
and decoration, we split out the externalisation in the C++ mode.  This
is required to ensure that we are able to attribute the functions
without following the more stringent rules that clang now enforces which
place the attributes following the identifier to which they appertain,
resulting in the attributes interleaving within the signature.  The
resulting spelling is more difficult to process for humans as well as
more difficult to identify as function declarations making code perusal
a challenge, particularly for the uninitiated.
@compnerd
Copy link
Member Author

compnerd commented Nov 9, 2022

@swift-ci please test

@compnerd
Copy link
Member Author

Closing in favour of fixing llvm/llvm-project#58229 (https://reviews.llvm.org/D137979)

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