Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: access $WORK directory from toolexec #45864

Open
dzonerzy opened this issue Apr 30, 2021 · 7 comments
Open

cmd/go: access $WORK directory from toolexec #45864

dzonerzy opened this issue Apr 30, 2021 · 7 comments

Comments

@dzonerzy
Copy link

@dzonerzy dzonerzy commented Apr 30, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.2 windows/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=386
set GOBIN=
set GOCACHE=C:\Users\DZONERZY\AppData\Local\go-build
set GOENV=C:\Users\DZONERZY\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\DZONERZY\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\DZONERZY\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.2
set GCCGO=gccgo
set GO386=sse2
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\Users\DZONERZY\go\src\github.com\dzonerzy\guzzer\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m32 -fmessage-length=0 -fdebug-prefix-map=C:\Users\DZONERZY\AppData\Local\Temp\go-build4099943664=/tmp/go-build -gno-record-gcc-switches

What did you do?

I'm trying to access $WORK variable via the -toolexec command , in order to modify the content of -importcfg before the compilation of a package

What did you expect to see?

A way to modify -importcfg content before compilation

What did you see instead?

There's not way to access the working directory via -toolexec

@ianlancetaylor ianlancetaylor changed the title Access $WORK directory from toolexec cmd/go: access $WORK directory from toolexec Apr 30, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 30, 2021

@bcmills
Copy link
Member

@bcmills bcmills commented Apr 30, 2021

@mvdan
Copy link
Member

@mvdan mvdan commented Apr 30, 2021

This is possible today, without directly knowing $WORK. You just look at the compiler flags when it runs, and swap or modify the importcfg file.

https://github.com/burrowers/garble/blob/d34406d83279978529dd732ad59e07e867f68c95/main.go#L859-L866

https://github.com/burrowers/garble/blob/d34406d83279978529dd732ad59e07e867f68c95/main.go#L1413

I'm not opposed to exposing $WORK, but I don't think it's necessary for what you want here.

@dzonerzy
Copy link
Author

@dzonerzy dzonerzy commented Apr 30, 2021

Actually i need to read the content of the "old" importcfg file and add there some new packagefile directive, so i need to access the old file not only swap it

@mvdan
Copy link
Member

@mvdan mvdan commented Apr 30, 2021

Right. The code I shared shows a working example of reading the existing file and replacing it with a new one.

@dzonerzy
Copy link
Author

@dzonerzy dzonerzy commented Apr 30, 2021

Imo another option is to allow multiple -importcfg switch and just merge them at compile time

@mvdan
Copy link
Member

@mvdan mvdan commented Apr 30, 2021

I guess that's possible, but I don't see it as necessary. I also don't understand how it's related to your original request for $WORK. You can certainly read, modify, and replace -importcfg currently, so I'd suggest that you try that before suggesting changes to the toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants