From 5280d0175f630fce04442ea3b2e03636e1ba5fcf Mon Sep 17 00:00:00 2001 From: TxCorpi0x <6095314+TxCorpi0x@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:46:52 +0300 Subject: [PATCH 1/4] Local binary linux wasmvm panic --- build/tx-chain/build.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/build/tx-chain/build.go b/build/tx-chain/build.go index 5b768642..1efd0054 100644 --- a/build/tx-chain/build.go +++ b/build/tx-chain/build.go @@ -221,7 +221,8 @@ func buildTXdInDocker( dockerVolumes := make([]string, 0) switch targetPlatform.OS { case txcrusttools.OSLinux: - // use cc not installed on the image we use for the build + // Linux builds must use muslc + static linking so the binary runs in Alpine (txd Docker image). + // Using glibc or dynamic wasmvm leads to SIGABRT in wasmvm/cgo when the binary runs in-container. if err := txcrusttools.Ensure(ctx, txchaintools.MuslCC, targetPlatform); err != nil { return err } @@ -229,13 +230,11 @@ func buildTXdInDocker( ldFlags = append(ldFlags, "-extldflags '-static'") var ( hostCCDirPath string - // path inside hostCCDirPath to the CC ccRelativePath string - wasmHostDirPath string - // path to the wasm lib in the CC wasmCCLibRelativeLibPath string ) + // Use targetPlatform for all tool paths so local and in-Docker builds use the same toolchain. switch targetPlatform { case txcrusttools.TargetPlatformLinuxAMD64InDocker: hostCCDirPath = filepath.Dir( @@ -251,9 +250,29 @@ func buildTXdInDocker( ccRelativePath = "/bin/aarch64-linux-musl-gcc" wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.aarch64.a", targetPlatform) wasmCCLibRelativeLibPath = "/aarch64-linux-musl/lib/libwasmvm_muslc.aarch64.a" + case txcrusttools.TargetPlatformLinuxLocalArchInDocker: + // Same toolchain as fixed arch above, chosen by runtime.GOARCH (CI can be amd64 or arm64). + if targetPlatform.Arch == txcrusttools.ArchAMD64 { + hostCCDirPath = filepath.Dir( + filepath.Dir(txcrusttools.Path("bin/x86_64-linux-musl-gcc", targetPlatform)), + ) + ccRelativePath = "/bin/x86_64-linux-musl-gcc" + wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.x86_64.a", targetPlatform) + wasmCCLibRelativeLibPath = "/x86_64-linux-musl/lib/libwasmvm_muslc.x86_64.a" + } else if targetPlatform.Arch == txcrusttools.ArchARM64 { + hostCCDirPath = filepath.Dir( + filepath.Dir(txcrusttools.Path("bin/aarch64-linux-musl-gcc", targetPlatform)), + ) + ccRelativePath = "/bin/aarch64-linux-musl-gcc" + wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.aarch64.a", targetPlatform) + wasmCCLibRelativeLibPath = "/aarch64-linux-musl/lib/libwasmvm_muslc.aarch64.a" + } else { + return errors.Errorf("building is not possible for platform %s", targetPlatform) + } default: return errors.Errorf("building is not possible for platform %s", targetPlatform) } + // Local Linux build: same muslc/static config as in-Docker, output to cache for Docker image. if !release && runtime.GOOS == txcrusttools.OSLinux { targetPlatform = txcrusttools.TargetPlatformLocal if err := copyLocalBinary(wasmHostDirPath, hostCCDirPath+wasmCCLibRelativeLibPath); err != nil { From bd25f6c7fd91a63d7056c145daee1420bbd59808 Mon Sep 17 00:00:00 2001 From: TxCorpi0x <6095314+TxCorpi0x@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:19:37 +0300 Subject: [PATCH 2/4] Refactor and move logic to function --- build/tx-chain/build.go | 102 +++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/build/tx-chain/build.go b/build/tx-chain/build.go index 1efd0054..d1435e88 100644 --- a/build/tx-chain/build.go +++ b/build/tx-chain/build.go @@ -203,6 +203,47 @@ func BuildOsmosisDockerImage(ctx context.Context, deps types.DepsFunc) error { }) } +// linuxMuslToolchain holds paths for a Linux muslc build (same toolchain for local and in-Docker). +type linuxMuslToolchain struct { + hostCCDirPath string + ccRelativePath string + wasmHostDirPath string + wasmCCLibRelativeLibPath string +} + +// linuxMuslToolchainFor returns the musl toolchain config for the given Linux platform. +// targetPlatform is used for all Path() lookups so local and in-Docker builds use the same toolchain. +func linuxMuslToolchainFor(targetPlatform txcrusttools.TargetPlatform) (linuxMuslToolchain, error) { + switch targetPlatform { + case txcrusttools.TargetPlatformLinuxAMD64InDocker, + txcrusttools.TargetPlatformLinuxARM64InDocker, + txcrusttools.TargetPlatformLinuxLocalArchInDocker: + // fall through to arch switch + default: + return linuxMuslToolchain{}, errors.Errorf("building is not possible for platform %s", targetPlatform) + } + + var gccBin, wasmLib, wasmSubdir string + switch targetPlatform.Arch { + case txcrusttools.ArchAMD64: + gccBin, wasmLib, wasmSubdir = "bin/x86_64-linux-musl-gcc", "lib/libwasmvm_muslc.x86_64.a", "/x86_64-linux-musl/lib/libwasmvm_muslc.x86_64.a" + case txcrusttools.ArchARM64: + gccBin, wasmLib, wasmSubdir = "bin/aarch64-linux-musl-gcc", "lib/libwasmvm_muslc.aarch64.a", "/aarch64-linux-musl/lib/libwasmvm_muslc.aarch64.a" + default: + return linuxMuslToolchain{}, errors.Errorf("building is not possible for platform %s", targetPlatform) + } + + hostCCDirPath := filepath.Dir(filepath.Dir(txcrusttools.Path(gccBin, targetPlatform))) + ccRelativePath := "/" + gccBin + wasmHostDirPath := txcrusttools.Path(wasmLib, targetPlatform) + return linuxMuslToolchain{ + hostCCDirPath: hostCCDirPath, + ccRelativePath: ccRelativePath, + wasmHostDirPath: wasmHostDirPath, + wasmCCLibRelativeLibPath: wasmSubdir, + }, nil +} + func buildTXdInDocker( ctx context.Context, deps types.DepsFunc, @@ -228,66 +269,28 @@ func buildTXdInDocker( } buildTags = append(buildTags, "muslc") ldFlags = append(ldFlags, "-extldflags '-static'") - var ( - hostCCDirPath string - ccRelativePath string - wasmHostDirPath string - wasmCCLibRelativeLibPath string - ) - // Use targetPlatform for all tool paths so local and in-Docker builds use the same toolchain. - switch targetPlatform { - case txcrusttools.TargetPlatformLinuxAMD64InDocker: - hostCCDirPath = filepath.Dir( - filepath.Dir(txcrusttools.Path("bin/x86_64-linux-musl-gcc", targetPlatform)), - ) - ccRelativePath = "/bin/x86_64-linux-musl-gcc" - wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.x86_64.a", targetPlatform) - wasmCCLibRelativeLibPath = "/x86_64-linux-musl/lib/libwasmvm_muslc.x86_64.a" - case txcrusttools.TargetPlatformLinuxARM64InDocker: - hostCCDirPath = filepath.Dir( - filepath.Dir(txcrusttools.Path("bin/aarch64-linux-musl-gcc", targetPlatform)), - ) - ccRelativePath = "/bin/aarch64-linux-musl-gcc" - wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.aarch64.a", targetPlatform) - wasmCCLibRelativeLibPath = "/aarch64-linux-musl/lib/libwasmvm_muslc.aarch64.a" - case txcrusttools.TargetPlatformLinuxLocalArchInDocker: - // Same toolchain as fixed arch above, chosen by runtime.GOARCH (CI can be amd64 or arm64). - if targetPlatform.Arch == txcrusttools.ArchAMD64 { - hostCCDirPath = filepath.Dir( - filepath.Dir(txcrusttools.Path("bin/x86_64-linux-musl-gcc", targetPlatform)), - ) - ccRelativePath = "/bin/x86_64-linux-musl-gcc" - wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.x86_64.a", targetPlatform) - wasmCCLibRelativeLibPath = "/x86_64-linux-musl/lib/libwasmvm_muslc.x86_64.a" - } else if targetPlatform.Arch == txcrusttools.ArchARM64 { - hostCCDirPath = filepath.Dir( - filepath.Dir(txcrusttools.Path("bin/aarch64-linux-musl-gcc", targetPlatform)), - ) - ccRelativePath = "/bin/aarch64-linux-musl-gcc" - wasmHostDirPath = txcrusttools.Path("lib/libwasmvm_muslc.aarch64.a", targetPlatform) - wasmCCLibRelativeLibPath = "/aarch64-linux-musl/lib/libwasmvm_muslc.aarch64.a" - } else { - return errors.Errorf("building is not possible for platform %s", targetPlatform) - } - default: - return errors.Errorf("building is not possible for platform %s", targetPlatform) + + tc, err := linuxMuslToolchainFor(targetPlatform) + if err != nil { + return err } - // Local Linux build: same muslc/static config as in-Docker, output to cache for Docker image. + if !release && runtime.GOOS == txcrusttools.OSLinux { + // Local Linux build: same muslc/static config as in-Docker, output to cache for Docker image. targetPlatform = txcrusttools.TargetPlatformLocal - if err := copyLocalBinary(wasmHostDirPath, hostCCDirPath+wasmCCLibRelativeLibPath); err != nil { + if err := copyLocalBinary(tc.wasmHostDirPath, tc.hostCCDirPath+tc.wasmCCLibRelativeLibPath); err != nil { return err } - cc = hostCCDirPath + ccRelativePath + cc = tc.hostCCDirPath + tc.ccRelativePath } else { const ccDockerDir = "/musl-gcc" dockerVolumes = append( dockerVolumes, - fmt.Sprintf("%s:%s", hostCCDirPath, ccDockerDir), + fmt.Sprintf("%s:%s", tc.hostCCDirPath, ccDockerDir), // put the libwasmvm to the lib folder of the compiler - fmt.Sprintf("%s:%s", wasmHostDirPath, fmt.Sprintf("%s%s", ccDockerDir, wasmCCLibRelativeLibPath)), + fmt.Sprintf("%s:%s%s", tc.wasmHostDirPath, ccDockerDir, tc.wasmCCLibRelativeLibPath), ) - cc = fmt.Sprintf("%s%s", ccDockerDir, ccRelativePath) + cc = ccDockerDir + tc.ccRelativePath } case txcrusttools.OSDarwin: buildTags = append(buildTags, "static_wasm") @@ -305,6 +308,7 @@ func buildTXdInDocker( default: return errors.Errorf("building is not possible for platform %s", targetPlatform) } + envs = append(envs, "CC="+cc) versionLDFlags, err := txdVersionLDFlags(ctx, buildTags) From db4fd626c5e88dc6f74e7528cbf962c346b397c6 Mon Sep 17 00:00:00 2001 From: TxCorpi0x <6095314+TxCorpi0x@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:24:25 +0300 Subject: [PATCH 3/4] Remove Unnecessary change in format --- build/tx-chain/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tx-chain/build.go b/build/tx-chain/build.go index d1435e88..ca69539a 100644 --- a/build/tx-chain/build.go +++ b/build/tx-chain/build.go @@ -290,7 +290,7 @@ func buildTXdInDocker( // put the libwasmvm to the lib folder of the compiler fmt.Sprintf("%s:%s%s", tc.wasmHostDirPath, ccDockerDir, tc.wasmCCLibRelativeLibPath), ) - cc = ccDockerDir + tc.ccRelativePath + cc = fmt.Sprintf("%s%s", ccDockerDir, tc.ccRelativePath) } case txcrusttools.OSDarwin: buildTags = append(buildTags, "static_wasm") From fa5da88fd7741516601399094a7f3c13a8bc637d Mon Sep 17 00:00:00 2001 From: TxCorpi0x <6095314+TxCorpi0x@users.noreply.github.com> Date: Fri, 20 Feb 2026 10:15:40 +0300 Subject: [PATCH 4/4] Replace arch check with os check --- build/tx-chain/build.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build/tx-chain/build.go b/build/tx-chain/build.go index ca69539a..65d8b786 100644 --- a/build/tx-chain/build.go +++ b/build/tx-chain/build.go @@ -214,24 +214,22 @@ type linuxMuslToolchain struct { // linuxMuslToolchainFor returns the musl toolchain config for the given Linux platform. // targetPlatform is used for all Path() lookups so local and in-Docker builds use the same toolchain. func linuxMuslToolchainFor(targetPlatform txcrusttools.TargetPlatform) (linuxMuslToolchain, error) { - switch targetPlatform { - case txcrusttools.TargetPlatformLinuxAMD64InDocker, - txcrusttools.TargetPlatformLinuxARM64InDocker, - txcrusttools.TargetPlatformLinuxLocalArchInDocker: - // fall through to arch switch - default: + if targetPlatform.OS != txcrusttools.OSLinux { return linuxMuslToolchain{}, errors.Errorf("building is not possible for platform %s", targetPlatform) } - var gccBin, wasmLib, wasmSubdir string + var arch string switch targetPlatform.Arch { case txcrusttools.ArchAMD64: - gccBin, wasmLib, wasmSubdir = "bin/x86_64-linux-musl-gcc", "lib/libwasmvm_muslc.x86_64.a", "/x86_64-linux-musl/lib/libwasmvm_muslc.x86_64.a" + arch = "x86_64" case txcrusttools.ArchARM64: - gccBin, wasmLib, wasmSubdir = "bin/aarch64-linux-musl-gcc", "lib/libwasmvm_muslc.aarch64.a", "/aarch64-linux-musl/lib/libwasmvm_muslc.aarch64.a" + arch = "aarch64" default: return linuxMuslToolchain{}, errors.Errorf("building is not possible for platform %s", targetPlatform) } + gccBin := fmt.Sprintf("bin/%s-linux-musl-gcc", arch) + wasmLib := fmt.Sprintf("lib/libwasmvm_muslc.%s.a", arch) + wasmSubdir := fmt.Sprintf("/%s-linux-musl/lib/libwasmvm_muslc.%s.a", arch, arch) hostCCDirPath := filepath.Dir(filepath.Dir(txcrusttools.Path(gccBin, targetPlatform))) ccRelativePath := "/" + gccBin