Skip to content

Commit

Permalink
cli: disable race detector if GOFLAGS contains -buildmode=pie
Browse files Browse the repository at this point in the history
This should allow to build the package on AlpineLinux. Also document the constraint of having to install the source under $GOPATH/src/github.com/traefik/yaegi until Go modules are supported.

Fixes #1523.
  • Loading branch information
mvertes committed Mar 16, 2023
1 parent 9d65860 commit f202764
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -177,6 +177,8 @@ Beside the known [bugs] which are supposed to be fixed in the short term, there
- Representation of types by `reflect` and printing values using %T may give different results between compiled mode and interpreted mode.
- Interpreting computation intensive code is likely to remain significantly slower than in compiled mode.

Go modules are not supported yet. Until that, it is necessary to install the source into `$GOPATH/src/github.com/traefik/yaegi` to pass all the tests.

## Contributing

[Contributing guide](CONTRIBUTING.md).
Expand Down
6 changes: 6 additions & 0 deletions cmd/yaegi/yaegi_test.go
Expand Up @@ -125,6 +125,12 @@ func TestYaegiCmdCancel(t *testing.T) {
}

func raceDetectorSupported(goos, goarch string) bool {
if strings.Contains(os.Getenv("GOFLAGS"), "-buildmode=pie") {
// The Go race detector is not compatible with position independent code (pie).
// We read the conventional GOFLAGS env variable used for example on AlpineLinux
// to build packages, as there is no way to get this information from the runtime.
return false
}
switch goos {
case "linux":
return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64"
Expand Down

0 comments on commit f202764

Please sign in to comment.