From 082881daf84a0ce3aae847c64b483c04d471e088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mo=CC=88hrmann?= Date: Tue, 3 May 2016 11:10:26 +0200 Subject: [PATCH] misc/cgo/fortran: fix gfortran compile test Fixes #14544 Change-Id: I58b0b164ebbfeafe4ab32039a063df53e3018a6d Reviewed-on: https://go-review.googlesource.com/22730 Reviewed-by: Ian Lance Taylor Reviewed-by: Sean Lake --- misc/cgo/fortran/test.bash | 16 ++++++++++++++++ src/cmd/dist/test.go | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/misc/cgo/fortran/test.bash b/misc/cgo/fortran/test.bash index d397dcb682..3d1bc9de8e 100755 --- a/misc/cgo/fortran/test.bash +++ b/misc/cgo/fortran/test.bash @@ -9,12 +9,28 @@ set -e FC=$1 +goos=$(go env GOOS) + +libext="so" +if [ "$goos" == "darwin" ]; then + libext="dylib" +fi + +case "$FC" in +*gfortran*) + libpath=$(dirname $($FC -print-file-name=libgfortran.$libext)) + export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-rpath,$libpath -L $libpath" + ;; +esac + if ! $FC helloworld/helloworld.f90 -o main.exe >& /dev/null; then echo "skipping Fortran test: could not build helloworld.f90 with $FC" exit 0 fi rm -f main.exe +status=0 + if ! go test; then echo "FAIL: go test" status=1 diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 11c22f4fd3..92559c9d7e 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -445,7 +445,7 @@ func (t *tester) registerTests() { if fortran == "" { fortran, _ = exec.LookPath("gfortran") } - if t.hasBash() && fortran != "" && t.goos != "dragonfly" { // see golang.org/issue/14544 + if t.hasBash() && fortran != "" { t.tests = append(t.tests, distTest{ name: "cgo_fortran", heading: "../misc/cgo/fortran",