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

Enforce version check on wasm lib #994

Closed
alpe opened this issue Sep 9, 2022 · 3 comments · Fixed by #1029
Closed

Enforce version check on wasm lib #994

alpe opened this issue Sep 9, 2022 · 3 comments · Fixed by #1029
Labels
S Estimated small

Comments

@alpe
Copy link
Contributor

alpe commented Sep 9, 2022

when used used as dynamic lib.
Follow up from #988 (comment)

Would a make build-linux target with static compilation be a sufficient solution?

@alpe alpe added the discussion label Sep 9, 2022
@jhernandezb
Copy link
Contributor

The only issue I see is that you can only build static binaries with muslc, which would probably require docker.

@webmaster128
Copy link
Member

The solution shown in https://github.com/public-awesome/stargaze/blob/2b06ae1cb8518dd19b128b65317da125efb9702d/cmd/starsd/cmd/start.go#L11-L22 is pretty cool. It does not differentiate between static libraries (which can be wrong by not updating the .a file in the builer docker) and shared libraries (which can be wrong when juggling with custom build systems).

I only wonder about this duplication. The line var LibwasmVersion = "1.0.0" is something that you should be able to get from the Go dependency management using

$ go list -m github.com/CosmWasm/wasmvm | cut -d" " -f2 | cut -d"v" -f2
1.1.1

Any idea how to get the build system information into the .go file?

@jhernandezb
Copy link
Contributor

You can use build info to get the version

package main

import (
	"fmt"
	"runtime/debug"

	_ "github.com/CosmWasm/wasmd/app"
)

func main() {
	buildInfo, ok := debug.ReadBuildInfo()
	if !ok {
		panic("can't read build info")
	}
	for _, d := range buildInfo.Deps {
		if d.Path != "github.com/CosmWasm/wasmvm" {
			continue
		}
		if d.Replace != nil {
			fmt.Printf("%s@%s => %s@%s\n", d.Path, d.Version, d.Replace.Path, d.Replace.Version)

		}
		fmt.Printf("%s@%s\n", d.Path, d.Version)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S Estimated small
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants