Skip to content

Commit 16ffd28

Browse files
authored
Fvm removed from libfilcrypto, saves 24mb binary size (#768)
* fvm optional, saves 24mb binary size * fvm for tests * review changes * cgo-bindings gcc12 * lint * merge * fix filecoin-ffi * gen * mod tidy fix * lint/gen * go mod
1 parent cb92510 commit 16ffd28

16 files changed

Lines changed: 69 additions & 56 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- '**'
1010

1111
env:
12-
GO_VERSION: 1.24
12+
GO_VERSION: "1.24.7"
1313

1414
jobs:
1515
ci-lint:
@@ -195,6 +195,7 @@ jobs:
195195
- name: Install FFI
196196
env:
197197
GITHUB_TOKEN: ${{ github.token }}
198+
CURIO_OPTIMAL_LIBFILCRYPTO: 0
198199
run: |
199200
make deps
200201
shell: bash
@@ -230,7 +231,7 @@ jobs:
230231
echo "Using YugabyteDB Container IP: ${{env.CURIO_HARMONYDB_HOSTS}}"
231232
export CURIO_HARMONYDB_HOSTS=${{ env.CURIO_HARMONYDB_HOSTS }}
232233
export LOTUS_HARMONYDB_HOSTS=${{ env.CURIO_HARMONYDB_HOSTS }}
233-
go test -v --tags=debug -timeout 30m ${{ matrix.test-suite.target }}
234+
go test -v --tags="debug,fvm" -timeout 30m ${{ matrix.test-suite.target }}
234235
235236
- name: Stop YugabyteDB container
236237
if: always() # Ensure this runs even if the tests fail

GO_VERSION_MIN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.24
1+
1.24.7

Makefile

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,31 @@ FFI_DEPS:=$(addprefix $(FFI_PATH),$(FFI_DEPS))
1010

1111
$(FFI_DEPS): build/.filecoin-install ;
1212

13+
# When enabled, build size-optimized libfilcrypto by default
14+
CURIO_OPTIMAL_LIBFILCRYPTO ?= 1
15+
1316
build/.filecoin-install: $(FFI_PATH)
14-
$(MAKE) -C $(FFI_PATH) $(FFI_DEPS:$(FFI_PATH)%=%)
17+
@if [ "$(CURIO_OPTIMAL_LIBFILCRYPTO)" = "1" ]; then \
18+
FFI_DISABLE_FVM=1 $(MAKE) curio-libfilecoin; \
19+
else \
20+
$(MAKE) -C $(FFI_PATH) $(FFI_DEPS:$(FFI_PATH)%=%); \
21+
fi
1522
@touch $@
1623

1724
MODULES+=$(FFI_PATH)
1825
BUILD_DEPS+=build/.filecoin-install
1926
CLEAN+=build/.filecoin-install
2027

28+
## Custom libfilcrypto build for Curio (size-optimized, no FVM)
29+
.PHONY: curio-libfilecoin
30+
curio-libfilecoin:
31+
FFI_BUILD_FROM_SOURCE=1 \
32+
FFI_USE_GPU=1 \
33+
FFI_USE_MULTICORE_SDR=1 \
34+
RUSTFLAGS='-C codegen-units=1 -C opt-level=3 -C strip=symbols' \
35+
$(MAKE) -C $(FFI_PATH) clean .install-filcrypto
36+
@echo "Rebuilt libfilcrypto for Curio (OpenCL+multicore, no default features)."
37+
2138
ffi-version-check:
2239
@[[ "$$(awk '/const Version/{print $$5}' extern/filecoin-ffi/version.go)" -eq 3 ]] || (echo "FFI version mismatch, update submodules"; exit 1)
2340
BUILD_DEPS+=ffi-version-check
@@ -82,6 +99,17 @@ CLEAN+=build/.update-modules
8299
deps: $(BUILD_DEPS)
83100
.PHONY: deps
84101

102+
## Test targets
103+
104+
test-deps: CURIO_OPTIMAL_LIBFILCRYPTO=0
105+
test-deps: $(BUILD_DEPS)
106+
@echo "Built dependencies with FVM support for testing"
107+
.PHONY: test-deps
108+
109+
test: test-deps
110+
go test -v -tags="cgo,fvm" -timeout 30m ./itests/...
111+
.PHONY: test
112+
85113
## ldflags -s -w strips binary
86114

87115
CURIO_TAGS ?= cunative
@@ -273,10 +301,24 @@ marketgen:
273301
swag init -dir market/mk20/http -g http.go -o market/mk20/http --parseDependencyLevel 3 --parseDependency
274302
.PHONY: marketgen
275303

276-
gensimple: api-gen go-generate cfgdoc-gen docsgen marketgen docsgen-cli
304+
# Run gen steps sequentially in a single shell to avoid Go build cache race conditions.
305+
# The "unlinkat: directory not empty" error occurs when multiple go processes
306+
# contend for the same build cache simultaneously.
307+
# Set GOCACHE_CLEAN=1 to clear the build cache before running (fixes persistent issues).
308+
gensimple:
309+
ifeq ($(GOCACHE_CLEAN),1)
310+
$(GOCC) clean -cache
311+
endif
312+
$(MAKE) deps
313+
$(MAKE) api-gen
314+
$(MAKE) go-generate
315+
$(MAKE) cfgdoc-gen
316+
$(MAKE) docsgen
317+
$(MAKE) marketgen
318+
$(MAKE) docsgen-cli
277319
$(GOCC) run ./scripts/fiximports
278320
go mod tidy
279-
.PHONY: gen
321+
.PHONY: gensimple
280322

281323
fiximports:
282324
$(GOCC) run ./scripts/fiximports

api/api_chain_all.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !forest
2-
// +build !forest
32

43
package api
54

api/api_chain_limited.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build forest
2-
// +build forest
32

43
package api
54

build/params_2k.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build 2k
2-
// +build 2k
32

43
package build
54

build/params_calibnet.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build calibnet
2-
// +build calibnet
32

43
package build
54

build/params_mainnet.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !calibnet && !debug && !2k
2-
// +build !calibnet,!debug,!2k
32

43
package build
54

build/params_testnet.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build debug
2-
// +build debug
32

43
package build
54

cmd/curio/ffi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package main
22

33
import (
4+
"context"
45
"fmt"
56
"os"
67

78
"github.com/ipfs/go-cid"
89
"github.com/snadrus/must"
910
"github.com/urfave/cli/v2"
10-
"golang.org/x/net/context"
1111

1212
"github.com/filecoin-project/go-jsonrpc"
1313

0 commit comments

Comments
 (0)