Skip to content

duckdb-swift API build failing on Linux #12

Open
@levitatingpineapple

Description

@levitatingpineapple

What happens?

Issue

duckdb-swift bindings are not building on linux with open source swift-foundation due to differences in the interface of Decimal type:

// Interface on Apple platforms
public struct Decimal : @unchecked Sendable {
    public init()
    public init(_exponent: Int32, _length: UInt32, _isNegative: UInt32, _isCompact: UInt32, _reserved: UInt32, _mantissa: (UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16))
    public var _exponent: Int32
    public var _length: UInt32
    public var _isNegative: UInt32
    public var _isCompact: UInt32
    public var _reserved: UInt32
    public var _mantissa: (UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
}

// Open source foundation interface
public struct Decimal : Sendable {
    public typealias Mantissa = (UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
    public init(mantissa: UInt64, exponent: Int16, isNegative: Bool)
    public init()
}

Workaround

I managed to compile the bindings by typecasting to a locally declared type, with a matching memory layout and copying over few required bits of the interface: Decimal+Linux.swift. While this workaround would break, if the underlying implementation changes - the typecasting could be covered few tests.

Resources

To Reproduce

To reproduce - simply try building duckdb-swift on any platform which uses open source version of Foundation framework.

OS:

aarch64, debian 12

DuckDB Version:

latest

DuckDB Client:

Swift 6.0.3

Hardware:

No response

Full Name:

Arturs Krumins

Affiliation:

none

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a source build

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions