https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111325
Bug ID: 111325 Summary: config/acx.m4: <PROG>_FOR_TARGET are not usable at top level Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: p...@gcc-bugzilla.mail.kapsi.fi Target Milestone: --- Hi. `<PROG>_FOR_TARGET' environment variables are not usable if used at top level configure when build == host and build != target. The problem is that ACX_CHECK_INSTALLED_TARGET_TOOL first checks for <prog>. If cache variable `ac_cv_path_<VAR>' (`VAR'=`<PROG>_FOR_TARGET') is empty, attempts to use AC_PATH_PROG(VAR, PROG, ...) (defined at lib/autoconf/programs.m4). Unfortunately, AC_PATH_PROG always sets `<VAR>' to cache variable `ac_cv_path_<VAR>' (that we know is potentially empty), i.e. `<PROG>_FOR_TARGET'=`ac_cv_path_<PROG>_FOR_TARGET'. If <prog> is not found, the (empty) cache variable is not touched, thus overwriting any user provided `<PROG>_FOR_TARGET' value. Then, NCN_STRICT_CHECK_TARGET_TOOLS tries to look for <target-prefix><prog>. If `<PROG>_FOR_TARGET' should be used (<target-prefix><prog> is not available), it comes up now empty due to earlier AC_PATH_PROG call. Ultimately, `<PROG>_FOR_TARGET' is set to a default value <target-prefix><prog> for any subsequent configure runs and the user provided value is not picked up. This very likely will not work, given user attempted to override this using `<PROG>_FOR_TARGET'. config/acx.m4: 340: AC_DEFUN([ACX_CHECK_INSTALLED_TARGET_TOOL], [ ... # NB: Omitted when build == host and build != target. 359: if test -z "$ac_cv_path_$1" && test -n "$gcc_cv_tool_dirs"; then 360: AC_PATH_PROG([$1], [$2], [], [$gcc_cv_tool_dirs]) # NB: $1=$ac_cv_path_$1 if $1 is not found from $gcc_cv_tool_dirs. 361: fi 362: if test -z "$ac_cv_path_$1" ; then 363: NCN_STRICT_CHECK_TARGET_TOOLS([$1], [$2]) 364: else 365: $1=$ac_cv_path_$1 366: fi 367: ]) []dnl # ACX_CHECK_INSTALLED_TARGET_TOOL