Libc not found for 'wasm32-unknown-wasi'

I created a docker image to develop a web app.
This image is running on the aarch64 armbian.
this is the Dockerfile:

FROM swift:focal

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libgtk+-3.0 gtk+-3.0

EXPOSE 8080

I also use carton
I use the plugin command:

swift run carton dev

then, I encounter the error below:

<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
warning: Could not read SDKSettings.json for SDK at: /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/share/wasi-sysroot
<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
[144/171] Wrapping AST for OpenCombine for debugging
[146/173] Compiling OpenCombineShim OpenCombineShim.swift
[147/173] Emitting module OpenCombineShim
<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
warning: Could not read SDKSettings.json for SDK at: /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/share/wasi-sysroot
[151/189] Compiling CartonCore TerminalController.swift
/app/.build/carton/checkouts/carton/Sources/CartonCore/InteractiveWriter.swift:14:55: error: cannot find type 'FILE' in scope
 12 |   public typealias FILEPointer = OpaquePointer
 13 | #else
 14 |   public typealias FILEPointer = UnsafeMutablePointer<FILE>
    |                                                       `- error: cannot find type 'FILE' in scope
 15 | #endif
 16 | 

/app/.build/carton/checkouts/carton/Sources/CartonCore/TerminalController.swift:146:18: error: cannot find 'winsize' in scope
144 |       // a temporary arrangement and needs to be fixed.
145 |       #if !arch(powerpc64le)
146 |         var ws = winsize()
    |                  `- error: cannot find 'winsize' in scope
147 |         #if os(OpenBSD)
148 |           let tiocgwinsz = 0x4008_7468

/app/.build/carton/checkouts/carton/Sources/CartonCore/TerminalController.swift:151:35: error: cannot find 'TIOCGWINSZ' in scope
149 |           let err = ioctl(1, UInt(tiocgwinsz), &ws)
150 |         #else
151 |           let err = ioctl(1, UInt(TIOCGWINSZ), &ws)
    |                                   `- error: cannot find 'TIOCGWINSZ' in scope
152 |         #endif
153 |         if err == 0 {
<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
[151/218] Wrapping AST for OpenCombineShim for debugging
<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
warning: Could not read SDKSettings.json for SDK at: /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/share/wasi-sysroot
warning: Could not read SDKSettings.json for SDK at: /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/share/wasi-sysroot
error: emit-module command failed with exit code 1 (use -v to see invocation)
[154/337] Compiling CartonCore Misc.swift
[155/338] Emitting module CartonCore
/app/.build/carton/checkouts/carton/Sources/CartonCore/FoundationProcessEx.swift:3:22: error: no type named 'Process' in module 'Foundation'
  1 | import Foundation
  2 | 
  3 | extension Foundation.Process {
    |                      `- error: no type named 'Process' in module 'Foundation'
  4 |   // Monitor termination/interrruption signals to forward them to child process
  5 |   public func setSignalForwarding(_ signalNo: Int32) {

/app/.build/carton/checkouts/carton/Sources/CartonCore/InteractiveWriter.swift:14:55: error: cannot find type 'FILE' in scope
 12 |   public typealias FILEPointer = OpaquePointer
 13 | #else
 14 |   public typealias FILEPointer = UnsafeMutablePointer<FILE>
    |                                                       `- error: cannot find type 'FILE' in scope
 15 | #endif
 16 | 
[156/338] Compiling CartonCore FoundationProcessEx.swift
/app/.build/carton/checkouts/carton/Sources/CartonCore/FoundationProcessEx.swift:3:22: error: no type named 'Process' in module 'Foundation'
  1 | import Foundation
  2 | 
  3 | extension Foundation.Process {
    |                      `- error: no type named 'Process' in module 'Foundation'
  4 |   // Monitor termination/interrruption signals to forward them to child process
  5 |   public func setSignalForwarding(_ signalNo: Int32) {
[157/338] Compiling CartonCore InteractiveWriter.swift
/app/.build/carton/checkouts/carton/Sources/CartonCore/InteractiveWriter.swift:14:55: error: cannot find type 'FILE' in scope
 12 |   public typealias FILEPointer = OpaquePointer
 13 | #else
 14 |   public typealias FILEPointer = UnsafeMutablePointer<FILE>
    |                                                       `- error: cannot find type 'FILE' in scope
 15 | #endif
 16 | 
[158/338] Compiling CartonCore Environment.swift
[159/338] Compiling CartonCore FileSystem+traverseRecursively.swift
/root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/CoreFoundation.h:28:10: note: while building module 'wasi_emulated_signal' imported from /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/CoreFoundation.h:28:
 26 | #include <setjmp.h>
 27 | #endif
 28 | #include <signal.h>
    |          `- note: while building module 'wasi_emulated_signal' imported from /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/CoreFoundation.h:28:
 29 | #include <stddef.h>
 30 | #include <stdio.h>

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "signal.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/root/.carton/sdk/wasm-6.0.2-RELEASE/usr/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
  1 | #ifndef _WASI_EMULATED_SIGNAL
  2 | #error "wasm lacks signal support; to enable minimal signal emulation, \
    |  `- error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
  3 | compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
  4 | #else

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "CoreFoundation.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/CoreFoundation.h:28:10: error: could not build module 'wasi_emulated_signal'
 26 | #include <setjmp.h>
 27 | #endif
 28 | #include <signal.h>
    |          `- error: could not build module 'wasi_emulated_signal'
 29 | #include <stddef.h>
 30 | #include <stdio.h>

/root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/ForSwiftFoundationOnly.h:79:10: note: while building module 'wasi_emulated_mman' imported from /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/ForSwiftFoundationOnly.h:79:
 77 | #undef _WASI_EMULATED_MMAN
 78 | #define _WASI_EMULATED_MMAN
 79 | #include <sys/mman.h>
    |          `- note: while building module 'wasi_emulated_mman' imported from /root/.carton/sdk/wasm-6.0.2-RELEASE/usr/lib/swift_static/CoreFoundation/ForSwiftFoundationOnly.h:79:
 80 | #elif TARGET_OS_LINUX
 81 | #include <errno.h>

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "sys/mman.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/root/.carton/sdk/wasm-6.0.2-RELEASE/usr/share/wasi-sysroot/include/sys/mman.h:2:2: error: "WASI lacks a true mmap; to enable minimal mmap emulation, compile with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman"
  1 | #ifndef _WASI_EMULATED_MMAN
  2 | #error "WASI lacks a true mmap; to enable minimal mmap emulation, \
    |  `- error: "WASI lacks a true mmap; to enable minimal mmap emulation, compile with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman"
  3 | compile with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman"
  4 | #else

<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
[159/341] Wrapping AST for JavaScriptKit for debugging

error: Plugin ended with exit code 1

Hi @carlhung, could you share your SwiftPM package source? I guess your package doesn't have any executable target.

1 Like

you are right. i forget to add product. thanks

I have same issue but on macOS.

Using swift-wasm-6.0.2-RELEASE.xctoolchain

Package file

// swift-tools-version:5.8
import PackageDescription
let package = Package(
    name: "MyApp",
    platforms: [.macOS(.v11), .iOS(.v13)],
    products: [
        .executable(name: "MyApp", targets: ["MyApp"]),
    ],
    dependencies: [
        .package(url: "https://github.com/TokamakUI/Tokamak", from: "0.11.0"),
        .package(url: "https://github.com/swiftwasm/carton", from: "1.0.0"),
    ],
    targets: [
        .executableTarget(
            name: "MyApp",
            dependencies: [
                .product(name: "TokamakShim", package: "Tokamak")
            ]),
    ]
)

Took it from this place Creating a browser app - Swift and WebAssembly

command swift run carton dev