-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go test -compiler $pkg can mask std package with name $(basename $pkg) #6793
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
Labels
Comments
I can try. It's pretty confusing though. I'll paste the output of "go test -compiler gccgo -x mwhudson/testing" and explain what I think is going on at each step. I'm not trying to explain things to you, I'm trying to explain what _I_ think is going on so that you can correct me if I'm wrong :-) mwhudson@narsil:testing$ go test -compiler gccgo -x mwhudson/testing WORK=/tmp/go-build342732787 #### mkdir -p $WORK/mwhudson/testing/_test/mwhudson/ ### This is the main scratch directory for testing mwhudson/testing mkdir -p $WORK/mwhudson/testing/_test/ ### Where the source lives cd /home/mwhudson/goplay2/src/mwhudson/testing ### mwhudson/testing has both "internal test files" i.e. a file _test that says "package testing" and ### "external test files" that say package testing_test, so it is necessary to rebuild a version of the ### package for testing. *** The problem here is that the intermediate testing.o is created directly in the main scratch directory *** gccgo -I $WORK -c -g -m64 -fgo-pkgpath=mwhudson/testing -fgo-relative-import-path=_/home/mwhudson/goplay2/src/mwhudson/testing -o $WORK/mwhudson/testing/_test/testing.o ./t.go ./t2_test.go ### Make the version of libtesting.a for the compilation of testing.test to link against ar cru $WORK/mwhudson/testing/_test/mwhudson/libtesting.a $WORK/mwhudson/testing/_test/testing.o ### Compile the code that will make up testing.test. ### This is the command that fails. Because of the "-I $WORK/mwhudson/testing/_test" when trying to resolve ### the `import "testing"`, gccgo finds the testing.o file created above, and obviously this does not define ### all of (or indeed any of) the things that the standard testing package provides. gccgo -I $WORK/mwhudson/testing/_test -I $WORK -c -g -m64 -fgo-pkgpath=mwhudson/testing_test -fgo-relative-import-path=_/home/mwhudson/goplay2/src/mwhudson/testing -o $WORK/mwhudson/testing/_test/testing_test.o ./t_test.go # mwhudson/testing_test ./t_test.go:3:11: error: reference to undefined identifier ‘testing.T’ func f(t *stdtesting.T) {} I don't completely understand why gccgo looks for a .o file when looking for a package, but dumping intermediate objects directly into a directory that's passed as an -I option just feels risky. My fix at https://golang.org/cl/27650045/ puts the testing.o file in a sub-directory of the scratch directory: mkdir -p $WORK/mwhudson/testing/_test/_obj_test/ cd /home/mwhudson/goplay2/src/mwhudson/testing gccgo -I $WORK -c -g -m64 -fgo-pkgpath=mwhudson/testing -fgo-relative-import-path=_/home/mwhudson/goplay2/src/mwhudson/testing -o $WORK/mwhudson/testing/_test/_obj_test/testing.o ./t.go ./t2_test.go This is analogous to what "go build" does: mwhudson@narsil:testing$ go build -x -compiler gccgo mwhudson/testing ... gccgo -I $WORK -c -g -m64 -fgo-pkgpath=mwhudson/testing -fgo-relative-import-path=_/home/mwhudson/goplay2/src/mwhudson/testing -o $WORK/mwhudson/testing/_obj/testing.o ./t.go ... I hope this helps! |
This issue was closed by revision 7178c05. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: