Repository navigation
rm c/bdwgc - #58
rm c/bdwgc#58xushiwei wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Review: rm c/bdwgc
This PR deletes the entire c/bdwgc package. The intent is clear, but the deletion is incomplete: an in-tree dependent still imports the removed package, which breaks the default build.
🔴 Blocker — dangling import breaks the default build
cpp/std/std_gc.go still imports and uses the deleted package:
cpp/std/std_gc.go:26—import "github.com/goplus/lib/c/bdwgc"cpp/std/std_gc.go:32—bdwgc.Malloc(unsafe.Sizeof(String{}))cpp/std/std_gc.go:33—bdwgc.RegisterFinalizer(...)
This file is the default build variant (//go:build !nogc); std_nogc.go only compiles under -tags nogc. So the standard build path is broken, not an edge case. Verified against the toolchain:
$ go vet ./cpp/std/
cpp/std/std_gc.go:26:2: no required module provides package github.com/goplus/lib/c/bdwgc
(go vet -tags nogc ./cpp/std/ passes, confirming only the default path is affected.)
This must be resolved in the same change — either don't delete c/bdwgc, or migrate allocString() in std_gc.go off the bdwgc API.
⚠️ When fixing: preserve finalizer semantics (don't just copy the nogc path)
std_gc.go and std_nogc.go have intentionally different allocString():
- GC path (
std_gc.go):bdwgc.Malloc+RegisterFinalizer(... Dispose())— the GC reclaims theStringwrapper and runsDispose()to free the underlyingstd::stringbuffer when the object becomes unreachable. nogcpath (std_nogc.go:30-33): plainc.Malloc, no finalizer, no free.
If std_gc.go is "fixed" by simply cloning the nogc body, the default build would silently lose automatic Dispose(), leaking the String struct and the std::string buffer on every NewString*/Str call (cpp/std/string.go). Whatever lands should keep finalizer-backed cleanup for the GC build, or give callers an explicit ownership/Dispose() contract.
📝 Minor notes
- Scope / consistency:
c/pthread/pthread_gc.gostill links bdw-gc (LLGoPackage = "link: $(pkg-config --libs bdw-gc); -lgc", line 29) and bindsC.GC_pthread_create/C.GC_pthread_join(lines 58, 79). It does not import the deleted Go package, so it's not broken — but if the goal is to drop bdw-gc entirely, this leaves a half-migration worth clarifying. If the goal is only to remove the typed Go binding while bdw-gc stays a runtime dependency, that's worth stating too. - Breaking change / rationale: The commit message is just
rm c/bdwgcwith no body. Removing an exported package path is a breaking change for downstream importers; a short rationale and a note on thecpp/stdimpact would help reviewers and consumers.
Recommendation: Resolve the cpp/std/std_gc.go import before merge and confirm go build ./... / go vet ./... pass in both default and -tags nogc configurations.
No description provided.