mirror of
https://github.com/apple/swift.git
synced 2026-10-22 19:15:50 +02:00
Symbols referenced only from the body of a Clang header inline function are declared by Clang, and IRGen failed to make them weakly linked when their module was imported `@_weakLinked`. After Clang code generation, weakly link every external declaration whose declaration belongs to a module imported `@_weakLinked`. rdar://144177103
52 lines
1.0 KiB
Swift
52 lines
1.0 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
// RUN: %target-swift-frontend -primary-file %t/Client.swift -I %t -emit-ir | %FileCheck %s
|
|
|
|
// UNSUPPORTED: OS=windows-msvc
|
|
|
|
// Symbols referenced only from the body of an inline function in a header
|
|
// should be weakly linked if their module is imported @_weakLinked.
|
|
|
|
//--- module.modulemap
|
|
|
|
module Strong {
|
|
header "Strong.h"
|
|
}
|
|
|
|
module Weak {
|
|
module Sub {
|
|
header "Weak.h"
|
|
}
|
|
}
|
|
|
|
//--- Strong.h
|
|
|
|
extern int strong_fn(void);
|
|
extern int redeclared_fn(void);
|
|
|
|
//--- Weak.h
|
|
|
|
#include "Strong.h"
|
|
|
|
extern int weak_fn(void);
|
|
extern int weak_var;
|
|
extern int redeclared_fn(void);
|
|
|
|
static inline int weak_inline_fn(void) {
|
|
return weak_fn() + weak_var + strong_fn() + redeclared_fn();
|
|
}
|
|
|
|
//--- Client.swift
|
|
|
|
import Strong
|
|
@_weakLinked import Weak
|
|
|
|
// CHECK-DAG: declare extern_weak i32 @weak_fn()
|
|
// CHECK-DAG: @weak_var = extern_weak global i32
|
|
// CHECK-DAG: declare i32 @strong_fn()
|
|
// CHECK-DAG: declare extern_weak i32 @redeclared_fn()
|
|
|
|
public func test() -> Int32 {
|
|
return redeclared_fn() + weak_inline_fn()
|
|
}
|