Open leaanthony opened 2 years ago
Hey thanks for posting this!
Hey, Great job creating this. Ran into a small issue. Wails CLI v2.0.0-beta.33
App Type: desktop Platforms: darwin/universal Compiler: C:\Program Files\Go\bin\go.exe Build Mode: Production Skip Frontend: false Compress: false Package: true Clean Build Dir: false LDFlags: "" Tags: []
Crosscompiling to Mac not currently supported.
Crosscompiling is not working for linux as well. got any solutions?
You'll notice that this is still a WIP.
Oh my bad. I was following a video from youtube where the author himself is explaining the crosscompiling process and it was working fine for him. Sorry.
This ticket is for the V2 version which I do not believe has working cross-compile at this time.
V1 used to work with what was available.. if it isn't working now I would open an issue on that.
Didn't mean to be harsh.
Cross compilation for v2 works for all scenarios apart from when the target is Mac and the compilation host isn't. If you really want to cross compile right now you can do so using GitHub actions. Both the October app and https://riftshare.app take this approach. I'll update the docs with this information over the weekend 👍
https://github.com/marcus-crane/october/blob/main/.github/workflows/release.yaml
V1 used to work with what was available.. if it isn't working now I would open an issue on that.
V1 is at bug+feature freeze.
Oh okay. But I could not get cross-compiling to Linux working as well. Anyway, Thank you for this awesome project. I'll start looking for alternatives to this compiling issue. wails build -platform linux Wails CLI v2.0.0-beta.33
App Type: desktop Platforms: linux Compiler: C:\Program Files\Go\bin\go.exe Build Mode: Production Skip Frontend: false Compress: false Package: true Clean Build Dir: false LDFlags: "" Tags: []
Crosscompiling to Linux not currently supported.
Latest versions should work for you but you need docker
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
We may leave "Cross-compilation" for Mac as a github actions task for v2. I will timebox trying to get xgo working to 1 evening and then leave this as a post-v2 task. The majority of people developing for Mac will have a Mac so I'm not sure how many people this really affects.
Cross compilation will be handled by GitHub actions for v2. Bumping this down the road.
Another option: https://github.com/goreleaser/goreleaser-cross
How to cross compile linux/arm
Using GitHub actions is the best way
Cross compiling to darwin target works on linux host with osxcross.
Requirements:
./build.sh
./build_compiler_rt.sh
Examples:
CGO_CFLAGS="-mmacosx-version-min=10.15" CGO_LDFLAGS="-fuse-ld=lld -mmacosx-version-min=10.15 -framework UniformTypeIdentifiers" CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC="o64-clang" CXX="o64-clang++" go build -tags desktop,production -buildmode=pie -buildvcs=false -ldflags "-s -w" -a -o build/bin/Phantom-darwin-amd64
CGO_CFLAGS="-mmacosx-version-min=11.1" CGO_LDFLAGS="-fuse-ld=lld -mmacosx-version-min=11.1 -framework UniformTypeIdentifiers" CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 CC="o64-clang" CXX="o64-clang++" go build -tags desktop,production -buildmode=pie -buildvcs=false -ldflags "-s -w" -a -o build/bin/Phantom-darwin-arm64
Then you can make an universal binary with:
lipo -create -output build/bin/Phantom-darwin build/bin/Phantom-darwin-amd64 build/bin/Phantom-darwin-arm64
The resulting binary can be packaged into .app
. Running codesign and notary on an macOS host will work with the cross compiled binary:
rachel@rachels-iMac-Pro phantom % ./codesign.sh
Conducting pre-submission checks for Phantom.app.zip and initiating connection to the Apple notary service...
Submission ID received
id: (redacted)
Upload progress: 100.00% (11.9 MB of 11.9 MB)
Successfully uploaded file
id: (redacted)
path: /Users/rachel/code/phantom/build/bin/Phantom.app.zip
Waiting for processing to complete.
Current status: Accepted..........
Processing complete
id: (redacted)
status: Accepted
Processing: /Users/rachel/code/phantom/build/bin/Phantom.app
Processing: /Users/rachel/code/phantom/build/bin/Phantom.app
The staple and validate action worked!
You can try using https://github.com/indygreg/apple-platform-rs for codesigning on Linux, however I haven't tested it yet.
wails build -platform linux/amd64
DEB | Using go webview2loader Wails CLI v2.4.1
Platform(s) | linux/amd64 Compiler | C:\Program Files\Go\bin\go.exe Skip Bindings | false Build Mode | production Frontend Directory | D:\projects\myproject\frontend Obfuscated | false Skip Frontend | false Compress | false Package | true Clean Bin Dir | false LDFlags | Tags | [] Race Detector | false
WARNING Crosscompiling to Linux not currently supported.
Hi, until this investigation is concluded; I wanted to solve all of the cross compilation and targeting issues for my own project so I cooked up a Docker solution inspired by go-releaser-cross. It is available as open source here so feel free to use it.
Thank you!
Using GitHub actions is the best way
Unfortunately I can't use GitHub actions at work as we don't use GH at all, so not a way for us. Our pipelines run on on-premise machines which are either linux or windows. I'll try to play around with qemu and, in case of success, i'll report here.
EDIT: actually I don't think it's legal to setup virtual macos machines, so I guess I'll stick with manual builds for darwin.
EDIT: actually I don't think it's legal to setup virtual macos machines, so I guess I'll stick with manual builds for darwin.
Indeed, and it's not legal for us to re-distribute macos sdks so you can use docker to do it (though we may be able to find a way that doesn't involve us redistributing anything)...
Although there is the options for using xgo, this article suggests it might be possible to cross-compile in a more lightweight way using zig: https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho