Skip to content

Build issue on nightly-6.0-amazonlinux2 #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AndrewBarba opened this issue Jul 30, 2024 · 10 comments · Fixed by swiftlang/swift-corelibs-foundation#5037
Closed

Build issue on nightly-6.0-amazonlinux2 #61

AndrewBarba opened this issue Jul 30, 2024 · 10 comments · Fixed by swiftlang/swift-corelibs-foundation#5037

Comments

@AndrewBarba
Copy link

AndrewBarba commented Jul 30, 2024

I'm currently experiencing build issues on nightly-6.0-amazonlinux2. Appears related to the new Foundation on nightly:

/workspace/.build/checkouts/swift-http-types/Sources/HTTPTypesFoundation/HTTPRequest+URL.swift:15:8: error: no such module 'CoreFoundation'
 13 | //===----------------------------------------------------------------------===//
 14 | 
 15 | import CoreFoundation
    |        `- error: no such module 'CoreFoundation'
 16 | import Foundation
 17 | import HTTPTypes

Edit: Full command used to build

/usr/local/bin/docker run \
  --platform linux/arm64 \
  --rm \
  -v ./:/workspace \
  -w /workspace \
  swiftlang/swift:nightly-6.0-amazonlinux2 bash -cl swift build -c release -Xswiftc -Osize --static-swift-stdlib
@guoye-zhang
Copy link
Contributor

@jrflat Do you know what’s happening there?

@Lukasa
Copy link

Lukasa commented Jul 30, 2024

I believe CoreFoundation is not intended to be part of the x-platform piece of Foundation, and so we probably shouldn't depend on it. This is probably related to re-homing Foundation on swift-foundation.

@FranzBusch
Copy link
Member

I agree. We must never import CoreFoundation on non-Darwin platforms. We don't guarantee any stability around that and with the re-core CoreFoundation is going away long term on non-Darwin platforms

@jrflat
Copy link

jrflat commented Jul 30, 2024

Yeah, we'll probably need to migrate from the CFURL functions to using URL, at least on non-Darwin platforms. I can help with this

cc: @jmschonfeld

@guoye-zhang
Copy link
Contributor

This CoreFoundation dependency is unfortunately unavoidable today unless Foundation URL starts supporting WHATWG parsing.

@jmschonfeld
Copy link

Yes CoreFoundation is not public API on non-Darwin and should not be relied upon outside of swift-corelibs-foundation so it should be removed from here. That being said, I don't think we explicitly removed the CoreFoundation module in the re-core and we still have projects that import it (incorrectly) that are successfully building. I can also successfully import the module from swift repl inside of a nightly-amazonlinux2 container. Let me check nightly-6.0-amazonlinux2

@jmschonfeld
Copy link

While I do not advocate for any CF code, the following does still appear to be functional to me on the latest nightly-6.0-amazonlinux2 container:

root@nightly-6 Repos]# swift test.swift
16
[root@nightly-6 Repos]# cat test.swift
import CoreFoundation
import Foundation

var url = URL(string: "http://apple.com")! as NSURL
let cf = unsafeBitCast(url, to: CFURL.self)
let length = CFURLGetBytes(cf, nil, 0)
print(length)[root@nightly-6 Repos]# swift test.swift
16
[root@nightly-6 Repos]# cat /etc/os-release 
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
SUPPORT_END="2025-06-30"

@AndrewBarba
Copy link
Author

AndrewBarba commented Jul 30, 2024

@jmschonfeld If helpful, here is full command I'm running to build:

/usr/local/bin/docker run \
  --platform linux/arm64 \
  --rm \
  -v ./:/workspace \
  -w /workspace \
  swiftlang/swift:nightly-6.0-amazonlinux2 bash -cl swift build -c release -Xswiftc -Osize --static-swift-stdlib

@jmschonfeld
Copy link

Aha, that --static-swift-stdlib is the key:

[root@nightly-amazonlinux2 Repos]# swiftc -static-stdlib test.swift                                                                                                                                                                                                                                                                                                        
/Repos/test.swift:1:8: error: no such module 'CoreFoundation'
1 | import CoreFoundation
  |        `- error: no such module 'CoreFoundation'
2 | import Foundation
3 | 
[root@nightly-amazonlinux2 Repos]# swiftc test.swift
<no output>

Looks like the CoreFoundation module was removed from the static swift build

@jmschonfeld
Copy link

We should consider removing the CoreFoundation usages here at some point, but I've posted swiftlang/swift-corelibs-foundation#5037 to resolve the regression here from previous behavior caused by the re-core (since I expect that this issue might have other unintended consequences so we should likely fix it anyways)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants