Skip to content

Commit 58e8c21

Browse files
authored
Merge pull request #12164 from aschwaighofer/swift-4.0-branch_fix_irgen_shared_declarations
[4.0] IRGen: Fix linkage for shared declarations
2 parents a779fa1 + cec02ff commit 58e8c21

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,8 @@ getIRLinkage(const UniversalLinkageInfo &info, SILLinkage linkage,
14161416

14171417
case SILLinkage::Shared:
14181418
case SILLinkage::SharedExternal:
1419-
return RESULT(LinkOnceODR, Hidden, Default);
1419+
return isDefinition ? RESULT(LinkOnceODR, Hidden, Default)
1420+
: RESULT(External, Hidden, Default);
14201421

14211422
case SILLinkage::Hidden:
14221423
return RESULT(External, Hidden, Default);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
2+
#define NS_OPTIONS(_type, _name) CF_OPTIONS(_type, _name)
3+
4+
typedef NS_OPTIONS(int, SomeOptions) {
5+
SomeOptionsFoo = 1,
6+
SomeOptionsBar = 2,
7+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -primary-file %s -import-objc-header %S/Inputs/usr/include/NSOption.h -emit-ir | %FileCheck %s
2+
3+
// REQUIRES: objc_interop
4+
5+
import Swift
6+
7+
sil public @use_witness : $@convention(thin) () -> () {
8+
%0 = witness_method $SomeOptions, #Equatable."=="!1 : <Self where Self : Equatable> (Self.Type) -> (Self, Self) -> Bool : $@convention(witness_method) <τ_0_0 where τ_0_0 : Equatable> (@in τ_0_0, @in τ_0_0, @thick τ_0_0.Type) -> Bool
9+
%1 = tuple ()
10+
return %1: $()
11+
}
12+
13+
// We used to emit linkonce_odr llvm linkage for this declaration.
14+
sil_witness_table shared SomeOptions : Equatable module __ObjC
15+
16+
// CHECK: @_T0SC11SomeOptionsVs9EquatableSoWP = external hidden global

0 commit comments

Comments
 (0)