[go] cmd/cgo: fix TestFortran on openbsd

5 views
Skip to first unread message

Joel Sing (Gerrit)

unread,
Jun 6, 2026, 10:53:58 AM (15 hours ago) Jun 6
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Joel Sing has uploaded the change for review

Commit message

cmd/cgo: fix TestFortran on openbsd

When gfortran is installed On OpenBSD, there is no unversioned
libgfortran.so library - look for libgfortran.a instead.

Additionally, the -print-file-name option returns the value specified
if the file is unknown. In other words, `-print-file-name=foobar` will
print `foobar`. Detect this case and error earlier so that it is easier
to debug.
Change-Id: I77d06cd48b0fc62b59fc9589ca13542ae3623a65

Change diff

diff --git a/src/cmd/cgo/internal/testfortran/fortran_test.go b/src/cmd/cgo/internal/testfortran/fortran_test.go
index 9ccf916..828265b 100644
--- a/src/cmd/cgo/internal/testfortran/fortran_test.go
+++ b/src/cmd/cgo/internal/testfortran/fortran_test.go
@@ -47,14 +47,19 @@
switch runtime.GOOS {
case "darwin":
libExt = "dylib"
- case "aix":
+ case "aix", "openbsd":
libExt = "a"
}
- libPath, err := exec.Command(fc, append([]string{"-print-file-name=libgfortran." + libExt}, fcExtra...)...).CombinedOutput()
+ libName := "libgfortran." + libExt
+ b, err := exec.Command(fc, append([]string{"-print-file-name=" + libName}, fcExtra...)...).CombinedOutput()
if err != nil {
- t.Errorf("error invoking %s: %s", fc, err)
+ t.Fatalf("error invoking %s: %s", fc, err)
}
- libDir := filepath.Dir(string(libPath))
+ libPath := strings.TrimSpace(string(b))
+ if string(libPath) == libName {
+ t.Fatalf("Failed to get full library path for %q", libName)
+ }
+ libDir := filepath.Dir(libPath)
cgoLDFlags := os.Getenv("CGO_LDFLAGS")
cgoLDFlags += " -L " + libDir
if runtime.GOOS != "aix" {

Change information

Files:
  • M src/cmd/cgo/internal/testfortran/fortran_test.go
Change size: S
Delta: 1 file changed, 9 insertions(+), 4 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I77d06cd48b0fc62b59fc9589ca13542ae3623a65
Gerrit-Change-Number: 787800
Gerrit-PatchSet: 1
Gerrit-Owner: Joel Sing <jo...@sing.id.au>
unsatisfied_requirement
satisfied_requirement
open
diffy

Joel Sing (Gerrit)

unread,
Jun 6, 2026, 10:59:34 AM (15 hours ago) Jun 6
to goph...@pubsubhelper.golang.org, Ian Lance Taylor, Michael Pratt, golang-co...@googlegroups.com
Attention needed from Ian Lance Taylor and Michael Pratt

Joel Sing voted

Auto-Submit+1
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Lance Taylor
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I77d06cd48b0fc62b59fc9589ca13542ae3623a65
Gerrit-Change-Number: 787800
Gerrit-PatchSet: 1
Gerrit-Owner: Joel Sing <jo...@sing.id.au>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Comment-Date: Sat, 06 Jun 2026 14:59:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Jun 6, 2026, 6:31:55 PM (7 hours ago) Jun 6
to Joel Sing, goph...@pubsubhelper.golang.org, Ian Lance Taylor, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Pratt, golang-co...@googlegroups.com
Attention needed from Joel Sing and Michael Pratt

Ian Lance Taylor voted and added 2 comments

Votes added by Ian Lance Taylor

Code-Review+2

2 comments

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Ian Lance Taylor . resolved

Thanks.

File src/cmd/cgo/internal/testfortran/fortran_test.go
Line 59, Patchset 1 (Latest): if string(libPath) == libName {
Ian Lance Taylor . unresolved

libPath is already a string here, the type conversion is unnecessary.

Open in Gerrit

Related details

Attention is currently required from:
  • Joel Sing
  • Michael Pratt
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I77d06cd48b0fc62b59fc9589ca13542ae3623a65
Gerrit-Change-Number: 787800
Gerrit-PatchSet: 1
Gerrit-Owner: Joel Sing <jo...@sing.id.au>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Joel Sing <jo...@sing.id.au>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Comment-Date: Sat, 06 Jun 2026 22:31:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages