Skip to content

Commit ba7ed9a

Browse files
committed
Mark the runtime's reimplementation of
llvm::hashing::detail::fixed_seed_override as weak in case it is staticly linked into an app that includes a real definition from LLVM.
1 parent 2d9ae8f commit ba7ed9a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stdlib/public/stubs/GlobalObjects.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,13 @@ void swift::_swift_instantiateInertHeapObject(void *address,
129129

130130
namespace llvm { namespace hashing { namespace detail {
131131
// An extern variable expected by LLVM's hashing templates. We don't link any
132-
// LLVM libs into the runtime, so define this here.
133-
size_t fixed_seed_override = 0;
132+
// LLVM libs into the runtime, so define it as a weak symbol.
133+
//
134+
// Systems that compile this code into a dynamic library will do so with
135+
// hidden visibility, making this all internal to the dynamic library.
136+
// Systems that statically link the Swift runtime into applications (e.g. on
137+
// Linux) need this to handle the case when the app already uses LLVM.
138+
size_t LLVM_ATTRIBUTE_WEAK fixed_seed_override = 0;
134139
} // namespace detail
135140
} // namespace hashing
136141
} // namespace llvm

0 commit comments

Comments
 (0)