Skip to content

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

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
kkebo opened this issue Nov 8, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@kkebo
Copy link

kkebo commented Nov 8, 2022

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
@kkebo kkebo added the bug Something isn't working label Nov 8, 2022
@kkebo
Copy link
Author

kkebo commented Nov 8, 2022

https://github.com/apple/swift-syntax is a real example.

At least now it succeeds to build a package product depending on swift-syntax (e.g. swift-format) for wasm-unknown-wasi without any errors, but it fails to build swift-syntax itself because of the same errors I pasted on the description.

Thus, in order to run tests of swift-syntax, I had to remove type: .static from all products like this:

swiftlang/swift-syntax@main...kkk669:swift-syntax:wasm32-wasi-test

@kateinoigakukun
Copy link
Member

The problem here was that the driver wrongly chose system ar instead of llvm-ar. I think it's resolved by swiftlang/swift-driver#1523 and I don't see the issue with the latest snapshot https://github.com/swiftwasm/swift/releases/tag/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-03-01-a

@kkebo
Copy link
Author

kkebo commented Mar 2, 2024

Thank you. I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants