gorename
无法用于以下粘贴的程序。该程序导入了一个在cgo模式下构建的包。
原因是gorename处理cgo文件的方式。它使用co预处理器处理它们。下面的示例导致运行以下命令(需要24秒):go tool cgo -objdir /var/folders/km/50gy6_q557v6_7vxbf9b29v00000gn/T/github.com_veandco_go-sdl2_sdl_C598351148 -- -D_THREAD_SAFE -I/opt/local/include/SDL2 -I /var/folders/km/50gy6_q557v6_7vxbf9b29v00000gn/T/github.com_veandco_go-sdl2_sdl_C598351148 audio.go blendmode.go clipboard.go cpuinfo.go endian.go error.go events.go filesystem.go gamecontroller.go gesture.go haptic.go hints.go joystick.go keyboard.go keycode.go loadso.go log.go mouse.go mutex.go pixels.go power.go rect.go render.go rwops.go scancode.go sdl.go sdl_cgo.go surface.go sysrender.go syswm.go timer.go touch.go version.go video.go
它从x/tools/go/loader/loader.go的parsePackageFiles中被调用。我认为这是go/loader
的问题。
@alandonovan,有没有办法解决这个问题?我很乐意解决它。
% cat main.go
package main
import (
"github.com/veandco/go-sdl2/sdl"
)
const w = 800
const h = 600
func main() {
println(sdl.INIT_VIDEO)
}
% gtime gorename -v -offset=main.go:#66 -to A
gorename: Loading package: gorenameclib
gorename: Updating package gorenameclib
24.36user 4.18system 0:25.95elapsed 110%CPU (0avgtext+0avgdata 310689792maxresident)k
0inputs+55outputs (1major+1165748minor)pagefaults 0swaps
% go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/thorn/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/thorn/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/thorn/golang"
GOTMPDIR=""
GOTOOLDIR="/Users/thorn/golang/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/km/50gy6_q557v6_7vxbf9b29v00000gn/T/go-build052892133=/tmp/go-build -gno-record-gcc-switches -fno-common"
1条答案
按热度按时间m0rkklqb1#
有趣的是,它发生在上面提到的特定 Package 中。我与其他CGO包一起工作,它运行得非常快。