Skip to content
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

Merged
merged 2 commits into from
Mar 15, 2022

Conversation

nicksieger
Copy link
Member

No description provided.

@nicksieger nicksieger requested a review from nicks March 15, 2022 01:30
@nicksieger nicksieger linked an issue Mar 15, 2022 that may be closed by this pull request
@@ -64,6 +64,7 @@ builds:
- amd64
env:
- CGO_ENABLED=1
- CGO_LDFLAGS=-static
Copy link
Member

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

Copy link
Contributor

@milas milas Mar 15, 2022

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)

Copy link
Contributor

@milas milas Mar 15, 2022

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:

- run: go install -mod vendor ./cmd/tilt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok!

Copy link
Member Author

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.

@nicksieger nicksieger merged commit aa3efbc into master Mar 15, 2022
@nicksieger nicksieger deleted the nicksieger/5593 branch March 15, 2022 15:14
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

Successfully merging this pull request may close these issues.

Tilt v0.26.0 does not work on windows
3 participants