Skip to content

FIX: Build fails with Go 1.24.0 due to sonic library incompatibility #4837

@ahwlsqja

Description

@ahwlsqja

⎿  ## Build fails with Go 1.24.0 despite v29.6.1 sonic fixes

 ### Problem

 Freshly scaffolded chains fail to build with Go 1.24.0 in Ignite CLI v29.6.1, even after the sonic-related fixes in commits [1878d46](https://github.com/ignite/cli/commit/1878d462a572ea615cccf425944dd67fafb92996) and [831ce3d](https://github.com/ignite/cli/commit/831ce3df29fc14b0b152d9644ef18ff19a43a301).

 **Error:**
 ```
 link: github.com/bytedance/sonic/loader: invalid reference to runtime.lastmoduledatap
 ```

 This is a **critical blocker** - every new Ignite CLI v29.6.1 user with Go 1.24.0 (the required version) cannot build their scaffolded chain out-of-the-box.

 ### How to Reproduce

 ```bash
 # 1. Install Go 1.24.0 (required by Ignite CLI)
 # 2. Install Ignite CLI v29.6.1
 cd /tmp && git clone https://github.com/ignite/cli.git
 cd cli && git checkout v29.6.1
 make install

 # 3. Scaffold a new chain
 ignite scaffold chain test-chain
 cd test-chain

 # 4. Try to build
 go build -mod=readonly -o ./build/test-chaind ./cmd/test-chaind
 ```

 **Result:** Build fails with the sonic/loader error above.

 ### Root Cause

 I investigated the v29.6.1 commit history and found that:

 **August 14 (Commit 1878d46):** Added `replace github.com/bytedance/sonic => v1.14.0` for Go 1.25 support

 **August 19 (Commit 831ce3d):** Bumped cosmossdk.io/log to v1.6.1 and **removed** the sonic replace directive

 The team expected cosmossdk.io/log v1.6.1 to resolve the sonic issue, but it didn't. Here's why:

 ```bash
 $ go mod graph | grep "cosmossdk.io/log@v1.6.1" | grep sonic
 cosmossdk.io/log@v1.6.1 github.com/bytedance/sonic@v1.14.0
 cosmossdk.io/log@v1.6.1 github.com/bytedance/sonic/loader@v0.3.0
 ```

 **cosmossdk.io/log v1.6.1 still depends on:**
 - sonic v1.14.0 ❌ (doesn't support Go 1.24.0)
 - sonic/loader v0.3.0 ❌ (doesn't support Go 1.24.0)

 **Versions that work with Go 1.24.0:**
 - sonic v1.14.2 
 - sonic/loader v0.4.0 

 According to [bytedance/sonic's README](https://github.com/bytedance/sonic):
 > "Go1.24.0 is not supported due to [golang/go#71672](https://github.com/golang/go/issues/71672), please use higher go version or add build tag `--ldflags="-checklinkname=0"`"

 ### Proposed Solutions

 #### Option 1: Re-add sonic replace with updated versions (Recommended)

 In `ignite/templates/app/files/go.mod.plush`, add:

 ```go
 replace (
     // Force sonic versions that support Go 1.24.0 and 1.25.0
     github.com/bytedance/sonic => github.com/bytedance/sonic v1.14.2
     github.com/bytedance/sonic/loader => github.com/bytedance/sonic/loader v0.4.0
 )
 ```

 **I've tested and verified this works** with Go 1.24.0 - chains build and run successfully.

 #### Option 2: Add linker flag to Makefile template

 Add `-checklinkname=0` to generated Makefiles (this is sonic's official workaround):

 ```makefile
 LD_FLAGS = -checklinkname=0
 BUILD_FLAGS = -mod=readonly -ldflags='$(LD_FLAGS)'
 ```

 #### Option 3: Wait for upstream fix

 Report to cosmossdk.io/log maintainers to update their sonic dependency. However, this is outside Ignite's control and may take time.

 ### Workaround for Users

 Until this is fixed, users can manually add to their project's `go.mod`:

 ```go
 replace (
     github.com/bytedance/sonic => github.com/bytedance/sonic v1.14.2
     github.com/bytedance/sonic/loader => github.com/bytedance/sonic/loader v0.4.0
 )
 ```

 Then:
 ```bash
 go mod tidy
 go build -o ./build/chaind ./cmd/chaind
 ```

 Or build with the linker flag:
 ```bash
 go build -ldflags="-checklinkname=0" -o ./build/chaind ./cmd/chaind
 ```

 ### Impact

 This affects **100% of new users** trying to use Ignite CLI v29.6.1 with Go 1.24.0 (the required version). It creates a poor first impression: "I just installed Ignite CLI and it doesn't work."

 Fixing this will:
 - Enable all Ignite CLI users to build with Go 1.24.0
 - Improve onboarding for new Cosmos developers
 - Align scaffolded projects with Ignite's Go 1.24.0 requirement
 - Reduce support burden from confused users

 ### Environment

 ```
 Ignite CLI version:      v29.6.1
 Ignite CLI build date:   2025-10-15T12:20:54Z
 Ignite CLI source hash:  d17ee311b5e7bd9e95e607cf7395a40b43b4361c
 Cosmos SDK version:      v0.53.4
 Go version:              go1.24.0 linux/amd64
 OS:                      Linux (WSL2), also reproducible on macOS
 cosmossdk.io/log:        v1.6.1 (latest available)
 ```

 ### Testing Evidence

 I successfully built and ran a chain using Option 1 (the replace directive):

 ```bash
 $ go build -o ./build/studyd ./cmd/studyd
 # Build succeeds 

 $ ./build/studyd version
 # Works perfectly 

 $ ./build/studyd start
 # Chain starts and produces blocks 
 ```

 ---

 **I'm happy to submit a PR with the fix if you'd like!** I can implement Option 1 or Option 2, whichever you prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions