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

misc/cgo/fortran, cmd/dist: Fortran Support Causing go/src/all.bash to Fail #14544

Closed
odysseus9672 opened this issue Feb 27, 2016 · 40 comments
Closed
Milestone

Comments

@odysseus9672
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version
    go version devel +7da4ced Sat Feb 27 21:12:19 2016 +0000 darwin/amd64
  2. What operating system and processor architecture are you using (go env)?
    go env
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH=""
    GORACE=""
    GOROOT="/Users/sean/goLang/go"
    GOTOOLDIR="/Users/sean/goLang/go/pkg/tool/darwin_amd64"
    CC="clang"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
    CXX="clang++"
    CGO_ENABLED="1"
  3. What did you do?
    (Use play.golang.org to provide a runnable example, if possible.)
    Run $GOROOT/src/all.bash
  4. What did you expect to see?
    A successful build and run of the test suite.
  5. What did you see instead?
##### ../misc/cgo/fortran
# _/Users/sean/goLang/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/sean/goLang/go/misc/cgo/fortran [build failed]
FAIL: go test
2016/02/27 14:47:14 Failed: exit status 1

The root of the problem is that the gfortran I use is supplied by the Fink software distribution (gcc5 package). Because of that, I need to find a way to get this into the LDFLAGS for the build process: -L/sw/lib/gcc5/lib

I've tried setting the environment variable before running all.bash, and that doesn't help. Ideally, there should three options that can be passed in to the build process to address this issue:

1: an explicit path to the fortran compiler to use,
2: the linker flag for things that need the standard fortran libs, and
3: a flag to disable the fortran feature if it isn't desired.

Maybe a set of environment variables (eg. GoFortran, GoFortranLibDir), where the fortran feature only kicks in if the first is set to the path of the fortran compiler and the second is a (list of?) directories to include in the linker's search space for fortran related builds.

@mikioh mikioh changed the title Fortran Support Causing go/src/all.bash to Fail misc/cgo/fortran, cmd/dist: Fortran Support Causing go/src/all.bash to Fail Feb 28, 2016
@mikioh mikioh added this to the Go1.7 milestone Feb 28, 2016
@mikioh
Copy link
Contributor

mikioh commented Feb 28, 2016

This occurs on the dragonfly buildbot too.

##### ../misc/cgo/fortran
# _/tmp/gobuilder/dragonfly-amd64-922ce58de018/go/misc/cgo/fortran
/usr/libexec/binutils225/elf/ld.gold: error: cannot find -lgfortran
FAIL    _/tmp/gobuilder/dragonfly-amd64-922ce58de018/go/misc/cgo/fortran [build failed]
FAIL: go test
2016/02/27 14:46:23 Failed: exit status 1

See http://build.golang.org/log/c10562643cfb4e429ca1f269dc0823bc76e830cf.

/cc @kortschak

@kortschak
Copy link
Contributor

This is curious - if it's not building it should not run the test.

@odysseus9672 @mikioh before you do the operations below, there is an omission to my last CL that might help figure this out. Is there a main.exe in misc/cgo/fortran? If there is, what does it do when run?

Then, can you tell me the outcome of running the test.bash in misc/cgo/fortran with $FC (the name of your fortran compiler) as a parameter? Also for $FC helloworld/helloworld.f90 -o main.exe >& /dev/null; echo $? (then without the dev null redirect).

@odysseus9672
Copy link
Author

Negative. This is the contents of misc/cgo/fortran/ .

ls -lh
total 32
-rw-r--r--  1 sean  staff   295B Feb 24 13:13 answer.f90
-rw-r--r--  1 sean  staff   264B Feb 24 13:13 fortran.go
-rw-r--r--  1 sean  staff   334B Feb 24 13:13 fortran_test.go
drwxr-xr-x  3 sean  staff   102B Feb 26 16:44 helloworld
-rwxr-xr-x  1 sean  staff   495B Feb 28 01:15 test.bash

Here are the results of the experiments you wanted run:

Sean-iBook4:fortran sean$ ./test.bash /sw/bin/gfortran
# _/Users/sean/goLang/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/sean/goLang/go/misc/cgo/fortran [build failed]
FAIL: go test
Sean-iBook4:fortran sean$ $FC helloworld/helloworld.f90 -o main.exe >& /dev/null; echo $
$
Sean-iBook4:fortran sean$ $FC helloworld/helloworld.f90 -o main.exe
Sean-iBook4:fortran sean$ ./main.exe 
 Hello World!
Sean-iBook4:fortran sean$ echo $FC
/sw/bin/gfortran

I wonder if this is because some environment variables aren't correctly being set in the test.bash file?

@kortschak
Copy link
Contributor

Not "echo $��, "echo $?��, and do this after both invocations of $FC - use the value you get from the following for $FC.

Can you echo $FC after it's set in the in misc/cgo/fortran/test.bash, and change "set -e" to "set -ex" and run all.bash paste the stanza regarding the fortran test here.

@odysseus9672
Copy link
Author

I'll run your tests as soon as I describe the tests I've tried.

I've set out testing things in test.bash, and I can only suppose that there is something hinky with the version of bash used on Mac OS X and Dragonfly. I tried adding the LDFLAGS to the test.bash script explicitly, and even sourcing Fink's init script, and the result is the same. Stranger still, the output of adding the verbose flag to the test script and running a verbose build outside of the script has virtually the same output.

$FC helloworld/helloworld.f90 -o main.exe >& /dev/null; echo $?
0
##### ../misc/cgo/fortran
+ FC=/sw/bin/gfortran
+ echo /sw/bin/gfortran
/sw/bin/gfortran
+ /sw/bin/gfortran helloworld/helloworld.f90 -o main.exe
+ rm -f main.exe
+ go test
# _/Users/sean/goLang/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/sean/goLang/go/misc/cgo/fortran [build failed]
+ echo 'FAIL: go test'
FAIL: go test
+ status=1
+ exit 1

@kortschak
Copy link
Contributor

kortschak commented Feb 28, 2016 via email

@odysseus9672
Copy link
Author

Modifying fortran.go to read as follows works:

// Copyright 2016 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package fortran

// #cgo LDFLAGS: -L/sw/lib/gcc5/lib
// int the_answer();
import "C"

func TheAnswer() int {
    return int(C.the_answer())
}

Of course, making that change is not a general solution, but there should be some way to get the appropriate information setup.

@odysseus9672
Copy link
Author

The output you asked for: main.exe exists and runs correctly.

output from all.bash:

##### ../misc/cgo/fortran
+ FC=/sw/bin/gfortran
+ echo /sw/bin/gfortran
/sw/bin/gfortran
+ /sw/bin/gfortran helloworld/helloworld.f90 -o main.exe
+ go test
# _/Users/sean/goLang/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/sean/goLang/go/misc/cgo/fortran [build failed]
+ echo 'FAIL: go test'
FAIL: go test
+ status=1
+ exit 1
2016/02/28 02:26:31 Failed: exit status 1

@odysseus9672
Copy link
Author

Setting the environment variable CGO_LDFLAGS, as described here:

https://golang.org/cmd/cgo/

also makes all.bash run correctly. So, I imagine that Fortran will need a CGO_FORTRANFLAGS, and CGO_LDFLAGS will suffice.

@kortschak
Copy link
Contributor

kortschak commented Feb 28, 2016 via email

@odysseus9672
Copy link
Author

I might have some environment variables set that help it. I can't identify which one, though, because none of them point to /sw/lib in a way that gfortran should understand.

Edit: also, I'm up to the minute on the devel branch.
go version
go version devel +5fc4dec Sun Feb 28 10:36:01 2016 +0000 darwin/amd64

printenv
MANPATH=/sw/share/man:/usr/local/share/man:/usr/share/man:/opt/X11/share/man:/Library/TeX/texbin/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man:/sw/lib/perl5/5.18.2/man
TERM_PROGRAM=Apple_Terminal
XDG_DATA_HOME=/Users/sean/.local/share
GNUPLOT_DEFAULT_GDFONT=Arial
SHELL=/bin/bash
TERM=xterm-256color
HGENCODING=UTF-8
TMPDIR=/var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/T/
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.dz7wyAWdKm/Render
TERM_PROGRAM_VERSION=343.7
TERM_SESSION_ID=D928C99E-652F-495C-BD11-B3E10E6B16BF
ac_cv_path_INTLTOOL_PERL=/usr/bin/perl
XAPPLRESDIR=/sw/etc/app-defaults/
GOROOT_BOOTSTRAP=/Users/sean/golang/go1.4.3
SGML_CATALOG_FILES=/sw/etc/sgml/catalog
USER=sean
GDK_USE_XFT=1
GDFONTPATH=/Library/Fonts
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.aRfIhVGsJj/Listeners
__CF_USER_TEXT_ENCODING=0x1F9:0x0:0x0
GNOME_DISABLE_CRASH_DIALOG=1
XDG_CONFIG_DIRS=/sw/etc/xdg
PATH=/Users/sean/mybin:/sw/bin:/sw/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/Users/sean/goLang/go/bin
HG=/sw/bin/hg
XML_CATALOG_FILES=/sw/etc/xml/catalog
PWD=/Users/sean
LANG=en_US.UTF-8
XPC_FLAGS=0x0
GOMAXPROCS=4
XPC_SERVICE_NAME=0
IRCNICK=BlackGriffin
SHLVL=1
HOME=/Users/sean
bc03=/Users/sean/AstroTools/bc03/src
GOROOT=/Users/sean/goLang/go
XDG_CONFIG_HOME=/Users/sean/.config
XDG_CACHE_HOME=/Users/sean/.cache
PYTHONPATH=/Users/sean/lib
LOGNAME=sean
XDG_DATA_DIRS=/sw/share
DBUS_SESSION_BUS_ADDRESS=launchd:env=DBUS_FINK_SESSION_BUS_SOCKET
INFOPATH=/sw/share/info:/sw/info:/usr/share/info
XDG_RUNTIME_DIR=/var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/C/
DISPLAY=/private/tmp/com.apple.launchd.5ZSuFRU7vW/org.macosforge.xquartz:0
LADSPA_PATH=/sw/lib/ladspa
SECURITYSESSIONID=186a5
_=/usr/bin/printenv

@kortschak
Copy link
Contributor

@odysseus9672 would you please try

cd $GOROOT/src
git fetch https://go.googlesource.com/go refs/changes/74/19874/2
git checkout FETCH_HEAD
./all.bash

@odysseus9672
Copy link
Author

The exit status changed, but nothing else I can see.

##### ../misc/cgo/fortran
# _/Users/sean/goLang/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/sean/goLang/go/misc/cgo/fortran [build failed]
2016/02/28 15:41:58 Failed: exit status 2

@kortschak
Copy link
Contributor

I'm at a stage where I don't think I can take this further without access to a failing system to play with (I'm on linux here). Clearly the issue is that invoking gfortran minimally as it is done by test.bash does not fail when it should and so thinks it can proceed. What might be helpful is to report what go/build is passing to execute when gfortran is called via cgo.

diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index 89ab1c0..ff7574d 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -2044,6 +2044,11 @@ func (b *builder) runOut(dir string, desc string, env []string, cmdargs ...inter
                }
        }

+       if cmdline[0] == "gfortran" {
+               fmt.Println(cmdline)
+               fmt.Println(mergeEnvLists(env, envForDir(dir, os.Environ())))
+       }
+
        nbusy := 0
        for {
                var buf bytes.Buffer

Then play with gfortran invocations for helloworld.f90 using the options that are passed until you get a helloworld.f90 build failure (also considering env vars).

@tsuna
Copy link
Contributor

tsuna commented Feb 29, 2016

JFYI, I'm seeing the same error, also on OS X, but with gcc installed from Homebrew (which provides gfortran) rather than from Fink. I also see main.exe and it runs fine, but like in @odysseus9672's case, the library can't be found by the linker.

tsuna@damogran ~/src/go/src $ ../misc/cgo/fortran/main.exe
 Hello World!
tsuna@damogran ~/src/go/src $ ldd ../misc/cgo/fortran/main.exe
../misc/cgo/fortran/main.exe:
    /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /usr/local/lib/gcc/5/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

I applied the patch shown above and I got this:

$ env -i PATH=/Users/tsuna/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/sbin GOROOT_BOOTSTRAP=/usr/local/Cellar/go/1.6/libexec ./all.bash
[...]
##### ../misc/cgo/fortran
[gfortran -I /Users/tsuna/src/go/misc/cgo/fortran -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -fno-common -I /tmp/go-build603620941/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o /tmp/go-build603620941/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c /Users/tsuna/src/go/misc/cgo/fortran/answer.f90]
[GOHOSTARCH=amd64 TERM=dumb GOROOT_BOOTSTRAP=/usr/local/Cellar/go/1.6/libexec GOTOOLDIR=/Users/tsuna/src/go/pkg/tool/darwin_amd64 GOGCCFLAGS=-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common PATH=/Users/tsuna/src/go/bin:/Users/tsuna/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/sbin GOARM=7 PWD=/Users/tsuna/src/go/misc/cgo/fortran GOARCH=amd64 LANG=C GO386=sse2 CGO_ENABLED=1 CXX=clang++ SHLVL=2 LANGUAGE=en_US.UTF8 GOROOT=/Users/tsuna/src/go GOOS=darwin GOHOSTOS=darwin CC=clang _=/Users/tsuna/src/go/bin/go]
# _/Users/tsuna/src/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/tsuna/src/go/misc/cgo/fortran [build failed]
FAIL: go test

@odysseus9672
Copy link
Author

I've also applied the patch mentioned, and here's the output.

##### ../misc/cgo/fortran
[gfortran -I /Users/sean/goLang/go/misc/cgo/fortran -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -fno-common -I /var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/T/go-build122949776/_/Users/sean/goLang/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o /var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/T/go-build122949776/_/Users/sean/goLang/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c /Users/sean/goLang/go/misc/cgo/fortran/answer.f90]
[MANPATH=/sw/share/man:/usr/local/share/man:/usr/share/man:/opt/X11/share/man:/Library/TeX/texbin/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man:/sw/lib/perl5/5.18.2/man TERM_PROGRAM=Apple_Terminal XDG_DATA_HOME=/Users/sean/.local/share GNUPLOT_DEFAULT_GDFONT=Arial SHELL=/bin/bash TERM=dumb HGENCODING=UTF-8 TMPDIR=/var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/T/ PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.dz7wyAWdKm/Render TERM_PROGRAM_VERSION=343.7 TERM_SESSION_ID=BF74C4EF-BB90-4561-AD2F-A61262C190F4 ac_cv_path_INTLTOOL_PERL=/usr/bin/perl XAPPLRESDIR=/sw/etc/app-defaults/ GOROOT_BOOTSTRAP=/Users/sean/golang/go1.4.3 SGML_CATALOG_FILES=/sw/etc/sgml/catalog USER=sean GDK_USE_XFT=1 GDFONTPATH=/Library/Fonts SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.aRfIhVGsJj/Listeners __CF_USER_TEXT_ENCODING=0x1F9:0x0:0x0 GNOME_DISABLE_CRASH_DIALOG=1 XDG_CONFIG_DIRS=/sw/etc/xdg PATH=/Users/sean/goLang/go/bin:/Users/sean/mybin:/sw/bin:/sw/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/Users/sean/goLang/go/bin HG=/sw/bin/hg XML_CATALOG_FILES=/sw/etc/xml/catalog PWD=/Users/sean/goLang/go/misc/cgo/fortran LANG=C XPC_FLAGS=0x0 IRCNAME=BlackGriffen IRCUSER=BlackGriffen GOMAXPROCS=4 XPC_SERVICE_NAME=0 IRCNICK=BlackGriffen SHLVL=2 HOME=/Users/sean bc03=/Users/sean/AstroTools/bc03/src GOROOT=/Users/sean/goLang/go XDG_CONFIG_HOME=/Users/sean/.config XDG_CACHE_HOME=/Users/sean/.cache PYTHONPATH=/Users/sean/lib LOGNAME=sean XDG_DATA_DIRS=/sw/share DBUS_SESSION_BUS_ADDRESS=launchd:env=DBUS_FINK_SESSION_BUS_SOCKET GOHOSTOS=darwin INFOPATH=/sw/share/info:/sw/info:/usr/share/info CC=clang XDG_RUNTIME_DIR=/var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/C/ DISPLAY=/private/tmp/com.apple.launchd.5ZSuFRU7vW/org.macosforge.xquartz:0 LADSPA_PATH=/sw/lib/ladspa SECURITYSESSIONID=186a5 GOARCH=amd64 GOHOSTARCH=amd64 GOOS=darwin GOTOOLDIR=/Users/sean/goLang/go/pkg/tool/darwin_amd64 GOGCCFLAGS=-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common CXX=clang++ CGO_ENABLED=1 GO386=sse2 GOARM=7 LANGUAGE=en_US.UTF8]
# _/Users/sean/goLang/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/Users/sean/goLang/go/misc/cgo/fortran [build failed]
2016/02/28 19:37:03 Failed: exit status 2

@tsuna
Copy link
Contributor

tsuna commented Feb 29, 2016

BTW, if I throw a -x in there I get:

+ go test -x
WORK=/tmp/go-build194267605
mkdir -p $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_/Users/tsuna/src/go/misc/cgo/
mkdir -p $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/
cd /Users/tsuna/src/go/misc/cgo/fortran
CGO_LDFLAGS="-g" "-O2" "-lgfortran" /Users/tsuna/src/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -importpath _/Users/tsuna/src/go/misc/cgo/fortran -- -I $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ fortran.go
cd $WORK
clang -fdebug-prefix-map=a=b -c trivial.c
clang -gno-record-gcc-switches -c trivial.c
cd /Users/tsuna/src/go/misc/cgo/fortran
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common -I $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o -c $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common -I $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o -c $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common -I $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o -c $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.c
gfortran -I . -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -fno-common -I $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c ./answer.f90
[gfortran -I /Users/tsuna/src/go/misc/cgo/fortran -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -fno-common -I /tmp/go-build194267605/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o /tmp/go-build194267605/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c /Users/tsuna/src/go/misc/cgo/fortran/answer.f90]
[GOHOSTARCH=amd64 TERM=dumb GOROOT_BOOTSTRAP=/usr/local/Cellar/go/1.6/libexec GOTOOLDIR=/Users/tsuna/src/go/pkg/tool/darwin_amd64 GOGCCFLAGS=-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common PATH=/Users/tsuna/src/go/bin:/Users/tsuna/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/sbin GOARM=7 PWD=/Users/tsuna/src/go/misc/cgo/fortran GOARCH=amd64 LANG=C CXX=clang++ CGO_ENABLED=1 GO386=sse2 SHLVL=3 GOROOT=/Users/tsuna/src/go LANGUAGE=en_US.UTF8 GOOS=darwin GOHOSTOS=darwin CC=clang _=/Users/tsuna/src/go/bin/go]
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common -o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_.o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o $WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -g -O2 -lgfortran
# _/Users/tsuna/src/go/misc/cgo/fortran
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$WORK/_/Users/tsuna/src/go/misc/cgo/fortran/_test/fortran.test
FAIL    _/Users/tsuna/src/go/misc/cgo/fortran [build failed]

We can see that clang is given -lgfortran without any -L flags, so this is assuming that clang can find it in its default search paths. This is a very reasonable assumption but here the problem stems from the fact that clang is the Apple-provided /usr/bin/clang, not the Homebrew-installed gcc that provided gfortran. Actually in the case of Homebrew, gcc isn't even installed as gcc by default, but as /usr/local/bin/gcc-5.

If I re-run the test as shown above but I override the environment variables CXX=g++-5 CC=gcc-5 (only the latter actually matters in this case) then the test passes.

You could argue that this setup is messed up ("what, your default C compiler is completely unrelated to your FORTRAN compiler?!") but since this is going to be a common problem given the number of people using Fink / MacPorts / Homebrew, it would be nice to find a way to fix this. Potentially using something along the lines of gfortran -print-file-name=libgfortran.dylib to find where the library is and add the dirname of that output as a -L flag (or adding all the library paths returned by gfortran -print-search-dirs).

Since we're in 2016 and I personally couldn't care less about FORTRAN, I simply removed gfortran from my $PATH so that this test doesn't run.

@kortschak
Copy link
Contributor

I'd prefer to have it detect the failure and skip rather than work hard to make the test pass. Any suggestion to how to get the attempt to build helloworld.f90 to fail on your machine in the same way?

@odysseus9672
Copy link
Author

You'd have to better emulate the process used in the go build. For instance, have gfortran put out an object file and then have the linker try to make main.exe.

Another possibility would be to test if the gfortran lib search dirs are contained in the search dirs used by the linker CGo is associated with or in the CGO_LDFLAGS. Though with the search dirs allowed to contain .. symbols, and probably symlinks, you'd need access to something that is more than a simple textual compare.

The trouble is that it seems like requiring the Fortran compiler be part of the software package used for the C linker is excessively strict.

gopherbot pushed a commit that referenced this issue Mar 23, 2016
Updates #14544.

Change-Id: I24ab8e6f9ad9d290a672216fc2f50f78c3ed8812
Reviewed-on: https://go-review.googlesource.com/21014
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@martisch
Copy link
Contributor

./all.bash fails with the "/usr/bin/ld: cannot find -lgfortran" error on freebsd 10.2 too as soon as i (pkg) install gcc.

@gopherbot
Copy link

CL https://golang.org/cl/21188 mentions this issue.

@josharian
Copy link
Contributor

I think this is a general problem, not a FreeBSD problem (not a dragonfly problem, for that matter). See #14544.

@mikioh
Copy link
Contributor

mikioh commented Mar 28, 2016

@josharian,

Yup, but I'm fine to disable the flaky test until someone resolves the root cause.

@josharian
Copy link
Contributor

Then let's disable for everyone rather than adding OSes one at a time, since it has nothing to with the OS.

@kortschak
Copy link
Contributor

Can we leave linux-amd64 to avoid gross regressions? With a TODO.

@ianlancetaylor
Copy link
Contributor

Seems like the problem arises because if $FC contains the string "gfortran" then the go tool passes -lgfortran to the linker, but the test in misc/cgo/fortran/test.bash does not do that when checking whether $FC works.

Could you see if https://golang.org/cl/21201 fixes the problem for you?

@mikioh
Copy link
Contributor

mikioh commented Mar 28, 2016

Just reverted cmd/dist/test.go and gave a short at cl21201 on dragonfly.

##### ../misc/cgo/fortran
# _/home/mikioh/go/misc/cgo/fortran
/usr/libexec/binutils225/elf/ld.gold: error: cannot find -lgfortran
FAIL    _/home/mikioh/go/misc/cgo/fortran [build failed]
FAIL: go test

Perhaps we need to test the capability for gfortran before the fortran test.

@gopherbot
Copy link

CL https://golang.org/cl/21201 mentions this issue.

@martisch
Copy link
Contributor

CL21201 also fails on freebsd.
This line works fine: "$FC helloworld/helloworld.f90 -o main.exe $flibs"
but "go test" fails with the linker error.

If i manually run /usr/local/bin/gfortran helloworld/helloworld.f90 -o main.exe -lgfortran
its exits with 0 and creates main.exe.

Not sure if this is related:
To actually run main.exe on freebsd 10.2 i need to add LD_LIBRARY_PATH:
LD_LIBRARY_PATH=/usr/local/lib/gcc48/ ./main.exe
because otherwise it does not find /lib/libgcc_s.so.1 see freebsd-toolchain discussion

@ianlancetaylor
Copy link
Contributor

@martisch Could you add -x to the go test line and show us the output? Thanks.

@odysseus9672
Copy link
Author

@tsuna already mentioned a solution that sounded pretty workable, to me.

Potentially using something along the lines of gfortran -print-file-name=libgfortran.dylib to find where the library is and add the dirname of that output as a -L flag (or adding all the library paths returned by gfortran -print-search-dirs).

I added caveats about how it would be nice to prune the output from the gfortran -print-search-dirs to avoid searching the same directory multiple times, but that isn't essential.

Edit: I should add that I don't see this as a way to fix the test. I see it as a way to fix how cgo supports fortran.

@martisch
Copy link
Contributor

@ianlancetaylor sure, thanks for having a look at this.

Seems cgo uses clang which is the default compiler in the freebsd base system and that clang wont find -lgfortran. The $FC command uses /usr/local/bin/gfortran.
Ping me if i should try out new patches/commands or generate more debug info. If better access is needed i can setup a freebsd server and user account so you can have a look at it live.

##### ../misc/cgo/fortran
WORK=/tmp/go-build300608776
mkdir -p $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_/usr/home/martisch/go/misc/cgo/
mkdir -p $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/
cd /usr/home/martisch/go/misc/cgo/fortran
CGO_LDFLAGS="-g" "-O2" "-lgfortran" /home/martisch/go/pkg/tool/freebsd_amd64/cgo -objdir $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -importpath _/usr/home/martisch/go/misc/cgo/fortran -- -I $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ fortran.go
cd $WORK
clang -fdebug-prefix-map=a=b -c trivial.c
clang -gno-record-gcc-switches -c trivial.c
cd /usr/home/martisch/go/misc/cgo/fortran
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o -c $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o -c $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o -c $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.c
gfortran -I . -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c ./answer.f90
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_.o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o $WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -g -O2 -lgfortran
# _/usr/home/martisch/go/misc/cgo/fortran
/usr/bin/ld: cannot find -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$WORK/_/usr/home/martisch/go/misc/cgo/fortran/_test/fortran.test
FAIL    _/usr/home/martisch/go/misc/cgo/fortran [build failed]
FAIL: go test
2016/03/28 19:06:12 Failed: exit status 1
gfortran -print-search-dirs
install: /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/
programs: =/usr/local/libexec/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/libexec/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/libexec/gcc48/gcc/x86_64-portbld-freebsd10.1/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../../../x86_64-portbld-freebsd10.1/bin/x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../../../x86_64-portbld-freebsd10.1/bin/
libraries: =/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../../../x86_64-portbld-freebsd10.1/lib/x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../../../x86_64-portbld-freebsd10.1/lib/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../x86_64-portbld-freebsd10.1/4.8.5/:/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../:/lib/x86_64-portbld-freebsd10.1/4.8.5/:/lib/:/usr/lib/x86_64-portbld-freebsd10.1/4.8.5/:/usr/lib/

gfortran -print-file-name=libgfortran.so   
/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../libgfortran.so

@hirochachacha
Copy link
Contributor

Hi, if I understand things correctly, I guess the solution is already clear.

We can modify go tool dist to distribute defaultFC and defaultFC_LDFLAGS like defaultCC for C compiler.

These values are defined by

var defaultFC string
var defaultFC_LDFLAGS string

if defaultCC == "gcc" {
  defaultFC = "gfortran"
  defaultFC_LDFLAGS = "-lgfortran"
}

If $FC and defaultFC are empty, the misc/cgo/fortran test should be skipped.

This solution is not only solving the issue, but also open for future extensions.
(e.g $FC_FOR_TARGET and $FC_LDFLAGS_FOR_TARGET)

@kortschak
Copy link
Contributor

Please try https://golang.org/cl/21297.

@gopherbot
Copy link

CL https://golang.org/cl/21297 mentions this issue.

@martisch
Copy link
Contributor

with patch:

bash -x ./test.bash gfortran
+ set -e
+ FC=gfortran
+ LD_LIBRARY_PATH=
+ case "$FC" in
+++ gfortran -print-file-name=libgfortran.so
++ dirname /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../libgfortran.so
+ LD_LIBRARY_PATH=/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../..
+ gfortran helloworld/helloworld.f90 -o main.exe
+ rm -f main.exe
+ go test -x
WORK=/tmp/go-build282707768
mkdir -p $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_/home/martisch/go/misc/cgo/
mkdir -p $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/
cd /home/martisch/go/misc/cgo/fortran
CGO_LDFLAGS="-g" "-O2" "-lgfortran" /home/martisch/go/pkg/tool/freebsd_amd64/cgo -objdir $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -importpath _/home/martisch/go/misc/cgo/fortran -- -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ fortran.go
cd $WORK
clang -fdebug-prefix-map=a=b -c trivial.c
clang -gno-record-gcc-switches -c trivial.c
cd /home/martisch/go/misc/cgo/fortran
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o -c $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o -c $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o -c $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.c
gfortran -I . -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c ./answer.f90
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -g -O2 -lgfortran
# _/home/martisch/go/misc/cgo/fortran
/usr/bin/ld: cannot find -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$WORK/_/home/martisch/go/misc/cgo/fortran/_test/fortran.test
FAIL    _/home/martisch/go/misc/cgo/fortran [build failed]
+ echo 'FAIL: go test'
FAIL: go test
+ status=1
+ exit 1

@kortschak
Copy link
Contributor

@martisch If you set LD_LIBRARY_PATH correctly prior to all.bash, do you get success?

@siebenmann
Copy link

I'm experiencing this general issue on FreeBSD 9.3, but there is a significant complication in my environment (one that may well exist in others). The short version is that I believe a fundamental problem here is compiling the Fortran code with gfortran (part of gcc) but compiling C code and linking everything with clang.

Run straight, without the CL change to misc/cgo/fortran/test.bash, I get the same failure as others:

##### ../misc/cgo/fortran
# _/homes/cks/src/go/misc/cgo/fortran
/usr/bin/ld: cannot find -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    _/homes/cks/src/go/misc/cgo/fortran [build failed]
FAIL: go test
2016/03/30 21:00:43 Failed: exit status 1

However, with the modification to test.bash from CL https://golang.org/cl/21297 what I get instead is a failure to link:

##### ../misc/cgo/fortran
# _/homes/cks/src/go/misc/cgo/fortran
/usr/local/lib/gcc48/gcc/i386-portbld-freebsd9.3/4.8.5/../../../libgfortran.so: undefined reference to `__getf2@GCC_4.6.0'
/usr/local/lib/gcc48/gcc/i386-portbld-freebsd9.3/4.8.5/../../../libgfortran.so: undefined reference to `__floatunditf@GCC_4.6.0'
/usr/local/lib/gcc48/gcc/i386-portbld-freebsd9.3/4.8.5/../../../libgfortran.so: undefined reference to `__subtf3@GCC_4.6.0'
[... repeat for a lot more symbols ...]

What I believe the underlying problem here is that on my FreeBSD the Fortran compiler is gfortran, ie GNU Fortran from the GCC compiler suite, but 'go test' is trying to build C code with clang and link the resulting clang C .o's with gfortran-compiled Fortran .o's. I'm not certain if this can ever work, but if it does it clearly needs more than just libgfortran.so itself, because libgfortran.so depends on libgcc_s.so and possibly other gcc-built shared libraries:

$ gfortran helloworld/helloworld.f90 -o main.exe
$ ldd main.exe
main.exe:
        libgfortran.so.3 => /usr/local/lib/gcc48/libgfortran.so.3 (0x2806a000)
        libm.so.5 => /lib/libm.so.5 (0x28167000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x28182000)
        libquadmath.so.0 => /usr/local/lib/gcc48/libquadmath.so.0 (0x2818d000)
        libc.so.7 => /lib/libc.so.7 (0x28206000)

I have tried a modification to the CL where I set not just LIBRARY_PATH but also CC=gcc and it works. In fact, setting $CC alone makes things work, presumably because the version of gcc that goes with gfortran has been built properly so it can find libgfortran on its own. This is easy to test in the directory:

$ cd misc/cgo/fortran
$ CC=gcc go test
PASS
ok      _/homes/cks/src/go/misc/cgo/fortran     0.004s

It's possible that forcing use of gcc will deal with most of the issues here.

The current test.bash diff I'm testing with is:

--- a/misc/cgo/fortran/test.bash
+++ b/misc/cgo/fortran/test.bash
@@ -9,6 +9,12 @@ set -e

 FC=$1

+case "$FC" in
+*gfortran*)
+  export CC=gcc
+  ;;
+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

@martisch
Copy link
Contributor

got it to work adding to patchset 3:

export CGO_LDFLAGS="-L /usr/local/lib/gcc48 -rpath /usr/local/lib/gcc48/"

the path /usr/local/lib/gcc48 is the path reported by $(dirname $($FC -print-file-name=libgfortran.${SFX}))

+ set -e
+ FC=gfortran
++ uname
+ [[ FreeBSD == \D\a\r\w\i\n ]]
+ SFX=so
+ case "$FC" in
+++ gfortran -print-file-name=libgfortran.so
++ dirname /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../../libgfortran.so
+ export LIBRARY_PATH=/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../..
+ LIBRARY_PATH=/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd10.1/4.8.5/../../..
+ gfortran helloworld/helloworld.f90 -o main.exe
+ rm -f main.exe
+ export 'CGO_LDFLAGS=-L /usr/local/lib/gcc48 -rpath /usr/local/lib/gcc48/'
+ CGO_LDFLAGS='-L /usr/local/lib/gcc48 -rpath /usr/local/lib/gcc48/'
+ go test -x
WORK=/tmp/go-build910922033
mkdir -p $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_/home/martisch/go/misc/cgo/
mkdir -p $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/
cd /home/martisch/go/misc/cgo/fortran
CGO_LDFLAGS="-L" "/usr/local/lib/gcc48" "-rpath" "/usr/local/lib/gcc48/" "-lgfortran" /home/martisch/go/pkg/tool/freebsd_amd64/cgo -objdir $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -importpath _/home/martisch/go/misc/cgo/fortran -- -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ fortran.go
cd $WORK
clang -fdebug-prefix-map=a=b -c trivial.c
clang -gno-record-gcc-switches -c trivial.c
cd /home/martisch/go/misc/cgo/fortran
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o -c $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o -c $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o -c $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.c
gfortran -I . -fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -I $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -g -O2 -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -c ./answer.f90
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_main.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -L /usr/local/lib/gcc48 -rpath /usr/local/lib/gcc48/ -lgfortran
/home/martisch/go/pkg/tool/freebsd_amd64/cgo -objdir $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/ -dynpackage fortran -dynimport $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_.o -dynout $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_import.go
cd $WORK
clang -no-pie -c trivial.c
cd /home/martisch/go/misc/cgo/fortran
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_all.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_export.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo2.o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/answer.f90.o -L /usr/local/lib/gcc48 -rpath /usr/local/lib/gcc48/ -Wl,-r -nostdlib
/home/martisch/go/pkg/tool/freebsd_amd64/compile -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_/home/martisch/go/misc/cgo/fortran.a -trimpath $WORK -p _/home/martisch/go/misc/cgo/fortran -buildid 436a583347a18a1c2ae28fa32fc3b617d4a0fa51 -D _/home/martisch/go/misc/cgo/fortran -I $WORK -pack ./fortran_test.go $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_gotypes.go $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/fortran.cgo1.go $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_cgo_import.go
pack r $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_/home/martisch/go/misc/cgo/fortran.a $WORK/_/home/martisch/go/misc/cgo/fortran/_test/_obj_test/_all.o # internal
mkdir -p $WORK/_/home/martisch/go/misc/cgo/fortran/_test/
cd $WORK/_/home/martisch/go/misc/cgo/fortran/_test
/home/martisch/go/pkg/tool/freebsd_amd64/compile -o ./main.a -trimpath $WORK -p main -complete -D "" -I . -I $WORK -pack ./_testmain.go
cd .
/home/martisch/go/pkg/tool/freebsd_amd64/link -o $WORK/_/home/martisch/go/misc/cgo/fortran/_test/fortran.test -L $WORK/_/home/martisch/go/misc/cgo/fortran/_test -L $WORK -w -extld=clang -buildmode=exe $WORK/_/home/martisch/go/misc/cgo/fortran/_test/main.a
$WORK/_/home/martisch/go/misc/cgo/fortran/_test/fortran.test
PASS
ok      _/home/martisch/go/misc/cgo/fortran 0.003s
+ exit

@gopherbot
Copy link

CL https://golang.org/cl/22730 mentions this issue.

@golang golang locked and limited conversation to collaborators May 4, 2017
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

10 participants