Skip to content

Failed to cross-compile source code using #Predicate macros. #27

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
ser-0xff opened this issue Oct 25, 2023 · 2 comments
Closed

Failed to cross-compile source code using #Predicate macros. #27

ser-0xff opened this issue Oct 25, 2023 · 2 comments

Comments

@ser-0xff
Copy link

Hi!
We would like to create Linux binaries/executables on macOS using cross compilation possibilities.
Some projects works fine, but we have an issue compiling a project using the new predicate functionality from swift-foundation package.
There is a minimised test, which compiles fine on macOS and Linux, but does not compile on macOS for Linux using a cross-compile.
We created a cross-compile toolchain according to directions in the README:

mbpro~ macros-cross-compile % swift experimental-sdk list                                          
5.9-RELEASE_ubuntu_jammy_aarch64

and when using it have the following:

mbpro~ macros-cross-compile % swift build --experimental-swift-sdk 5.9-RELEASE_ubuntu_jammy_aarch64
Building for debugging...
warning: Could not read SDKSettings.json for SDK at: /Users/user/Library/org.swift.swiftpm/swift-sdks/5.9-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.9-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk
warning: Could not read SDKSettings.json for SDK at: /Users/user/Library/org.swift.swiftpm/swift-sdks/5.9-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.9-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk
<unknown>:0: warning: glibc not found for 'aarch64-unknown-linux-gnu'; C stdlib may be unavailable
.....
Macros: Operation not permitted
<unknown>:0: warning: glibc not found for 'aarch64-unknown-linux-gnu'; C stdlib may be unavailable
<unknown>:0: warning: glibc not found for 'aarch64-unknown-linux-gnu'; C stdlib may be unavailable
warning: Could not read SDKSettings.json for SDK at: /Users/user/Library/org.swift.swiftpm/swift-sdks/5.9-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.9-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk
error: emit-module command failed with exit code 1 (use -v to see invocation)
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
/Users/user/external-reproducers/swift/macros-cross-compile/.build/aarch64-unknown-linux-gnu/debug/FoundationMacros: /Users/user/external-reproducers/swift/macros-cross-compile/.build/aarch64-unknown-linux-gnu/debug/FoundationMacros: Operation not permitted
<unknown>:0: warning: compiler plugin not loaded: '/Users/user/external-reproducers/swift/macros-cross-compile/.build/aarch64-unknown-linux-gnu/debug/FoundationMacros; failed to initialize
/Users/user/external-reproducers/swift/macros-cross-compile/Sources/MacrosCrossCompile/Main.swift:8:17: error: external macro implementation type 'FoundationMacros.PredicateMacro' could not be found for macro 'Predicate'
let predicate = #Predicate<Monster> { monster in
                ^
/Users/user/external-reproducers/swift/macros-cross-compile/.build/checkouts/swift-foundation/Sources/FoundationEssentials/Predicate/Predicate.swift:33:14: note: 'Predicate' declared here
public macro Predicate<each Input>(_ body: (repeat each Input) -> Bool) -> Predicate<repeat each Input> = #externalMacro(module: "FoundationMacros", type: "PredicateMacro")
             ^
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
/Users/user/external-reproducers/swift/macros-cross-compile/.build/aarch64-unknown-linux-gnu/debug/FoundationMacros: /Users/user/external-reproducers/swift/macros-cross-compile/.build/aarch64-unknown-linux-gnu/debug/FoundationMacros: Operation not permitted
<unknown>:0: warning: compiler plugin not loaded: '/Users/user/external-reproducers/swift/macros-cross-compile/.build/aarch64-unknown-linux-gnu/debug/FoundationMacros; failed to initialize
/Users/user/external-reproducers/swift/macros-cross-compile/Sources/MacrosCrossCompile/Main.swift:8:17: error: external macro implementation type 'FoundationMacros.PredicateMacro' could not be found for macro 'Predicate'
let predicate = #Predicate<Monster> { monster in
                ^
/Users/user/external-reproducers/swift/macros-cross-compile/.build/checkouts/swift-foundation/Sources/FoundationEssentials/Predicate/Predicate.swift:33:14: note: 'Predicate' declared here
public macro Predicate<each Input>(_ body: (repeat each Input) -> Bool) -> Predicate<repeat each Input> = #externalMacro(module: "FoundationMacros", type: "PredicateMacro")
             ^
error: fatalError

The source code of the minimised test available in the repo

Steps to reproduce

mbpro~ git clone https://github.com/ordo-one/external-reproducers.git
Cloning into 'external-reproducers'...
remote: Enumerating objects: 231, done.
remote: Counting objects: 100% (231/231), done.
remote: Compressing objects: 100% (155/155), done.
remote: Total 231 (delta 92), reused 154 (delta 38), pack-reused 0
Receiving objects: 100% (231/231), 42.60 KiB | 1.22 MiB/s, done.
Resolving deltas: 100% (92/92), done.
mbpro~ cd external-reproducers/swift/macros-cross-compile 
mbpro~ swift build --experimental-swift-sdk 5.9-RELEASE_ubuntu_jammy_aarch64
@ser-0xff ser-0xff changed the title Failed to cross-compile source code using macros. Failed to cross-compile source code using #Predicate macros. Oct 25, 2023
@MaxDesiatov
Copy link
Contributor

Macros are currently not supported in cross-compilation. This is not something we can address in Swift SDK Generator, the issue is on SwiftPM side. Closing as a duplicate of swiftlang/swift-package-manager#6950.

@MaxDesiatov MaxDesiatov closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
@jpsim
Copy link

jpsim commented Nov 17, 2023

Macros: Operation not permitted
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted

I think this is related to swiftlang/swift-package-manager#7098

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

No branches or pull requests

3 participants