feat: Add support for conditional static linking of C lib to builds#1292
Merged
maaarcelino merged 2 commits intomainfrom Oct 16, 2023
Merged
feat: Add support for conditional static linking of C lib to builds#1292maaarcelino merged 2 commits intomainfrom
maaarcelino merged 2 commits intomainfrom
Conversation
2 tasks
erezrokah
reviewed
Oct 16, 2023
serve/package.go
Outdated
| return nil, err | ||
| } | ||
| ldFlags := fmt.Sprintf("-s -w -X %s/plugin.Version=%s", importPath, pluginVersion) | ||
| if getEnvOrDefault("STATIC_LINKING_ENABLED", "0") == "1" { |
Member
There was a problem hiding this comment.
Can we make this into a plugin option? See example https://github.com/cloudquery/cloudquery/blob/9e916090240a33ddf5a0163b950bf8fc1a8873ed/plugins/destination/sqlite/main.go#L23
Not sure if we want withStaticLinking bool option or withAdditionalLDFlags []string flag. Maybe withStaticLinking is good for now
erezrokah
requested changes
Oct 16, 2023
kodiakhq bot
pushed a commit
that referenced
this pull request
Oct 16, 2023
🤖 I have created a release *beep* *boop* --- ## [4.13.0](v4.12.5...v4.13.0) (2023-10-16) ### Features * Add support for conditional static linking of C lib to builds ([#1292](#1292)) ([7c27065](7c27065)) * Support Delete Record ([#1282](#1282)) ([1f0a603](1f0a603)) ### Bug Fixes * **deps:** Update github.com/cloudquery/arrow/go/v14 digest to dbcb149 ([#1291](#1291)) ([7c634dc](7c634dc)) * **deps:** Update module github.com/cloudquery/plugin-pb-go to v1.12.3 ([#1289](#1289)) ([3e063bc](3e063bc)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for conditionally linking C libs when building plugin executables. CGO_ENABLED plugins (sqlite and duckdb) fail to run on Alpine Linux distributions because of missing C libraries needed to execute the code. See cloudquery/cloudquery#14465.
The fix is to include those missing libraries into the executable that is created by
go build:CGO_ENABLED=1 go build -ldflags="-linkmode external -extldflags=-static"