Skip to content

Commit

Permalink
Autoconf: Disable LDFLAGS for C testing (#674)
Browse files Browse the repository at this point in the history
Certain compilers would expect values passed to ld which cannot be
passed to the C compiler.  This caused the autoconf C configuration to
fail, since it uses to CC for linking rather than LD.

Since we never use the C compiler for linking, this is not something we
need to be concerned about, and the LDFLAGS is disabled when testing the
C compiler.

This is only a concern when using certain GPU-related flags in the
Nvidia compiler, and is only a problem for libraries with a significant
amount of C code, such as FMS.
  • Loading branch information
marshallward authored Jul 9, 2024
1 parent f596c81 commit ac9d6a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ $(WORK)/%/restart/ocean.stats: $(BUILD)/symmetric/MOM6 | preproc
# Not a true rule; only call this after `make test` to summarize test results.
.PHONY: test.summary
test.summary:
@./tools/report_test_results.sh $(WORK)/results
./tools/report_test_results.sh $(WORK)/results


#---
Expand Down
4 changes: 2 additions & 2 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ AS_IF([test "x$with_driver" != "x"],


# Explicitly assume free-form Fortran
AC_LANG(Fortran)
AC_FC_SRCEXT(f90)
AC_LANG([Fortran])
AC_FC_SRCEXT([f90])


# Determine MPI compiler wrappers
Expand Down
16 changes: 14 additions & 2 deletions ac/deps/configure.fms.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ AC_INIT(
AC_CONFIG_SRCDIR([fms/fms.F90])
AC_CONFIG_MACRO_DIR([m4])


# C configuration

# Autoconf assumes that LDFLAGS can be passed to CFLAGS, even though this is
# not valid in some compilers. This can cause basic CC tests to fail.
# Since we do not link with CC, we can safely disable LDFLAGS for AC_PROG_CC.
FC_LDFLAGS="$LDFLAGS"
LDFLAGS=""

# C compiler verification
AC_PROG_CC
AX_MPI
CC=$MPICC
Expand Down Expand Up @@ -55,10 +64,13 @@ AC_CHECK_FUNCS([gettid], [], [
# FMS 2019.01.03 uses __APPLE__ to disable Linux CPU affinity calls.
AC_CHECK_FUNCS([sched_getaffinity], [], [AC_DEFINE([__APPLE__])])

# Restore LDFLAGS
LDFLAGS="$FC_LDFLAGS"


# Standard Fortran configuration
AC_LANG(Fortran)
AC_FC_SRCEXT(f90)
AC_LANG([Fortran])
AC_FC_SRCEXT([f90])
AC_PROG_FC


Expand Down

0 comments on commit ac9d6a4

Please sign in to comment.