johnno1962 / InstantSyntax

SwiftSyntax binary frameworks
Apache License 2.0
47 stars 3 forks source link

Enable original package patching using swift package mirroring #5

Open lyzkov opened 3 weeks ago

lyzkov commented 3 weeks ago

As we discussed in swift-syntax, a top-level package dependency graph can be patched with:

swift package config set-mirror --original https://github.com/swiftlang/swift-syntax --mirror https://github.com/johnno1962/InstantSyntax

This can potentially ease swift-syntax replacement with its respective binary version. The only caveat is that the repository of the mirrored package should contain all tags from the original repository for the SPM to resolve the overridden package.

Since then, the request from the Swift community for InstantSyntax has been to maintain all tags from the source package repository.

Thank you in advance.

johnno1962 commented 3 weeks ago

Maintaining tags for all those in the source repo isn't the only issue this repo faces. Versioning is a complex problem which Apple is much better situated to resolve given they have control of the related tooling. I'm afraid I won't be looking at this.

lyzkov commented 2 weeks ago

I don't know if all tags are necessary to recreate. Maybe major + or minor? I’ve tried to replace the original swift-syntax with my fork of InstantSyntax using the package mirroring in the project that depends on The Composable Architecture and it seems that a wide range of versions is available to choose from. Nonetheless, the compilation failed on switch covers known cases, but 'AccessorBlockSyntax.Accessors' may have additional unknown values.

EDIT: I've tackled the issue of nonexhaustive switch by covering unknown cases in forked versions of TCA dependencies.

However, the main problem is Emit Swift module (arm64):

external macro implementation type 'PerceptionMacros.PerceptibleMacro' could not be found for macro 'Perceptible()'; '/Users/lyzkov/Library/Developer/Xcode/DerivedData/MyProject/Build/Products/Debug/PerceptionMacros' produced malformed response

I'm not sure because the build error message is very enigmatic. @vmanot Maybe you have some ideas?

I guess that the problem is caused by commenting out unsafe flags for weak frameworks to link.

let staticLink = ["\(clone)\(tag)/libSwiftSyntax.a"] +
    modules.map { $0.name }.flatMap({ module in
    ["-weak_framework", module] + platforms.flatMap({
        ["-F", "\(clone)\(tag)/\(module).xcframework/\($0)"] })
    })

(...)

    .target(
      name: "InstantSyntax"
//      linkerSettings: [.unsafeFlags(staticLink)]
    ),

I've did it get rid of package resolution error:

the target 'InstantSyntax' in product 'SwiftSyntaxMacros' contains unsafe build flags

which is (in my opinion) due to an overly restrictive SPM policy towards passing custom compilation flags.

@johnno1962 Have you been troubled with passing unsafe flags during InstantSyntax development?