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

Cross-compiling tests doesn't work if a package uses macros #8094

Open
1 task done
finagolfin opened this issue Nov 4, 2024 · 4 comments
Open
1 task done

Cross-compiling tests doesn't work if a package uses macros #8094

finagolfin opened this issue Nov 4, 2024 · 4 comments
Labels

Comments

@finagolfin
Copy link
Contributor

finagolfin commented Nov 4, 2024

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

It always fails with an error like this with my Android SDK bundles:

error: Failed opening '/home/finagolfin/swift-syntax/Examples/.build/aarch64-unknown-linux-android24/debug/index/store/v5/units/AddAsyncMacroTests.swift.o-20XPE2PQ2J7J7': No such file or directory

I first reported this bug in April, nothing has changed since.

Expected behavior

The tests to cross-compile

Actual behavior

Weird errors that it can't find a file

Steps to reproduce

  1. ~/swift-6.0.2-RELEASE-fedora39/usr/bin/swift sdk install ~/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle.tar.gz
  2. cd swift-syntax/Examples
  3. ~/swift-6.0.2-RELEASE-fedora39/usr/bin/swift build --build-tests --swift-sdk aarch64-unknown-linux-android24

It fails with a similar error for the latest trunk 6.1 SDK bundle used by the command ~/swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a-ubi9/usr/bin/swift build --build-tests --swift-sdk aarch64-unknown-linux-android24 -Xswiftc -disallow-use-new-driver, with that last flag needed because of a swift-driver 6.1 regression, swiftlang/swift-driver#1723.

Swift Package Manager version/commit hash

SwiftPM 6.0 and 6.1, cross-compiling packages that use macros didn't work at all before that

Swift & OS version (output of swift --version ; uname -a)

Swift 6.0.2/6.1 cross-compiling the swift-syntax example or swift-foundation tests for Android AArch64 from linux x86_64

@finagolfin finagolfin added the bug label Nov 4, 2024
@finagolfin
Copy link
Contributor Author

@marcprux, can you generate a linux SDK bundle on macOS using the swift-sdk-generator and see if this reproduces with the linux SDK bundle also?

@marcprux
Copy link

marcprux commented Nov 4, 2024

If I create a MacroDemo project with swift package init --type macro, it fails to cross-compile with a similar error:

$ ~/Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/bin/swift build --swift-sdk 6.0.2-RELEASE_ubuntu_jammy_aarch64 --build-tests

Fetching https://github.com/apple/swift-syntax.git from cache
Fetched https://github.com/apple/swift-syntax.git from cache (0.02s)
Creating working copy for https://github.com/apple/swift-syntax.git
Working copy of https://github.com/apple/swift-syntax.git resolved at 510.0.3
Building for debugging...
…
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
error: Failed opening '/opt/src/github/MacroDemo/.build/aarch64-swift-linux-musl/debug/index/store/v5/units/MacroDemoTests.swift.o-OV9PWKAUKWEY': No such file or directory

The same error occurs with the 6.0.2-RELEASE_ubuntu_jammy_aarch64 (which I built with swift-sdk-generator: swift run swift-sdk-generator make-linux-sdk --swift-version 6.0.2-RELEASE), as well as with both the Musl SDK (swift-6.0.2-RELEASE_static-linux-0.0.1) and the Android SDK (swift-6.0.2-RELEASE-android-24-0.1).

@marcprux
Copy link

marcprux commented Nov 4, 2024

Note that this might not affect all macros, but might be some specific issue with SwiftSyntaxMacros (or SwiftSyntaxMacrosTestSupport). If I create a variant of the sample macro project that just tests the #stringify macro directly (see MacroDemoLibTests.swift), then it builds successfully and the tests pass on Android.

@finagolfin
Copy link
Contributor Author

Thanks for checking, Marc.

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

No branches or pull requests

2 participants