Skip to content

Fails to compile on Fedora 39 with Swift 5.8.1 (From repos) or official 5.9 binaries #278

@JCWasmx86

Description

@JCWasmx86

Expected behavior

It compiles on Arch Linux and Fedora 39 (Works on Fedora 38)

Actual behavior

Does not compile on Arch Linux/Fedora 39 (The following part of the issue assumes Fedora 39)

Steps to reproduce

  1. Create fedora 39 VM/container
  2. Install swift using dnf or use the official binaries from swift.org
  3. Try to compile swift-log (From master or the latest release)

If possible, minimal yet complete reproducer code (or URL to code)

git clone https://github.com/apple/swift-log
cd swift-log
swift build
# Or
wget https://download.swift.org/swift-5.9-release/ubuntu2204/swift-5.9-RELEASE/swift-5.9-RELEASE-ubuntu22.04.tar.gz
tar xvf swift-5.9-RELEASE-ubuntu22.04.tar.gz
./swift-5.9-RELEASE-ubuntu22.04/usr/bin/swift build
/swift-log/Sources/Logging/Logging.swift:1392:64: error: value of optional type 'UnsafeMutablePointer<tm>?' must be unwrapped to a value of type 'UnsafeMutablePointer<tm>'
        strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
                                                               ^
/swift-log/Sources/Logging/Logging.swift:1391:13: note: short-circuit using 'guard' to exit this function early if the optional value contains 'nil'
        let localTime = localtime(&timestamp)
            ^
        guard                                 else { return <#default value#> }
/swift-log/Sources/Logging/Logging.swift:1391:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
        let localTime = localtime(&timestamp)
                        ^
                                              ?? <#default value#>
/swift-log/Sources/Logging/Logging.swift:1391:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
        let localTime = localtime(&timestamp)
                        ^
                                             !
/swift-log/Sources/Logging/Logging.swift:1392:64: note: coalesce using '??' to provide a default when the optional value contains 'nil'
        strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
                                                               ^
                                                                         ?? <#default value#>
/swift-log/Sources/Logging/Logging.swift:1392:64: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
        strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
                                                               ^
                                                                        !
error: fatalError

SwiftLog version/commit hash

cb28750 and 1.5.3

Swift & OS version (output of swift --version && uname -a)

Swift version 5.8.1 (swift-5.8.1-RELEASE)
Target: x86_64-unknown-linux-gnu
Linux 6d64617a9d4e 6.4.15-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep  7 00:25:01 UTC 2023 x86_64 GNU/Linux

and

Swift version 5.9 (swift-5.9-RELEASE)
Target: x86_64-unknown-linux-gnu
Linux 6d64617a9d4e 6.4.15-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep  7 00:25:01 UTC 2023 x86_64 GNU/Linux

I was able to fix this with the help of helje5 by doing this hack: https://github.com/JCWasmx86/swift-log/commit/332ed31d777c7acbf4790a790bcfb54fe264de27

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