Skip to content
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

Unable to create Bookworm SDK (unclear documentation) #189

Open
dscreve opened this issue Feb 25, 2025 · 16 comments
Open

Unable to create Bookworm SDK (unclear documentation) #189

dscreve opened this issue Feb 25, 2025 · 16 comments
Labels
documentation Improvements or additions to documentation

Comments

@dscreve
Copy link

dscreve commented Feb 25, 2025

Just enter the following command :

$> swift run swift-sdk-generator make-linux-sdk --with-docker --from-container-image swift:6.0.3-bookworm:latest --sdk-name 6.0.3-bookworm

Result :
warning: failed to retrieve search paths with pkg-config; maybe pkg-config is not installed
warning: couldn't find pc file for sqlite3
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build of product 'swift-sdk-generator' complete! (2.18s)
2025-02-25T19:48:51+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Downloading required toolchain packages...
2025-02-25T19:48:51+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Using downloaded artifacts from cache
2025-02-25T19:48:51+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Launching a container to extract the Swift SDK for the target triple...
Error: process exited non-zero: exit(125)

@xtremekforever
Copy link
Contributor

xtremekforever commented Feb 25, 2025

Looks like you have a typo in your tag name. It should be:

--from-container-image swift:6.0.3-bookworm

Without the last :latest part.

@MaxDesiatov MaxDesiatov added the question Further information is requested label Feb 26, 2025
@MaxDesiatov
Copy link
Contributor

Hi @dscreve, would you be able to confirm that the issue is resolved for you when using the proposed tag name?

@dscreve
Copy link
Author

dscreve commented Feb 27, 2025

Hello,

This works fine, but If I use an amd64 image on Mac M1, it does not works. Only arm64 image works.

I have created an amd64 Linux image from with this docker file :
FROM swift:6.0.3-bookworm

Then, use this command :
% swift run swift-sdk-generator make-linux-sdk --with-docker --from-container-image dlta-swift-docker-amd64 --sdk-name 6.0.3-bookworm-amd64

And I have the following error messages :
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build of product 'swift-sdk-generator' complete! (0.27s)
2025-02-27T14:37:30+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Downloading required toolchain packages...
2025-02-27T14:37:30+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Using downloaded artifacts from cache
2025-02-27T14:37:30+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Launching a container to extract the Swift SDK for the target triple...
Error: process exited non-zero: exit(125)

If I go into the Bundles/6.0.3-bookworm-amd64.artifactbundle/6.0.3-bookworm-amd64 directory, I have a directory named
aarch64-unknown-linux-gnu.
So, it seems to be a problem with target architecture.

And I don't know if Glibc has been selected instead of Musl

David

@xtremekforever
Copy link
Contributor

@dscreve you have to provide the --target param as well: --target x86_64-unknown-linux-gnu

If your container arch doesn't match the target arch it will certainly have issues. So, the full command should be:

swift run swift-sdk-generator make-linux-sdk --with-docker --from-container-image dlta-swift-docker-amd64 --target x86_64-unknown-linux-gnu --sdk-name 6.0.3-bookworm-amd64

@dscreve
Copy link
Author

dscreve commented Feb 28, 2025

Thanks ! this works fine for sdk creation.

What are the accepted values for --parameters ? readme.md documentation seems to be outdated and incomplete.

Now, I try to compile a project on my Mac using x86-64 and aarch64 SDK.

I get some warnings :
warning: Could not read SDKSettings.json for SDK at: /Users/dscreve/Library/org.swift.swiftpm/swift-sdks/6.0.3-bookworm-amd64.artifactbundle/6.0.3-bookworm-amd64/x86_64-unknown-linux-gnu/ubuntu-jammy.sdk

warning: libc not found for 'x86_64-unknown-linux-gnu'; C stdlib may be unavailable

And when compiling, I get compilation errors :
9 | import CryptoKit
| `- error: no such module 'CryptoKit'

any idea how to fix it ?

David

@xtremekforever
Copy link
Contributor

Um....I think that CryptoKit is not available on Linux platforms...am I correct @MaxDesiatov ?

@MaxDesiatov
Copy link
Contributor

You should use swift-crypto instead, which will switch between CryptoKit and the OSS shims over BoringSSL, depending on the OS you're targeting.

@euanh
Copy link
Contributor

euanh commented Feb 28, 2025

You can ignore these warnings:

warning: Could not read SDKSettings.json for SDK at: /Users/dscreve/Library/org.swift.swiftpm/swift-sdks/6.0.3-bookworm-amd64.artifactbundle/6.0.3-bookworm-amd64/x86_64-unknown-linux-gnu/ubuntu-jammy.sdk

#185 should fix this warning

warning: libc not found for 'x86_64-unknown-linux-gnu'; C stdlib may be unavailable

swiftlang/swift#76545 should fix this warning

@dscreve
Copy link
Author

dscreve commented Feb 28, 2025

You should use swift-crypto instead, which will switch between CryptoKit and the OSS shims over BoringSSL, depending on the OS you're targeting.

You are right !

I will fix this.

@MaxDesiatov MaxDesiatov added documentation Improvements or additions to documentation and removed question Further information is requested labels Feb 28, 2025
@MaxDesiatov
Copy link
Contributor

Thanks for checking! I'll keep this open as a reminder for documentation improvements.

@MaxDesiatov MaxDesiatov changed the title Unable to create Bookworm SDK Unable to create Bookworm SDK (unclear documentation) Feb 28, 2025
@dscreve
Copy link
Author

dscreve commented Feb 28, 2025

I replaced CryptoKit with swift-crypto, but still have the issue :

import Crypto
| `- error: no such module 'Crypto'

Any idea ?

@MaxDesiatov
Copy link
Contributor

Does it build on macOS without cross compilation that way? If not, I'd say this is specific to your package and is not caused by Swift SDK Generator.

First thing to look for would be target/product dependencies not specified in Package.swift. Maybe one of your targets where you have import Crypto doesn't specify a dependency on .product(name: "Crypto", package: "swift-crypto")?

@dscreve
Copy link
Author

dscreve commented Mar 1, 2025

I think I have fixed this, but I cannot check because I have a compiler crash.

@MaxDesiatov
Copy link
Contributor

Would you mind linking to the crash bugreport here?

@dscreve
Copy link
Author

dscreve commented Mar 1, 2025

Actually it is related to the use of CryptoKit that I missed and that cause compiler error because it use static method of CryptoKit. Issue was encountered in standard linux compilation. That's not related to SDK usage.

@dscreve
Copy link
Author

dscreve commented Mar 2, 2025

Good news : Everything is compiling now...but I'm linking against libcrypto (openSSL) and it does not work.

I have installed libssl-dev in docker Image as below :
RUN apt update && apt -y install libssl-dev && apt -y clean

But I don't know how to tell him to add it in the generated SDK and I have the following error :
ld.lld: error: undefined symbol: RAND_bytes
(and many others for the all call to libcrypto).

I have openSSL installed on the Mac, and It seems to try to look in the Mac library :
ld.lld: warning: /opt/homebrew/Cellar/openssl@3/3.0.7/lib/libssl.a: archive member 'libssl-lib-bio_ssl.o' is neither ET_REL nor LLVM bitcode

I have created another issue for that.

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

No branches or pull requests

4 participants