]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Go: do not clobber GOFLAGS in AC_PROG_GO (sr #111383) master
authorZack Weinberg <zack@owlfolio.org>
Mon, 9 Feb 2026 14:25:15 +0000 (09:25 -0500)
committerZack Weinberg <zack@owlfolio.org>
Mon, 9 Feb 2026 14:25:15 +0000 (09:25 -0500)
The AC_PROG_GO macro should honor the GOFLAGS set by the user at
configure time.

Fixes <https://savannah.gnu.org/support/?111382>.

* lib/autoconf/go.m4: Do not clobber GOFLAGS in AC_PROG_GO.
  Simplify sequence of AC_CHECK_TOOL/AC_CHECK_PROGS operations;
  this macro does not have the backward compatibility constraints
  that AC_PROG_CC does.

lib/autoconf/go.m4

index d9b8915edef58902e93fa4fcf50fcfac43d265ae..f82a64570b6acf6648cb4b67125ea35acc3f90d5 100644 (file)
@@ -149,23 +149,13 @@ AC_DEFUN([AC_LANG_COMPILER(Go)],
 AN_MAKEVAR([GOC], [AC_PROG_GO])
 AN_PROGRAM([gccgo], [AC_PROG_GO])
 AC_DEFUN([AC_PROG_GO],
-[AC_LANG_PUSH(Go)dnl
+[AC_LANG_PUSH([Go])dnl
 AC_ARG_VAR([GOC],   [Go compiler command])dnl
 AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
 _AC_ARG_VAR_LDFLAGS()dnl
-m4_ifval([$1],
-      [AC_CHECK_TOOLS(GOC, [$1])],
-[AC_CHECK_TOOL(GOC, gccgo)
-if test -z "$GOC"; then
-  if test -n "$ac_tool_prefix"; then
-    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [$ac_tool_prefix}gccgo])
-  fi
-fi
-if test -z "$GOC"; then
-  AC_CHECK_PROG(GOC, gccgo, gccgo, , , false)
-fi
-])
-
+# We only look for gccgo, not `go build`, because `go build`'s command
+# line interface is completely different.
+AC_CHECK_TOOLS([GOC], [m4_default([$1], [gccgo])])
 # Provide some information about the compiler.
 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
 set X $ac_compile
@@ -173,6 +163,7 @@ ac_compiler=$[2]
 _AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
-GOFLAGS="-g -O2"
-AC_LANG_POP(Go)dnl
+# Default value for GOFLAGS
+: ${GOFLAGS:="-g -O2"}
+AC_LANG_POP([Go])dnl
 ])# AC_PROG_GO