1
0
mirror of https://github.com/golang/go synced 2024-11-11 21:10:21 -07:00

cmd/compile, misc/cgo: fix fortran tests on aix/ppc64

Enable pattern lib.a/shared.so.X in cgo_import_dynamic as on AIX,
archive files (.a) often have shared objects (.so) inside them.

Change-Id: I21096c75eb7fbcc7064b0b832bfa8ed862142051
Reviewed-on: https://go-review.googlesource.com/c/go/+/168877
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Clément Chigot 2019-03-22 12:48:31 +01:00 committed by Ian Lance Taylor
parent 83d90bbc82
commit 08692bed1e
2 changed files with 8 additions and 2 deletions

View File

@ -14,12 +14,17 @@ goos=$(go env GOOS)
libext="so"
if [ "$goos" = "darwin" ]; then
libext="dylib"
elif [ "$goos" = "aix" ]; then
libtext="a"
fi
case "$FC" in
*gfortran*)
libpath=$(dirname $($FC -print-file-name=libgfortran.$libext))
export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-rpath,$libpath -L $libpath"
if [ "$goos" != "aix" ]; then
RPATH_FLAG="-Wl,-rpath,$libpath"
fi
export CGO_LDFLAGS="$CGO_LDFLAGS $RPATH_FLAG -L $libpath"
;;
esac

View File

@ -116,8 +116,9 @@ func (p *noder) pragcgo(pos syntax.Pos, text string) {
f[3] = strings.Trim(f[3], `"`)
if objabi.GOOS == "aix" && f[3] != "" {
// On Aix, library pattern must be "lib.a/object.o"
// or "lib.a/libname.so.X"
n := strings.Split(f[3], "/")
if len(n) != 2 || !strings.HasSuffix(n[0], ".a") || !strings.HasSuffix(n[1], ".o") {
if len(n) != 2 || !strings.HasSuffix(n[0], ".a") || (!strings.HasSuffix(n[1], ".o") && !strings.Contains(n[1], ".so.")) {
p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_dynamic local [remote ["lib.a/object.o"]]`})
return
}