]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, misc/cgo: fix fortran tests on aix/ppc64
authorClément Chigot <clement.chigot@atos.net>
Fri, 22 Mar 2019 11:48:31 +0000 (12:48 +0100)
committerIan Lance Taylor <iant@golang.org>
Fri, 22 Mar 2019 13:52:59 +0000 (13:52 +0000)
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>
misc/cgo/fortran/test.bash
src/cmd/compile/internal/gc/lex.go

index 1e0d59ea1c6a9f88bc3d59f3769e6ef8002164b6..9498da0208f87807d0505ba226926b22b682303a 100755 (executable)
@@ -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
 
index bd68ebffff0a25a7464c71af962463e4ba9c92a8..557f98604d2fce44c659f1093aeaa38164e37f30 100644 (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
                                }