Skip to content

Commit 6b2a97b

Browse files
committed
[Runtime] Remove attribute ordering hack
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).
1 parent c78bb3e commit 6b2a97b

File tree

5 files changed

+5
-14
lines changed

5 files changed

+5
-14
lines changed

include/swift/Runtime/Config.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,6 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL
168168
// Bring in visibility attribute macros
169169
#include "swift/shims/Visibility.h"
170170

171-
// Temporary definitions to allow compilation on clang-15.
172-
#if defined(__cplusplus)
173-
#define SWIFT_EXTERN_C extern "C"
174-
#else
175-
#define SWIFT_EXTERN_C
176-
#endif
177-
#define SWIFT_RUNTIME_EXPORT_ATTRIBUTE SWIFT_EXPORT_FROM_ATTRIBUTE(swiftCore)
178-
179171
// Define mappings for calling conventions.
180172

181173
// Annotation for specifying a calling convention of

include/swift/Runtime/Heap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace swift {
2929
// Never returns nil. The returned memory is uninitialized.
3030
//
3131
// An "alignment mask" is just the alignment (a power of 2) minus 1.
32-
SWIFT_EXTERN_C SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT_ATTRIBUTE
32+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
3333
void *swift_slowAlloc(size_t bytes, size_t alignMask);
3434

3535
// If the caller cannot promise to zero the object during destruction,

include/swift/Runtime/HeapObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct OpaqueValue;
6161
///
6262
/// POSSIBILITIES: The argument order is fair game. It may be useful
6363
/// to have a variant which guarantees zero-initialized memory.
64-
SWIFT_EXTERN_C SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT_ATTRIBUTE
64+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
6565
HeapObject *swift_allocObject(HeapMetadata const *metadata,
6666
size_t requiredSize,
6767
size_t requiredAlignmentMask);
@@ -117,7 +117,7 @@ BoxPair swift_makeBoxUnique(OpaqueValue *buffer, Metadata const *type,
117117
size_t alignMask);
118118

119119
/// Returns the address of a heap object representing all empty box types.
120-
SWIFT_EXTERN_C SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT_ATTRIBUTE
120+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
121121
HeapObject* swift_allocEmptyBox();
122122

123123
/// Atomically increments the retain count of an object.

include/swift/Runtime/Metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ swift_getGenericMetadata(MetadataRequest request,
313313
/// - installing new v-table entries and overrides; and
314314
/// - registering the class with the runtime under ObjC interop.
315315
/// Most of this work can be achieved by calling swift_initClassMetadata.
316-
SWIFT_EXTERN_C SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT_ATTRIBUTE
316+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
317317
ClassMetadata *
318318
swift_allocateGenericClassMetadata(const ClassDescriptor *description,
319319
const void *arguments,
@@ -322,7 +322,7 @@ swift_allocateGenericClassMetadata(const ClassDescriptor *description,
322322
/// Allocate a generic value metadata object. This is intended to be
323323
/// called by the metadata instantiation function of a generic struct or
324324
/// enum.
325-
SWIFT_EXTERN_C SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT_ATTRIBUTE
325+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
326326
ValueMetadata *
327327
swift_allocateGenericValueMetadata(const ValueTypeDescriptor *description,
328328
const void *arguments,

lib/IRGen/GenDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "swift/ClangImporter/ClangModule.h"
3131
#include "swift/Demangling/ManglingMacros.h"
3232
#include "swift/IRGen/Linking.h"
33-
#include "swift/Runtime/HeapObject.h"
3433
#include "swift/SIL/FormalLinkage.h"
3534
#include "swift/SIL/SILDebugScope.h"
3635
#include "swift/SIL/SILModule.h"

0 commit comments

Comments
 (0)