Skip to content

Building with the flag --build-tests fails if there is at least one product whose type is static #5048

@kkebo

Description

@kkebo

Describe the bug

I don't know this is a bug, but swift build --build-tests --triple wasm32-unknown-wasi fails if there is at least one product whose type is static.

$ swift build --build-tests --triple wasm32-unknown-wasi Building for debugging... ar: @/Users/kebo/wasm-static-test/.build/wasm32-unknown-wasi/debug/wasm-static-test-static.product/Objects.LinkFileList: No such file or directory [3/11] Archiving libwasm-static-test-static.a

Steps To Reproduce

$ mkdir wasm-static-test && cd wasm-static-test $ swift package init --type library Creating library package: wasm-static-test  Creating Package.swift  Creating README.md  Creating .gitignore  Creating Sources/  Creating Sources/wasm-static-test/wasm_static_test.swift  Creating Tests/  Creating Tests/wasm-static-testTests/  Creating Tests/wasm-static-testTests/wasm_static_testTests.swift $ vim Package.swift # Add `type: .static` to `product` (see the following example) $ swift build --build-tests --triple wasm32-unknown-wasi Building for debugging... ar: @/Users/kebo/wasm-static-test/.build/wasm32-unknown-wasi/debug/wasm-static-test-static.product/Objects.LinkFileList: No such file or directory [3/11] Archiving libwasm-static-test-static.a

The modified part of Package.swift:

 .library( name: "wasm-static-test-static", type: .static, // <-- I added this line targets: ["wasm-static-test"]),

Expected behavior

.build/debug/wasm-static-testPackageTests.wasm is built normally.

Screenshots

Environment (please fill out the following information)

$ sw_vers ProductName: macOS ProductVersion: 13.1 BuildVersion: 22C5033e $ uname -a Darwin xylotruesgideon.lan 22.2.0 Darwin Kernel Version 22.2.0: Sun Oct 16 18:11:16 PDT 2022; root:xnu-8792.60.32.0.1~11/RELEASE_ARM64_T8103 arm64 $ swiftenv version wasm-DEVELOPMENT-SNAPSHOT-2022-10-04-a (set by /Users/kebo/wasm-static-test/.swift-version) $ xcodebuild -version Xcode 14.1 Build version 14B47b

Additional context

The ar command said that there was no such file or directory as /Users/kebo/wasm-static-test/.build/wasm32-unknown-wasi/debug/wasm-static-test-static.product/Objects.LinkFileList, but it appears to exist.

$ cat /Users/kebo/wasm-static-test/.build/wasm32-unknown-wasi/debug/wasm-static-test-static.product/Objects.LinkFileList /Users/kebo/wasm-static-test/.build/wasm32-unknown-wasi/debug/wasm_static_test.build/wasm_static_test.swift.o /Users/kebo/wasm-static-test/.build/wasm32-unknown-wasi/debug/wasm_static_test.build/wasm_static_test.swiftmodule.o

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions