Skip to content

@_cdecl doesn’t work in emdedded dependency #74328

Open
@MihaelIsaev

Description

@MihaelIsaev

Description

Bug in Embedded Swift with @_cdecl inside a dependency package.

Toolchain: swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-09-a
Build command: swift build -c release --triple wasm32-unknown-none-wasm

Compilation error

Building for production...
error: link command failed with exit code 1 (use -v to see invocation)
clang: warning: argument unused during compilation: '-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks' [-Wunused-command-line-argument]
wasm-ld: error: .build/wasm32-unknown-none-wasm/release/_CLib.build/_CLib.c.o: undefined symbol: _swiftMethod
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[11/12] Linking App.wasm

Reproduction

// Sources/App/App.swift
import Lib1

@_expose(wasm, "main")
func main() {
    __hello()
}

@_extern(c)
func __hello()

Lib1 package code

// Sources/_CLib/_CLib.c
extern void _swiftMethod();

void __hello() {
    _swiftMethod();
}

// Sources/Lib1/Lib1.swift
import _CLib

@_cdecl("_swiftMethod")
public func _swiftMethod() {}

Expected behavior

@_cdecl("_swiftMethod") should be taken by the compiler from the Lib1

Environment

Apple Swift version 6.0-dev (LLVM 579155491d559cc, Swift 64869e5)
Target: arm64-apple-macosx14.0

Additional information

CDeclDependencyBug.zip – project that reproduces the issue

Metadata

Metadata

Assignees

Labels

WebAssemblyPlatform: WebAssemblybugA deviation from expected or documented behavior. Also: expected but undesirable behavior.embeddedEmbedded Swift

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions