-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
fyne-cross option -ldflags does not work properly like it does in go build #190
Comments
BTW it is recommended to use metadata rather than LDFlags as they do not work on all platforms even if you can get the commands into the compiler https://developer.fyne.io/started/metadata |
Thank you for the info about go problems with ldflags on some platforms but on linux and windows desktop OSes it works. I've used -ldflags in my other not fyne go project and it succeeded. When it comes to using metadata I know that vars are initialized with fyne and fyne-cross by means of transient go file with init() func. And if I do trivial I didn't found in fyne docs they recommended mandatory use of metadata or FyneApp.toml. If there is no way to fix the ldflags option in fyne-cross it will be right to delete ldflags option from fyne-cross help command to eliminate issues :) It's a real bug |
From memory, I think |
It also means you can set those argument in |
In fyne-cross sources I found such a test case: {
name: "custom ldflags",
args: args{
flags: &CommonFlags{
AppBuild: 1,
Ldflags: "-X main.version=1.2.3",
},
},
want: Context{
AppBuild: "1",
AppID: "",
Volume: vol,
CacheEnabled: true,
StripDebug: true,
Package: ".",
Engine: engine,
Env: map[string]string{
"GOFLAGS": "-ldflags=-X -ldflags=main.version=1.2.3",
},
},
wantErr: false,
}, and it passed |
|
I had a better look at this and it is a bit weird. It seems something is happening when calling We also do not pick the OS GOFLAGS and I have created a PR for it. Finally the syntax is the following at the moment (before my PR): After my PR the following, which follow actually go expectation: |
The syntax you describe above Concerning -release option with -ldflags I think it's because fyne has no -ldflags option for release command now when I run |
Sorry, that line should be working, but can't figure out why. The line that work for me is: The thing that change in |
I found that command /usr/bin/docker run --rm -t -w /app -v /home/vinser/Dev/t_fyne:/app:z -v /home/vinser/.cache/fyne-cross:/go:z --platform linux/arm64 -u 1000:1000 --entrypoint fixuid -v /tmp/ssh-XXXXXXq4THxC/agent.43703:/tmp/ssh-agent -e SSH_AUTH_SOCK=/tmp/ssh-agent -e CGO_ENABLED=1 -e GOCACHE=/go/go-build -e CXX=zig c++ -target aarch64-linux-gnu -isystem /usr/include -L/usr/lib/aarch64-linux-gnu -e GOOS=linux -e GOARCH=arm64 -e CC=zig cc -target aarch64-linux-gnu -isystem /usr/include -L/usr/lib/aarch64-linux-gnu docker.io/fyneio/fyne-cross-images:linux /usr/local/bin/fyne package -os linux -name t_fyne -icon /app/fyne-cross/tmp/linux-arm64/Icon.png -appBuild 20 -appVersion 1.0.0 -appID com.github.vinser.t_fyne -release |
Yes, that's why I did open PR #193 . The things that should currently work is: |
May i know when this would be fixed? |
It seems that there is a PR open, so you can see the latest over there. |
I got similar bug with ldflag too |
Did you see the PR linked above? |
Any progress ?? I can never understand why a project owner dooms his project to abandonment. Someone wanted to help you and solve the problem, as the community always does. And Yes I see that you asking about the "unit tests" for this PR, but not everyone is the best developer, you should help him instead of punishing him for that he wanted to help you. I hope I am wrong about you intention |
And I have the same problem; for now, I am fixing it using the |
I'm not quite sure what the intent of your message is here. Cedric who I was discussing this with is a core contributor to the project. Note also that the PR has been accepted - so he could merge it if he believed that I was wrong in the push back. Nobody is "dooming this project to abandonment" and this is run by a group of people, not a single individual. |
I believe this is a regression in 1.4.0. I updated from 1.3.0 (and my go version at the same time) and this broke my versioning which now means many customers auto-updates won't function and I'll have to have them manually re-download. Should there be some kind of notice on the readme to let people know about the regression? To be clear on the status - the PR that was merged only allows GOFLAGS to be used as a workaround? So the issue still persists I believe? I may take a stab at it since I'd like to get this working again in my CI and I can't downgrade to 1.3.0 due to my go version. |
The issue has been resolved as far as I can see. Please try the 1.5.0 release which includes the change. |
There is still more work to be done here. The test in fyne-cross is validating the wrong behavior (tested with go 1.22.3):
I also verified it will silently fail (second flag overwrites the first) when its not a syntax error:
So there is no way to pass multiple ldflags without proper quoting. This test at least ensures that we are using this incorrect approach when passing ldflags:
|
Yes - but is that quoting not what was added in 1.5.0? |
I think you might be thinking of the quoting that is put around the value of an environment variable when it has an I went on to debug further, as my workaround of setting GOFLAGS directly still didn't work as I expected. I believe its related to this code in |
I was able to track down my issue. I've explained it in the PR here: This was why the ldflags were ignored - they are converted to GOFLAGS in fyne cross, which are ignored by |
@Bluebugs can you comment on this? I'm a bit lost. |
I guess I'm still facing this issue while trying to fyne-cross a windows build from macOS.
Somewhere down the line, I tried the workaround mentioned above, it packages successfully but the value does not appear in the final package
|
Describe the bug:
Unlike
go build
fyne-cross option ldflags does nothing when I try to set global var withldflags "-X 'main.ver=1.0.0'"
To Reproduce:
For the code beneath - steps to reproduce the behavior:
Run the command
fyne-cross linux -ldflags "-X 'main.version=0.0.1'"
Run executable was built
See no version is displayed
Run the same code with the command
go run -ldflags "-X 'main.version=0.0.1'" .
See version is displayed
Example code:
Device and debug info (please complete the following information):
The text was updated successfully, but these errors were encountered: