-
Notifications
You must be signed in to change notification settings - Fork 310
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
goreleaser: add -static to LDFLAGS for windows build #5594
Conversation
@@ -64,6 +64,7 @@ builds: | |||
- amd64 | |||
env: | |||
- CGO_ENABLED=1 | |||
- CGO_LDFLAGS=-static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add it to every build to be consistent? i'd hate if we had a bug that only affected static builds. i guess in theory macos should always have glibc from xcode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually can't statically link to the system libraries on macOS - they require you to dynamically link:
⨯ build failed after 181.83s error=failed to build for darwin_amd64: exit status 2: # runtime/cgo
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And fwiw, for Linux, I think it's expected that you either dynamically link against glibc or statically link everything using musl.
Our current setup should be fine on those OSes as we don't have any implicit links to non-system libraries (e.g. we didn't apt-get install libusb-dev
and then dynamically link against the system copy - the go-tree-sitter
package vendors in the Tree-sitter code so it'll get compiled straight in)
From v0.26.0:
Linux
ldd $(which tilt)
linux-vdso.so.1 (0x00007ffd56fc4000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f697ac6d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f697ac67000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f697aa85000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f697a936000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f697a91b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f697a729000)
/lib64/ld-linux-x86-64.so.2 (0x00007f697ac95000)
Darwin
$ otool -L $(which tilt)
/usr/local/bin/tilt:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1775.118.101)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 59754.100.106)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1122.33.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 905.6.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, might be worth adding CGO_ENABLED=1 CGO_LDFLAGS=-static
to the CircleCI build-windows
job:
Line 73 in b1ac829
- run: go install -mod vendor ./cmd/tilt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also some interesting notes here, so maybe building static cross compiled binaries is a thing people want to do, and yet, I don't want to complicate things here too much.
83db7ec
to
bf5b236
Compare
No description provided.