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: unable to build test that depends on package with -1.0 in the name #22986

Closed
Zariel opened this issue Dec 4, 2017 · 5 comments
Closed

Comments

@Zariel
Copy link

Zariel commented Dec 4, 2017

Please answer these questions before submitting your issue. Thanks!

What did you do?

This package fails to compile on tip but works on 1.9.3 https://github.com/jaegertracing/jaeger/tree/master/cmd/agent/app/httpserver where the troublsome folder is thrift-0.9.2 and reduces down to the following I think.

test/a_test.go:

package test

import p "test/p-1.0"
import "testing"

func TestGlobal(t *testing.T) {
	if !p.Global {
		t.Fatal("global false")
	}
}

test/p-1.0/m.go:

package p

var Global = true

func init() {
}

go test -v

This also replicates with go run

What did you expect to see?

=== RUN   TestGlobal
--- PASS: TestGlobal (0.00s)
PASS
ok  	test	0.007s

What did you see instead?

# test (testmain)
test/p-1%!e(MISSING)0.init: call to external function
test.TestGlobal: relocation target test/p-1%2e0.Global not defined
test.init: relocation target test/p-1%2e0.init not defined
test.TestGlobal: undefined: "test/p-1%2e0.Global"
test.init: undefined: "test/p-1%2e0.init"
FAIL	test [build failed]

Does this issue reproduce with the latest release (go1.9.2)?

No

System details

go version devel +1b9f66330b Mon Dec 4 05:15:50 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/chris/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/chris/dev/gotmp"
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/tq/6k_qff2j0q5fs4h4_wjd_d1h0000gn/T/go-build120472160=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel +1b9f66330b Mon Dec 4 05:15:50 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +1b9f66330b Mon Dec 4 05:15:50 2017 +0000
uname -v: Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29
lldb --version: lldb-900.0.50.1
  Swift-4.0
@ianlancetaylor ianlancetaylor changed the title go/test: unable to execute package which depends on package with -1.0 in the name cmd/go: unable to build test that depends on package with -1.0 in the name Dec 5, 2017
@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Dec 5, 2017
@gopherbot
Copy link

Change https://golang.org/cl/81878 mentions this issue: cmd/link: with -importcfg don't strip trailing ".a"

@odeke-em
Copy link
Member

@Zariel am currently running on tip but I can't directly reproduce it by your repro, please take a look at this sample repro

#!/bin/sh
mkdir -p 22986 && cd 22986 || exit "Failed to create 22986"
mkdir -p test/p-1.0 && echo "package foo\ntype Sample int" > test/p-1.0/foo.go
echo 'package test\n\nimport (\n"testing"\ntest "./test/p-1.0"\n)\nfunc TestFoo(t *testing.T) {\n_ = test.Sample(10)\n}' > m_test.go && go test -v
cd ../ && rm -rf 22986

which gives me

=== RUN   TestFoo
--- PASS: TestFoo (0.00s)
PASS
ok  	_/Users/emmanuelodeke/Desktop/openSrc/bugs/golang/22986	0.008s

@ianlancetaylor
Copy link
Contributor

@odeke-em I was able to recreate it--see the CL above for a test case.

@odeke-em
Copy link
Member

Cool, thanks @ianlancetaylor!

@Zariel
Copy link
Author

Zariel commented Dec 12, 2017

@ianlancetaylor thanks!

@golang golang locked and limited conversation to collaborators Dec 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants