From 7780ff4f6976b350a714ee93ef9aead0352cc92f Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Fri, 5 Aug 2022 21:52:57 -0400 Subject: [PATCH 1/2] Autoconf: Logging for dependency builds This patch adds the `REPORT_ERROR_LOGS` variable to the .testing and ac/deps makefiles. When set to true, a failed FMS build will also echo the contents of `config.log`, in order to diagnose remote CI builds. The variable is disabled on default, to reduce the amount of output at command line. It has been added to the GitHub Actions CI, and is propagated through `.testing/Makefile`. Although not used in the MOM6 builds, it could be extended to them if it proves useful. Currently, these Makefiles always echo `config.log` after a failed build. --- .github/actions/testing-setup/action.yml | 2 +- .testing/Makefile | 8 +++++++- ac/deps/Makefile | 21 ++++++++++++--------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/actions/testing-setup/action.yml b/.github/actions/testing-setup/action.yml index a21ee949db..8a3264b140 100644 --- a/.github/actions/testing-setup/action.yml +++ b/.github/actions/testing-setup/action.yml @@ -32,7 +32,7 @@ runs: run: | echo "::group::Compile FMS library" cd .testing - make deps/lib/libFMS.a -s -j + REPORT_ERROR_LOGS=true make deps/lib/libFMS.a -s -j echo "::endgroup::" - name: Store compiler flags used in Makefile diff --git a/.testing/Makefile b/.testing/Makefile index 150a365692..917feb311b 100644 --- a/.testing/Makefile +++ b/.testing/Makefile @@ -116,6 +116,9 @@ DO_COVERAGE ?= # Report failure if coverage report is not uploaded REQUIRE_COVERAGE_UPLOAD ?= +# Print logs if an error is encountered +REPORT_ERROR_LOGS ?= + # Time measurement (configurable by the CI) TIME ?= time @@ -330,7 +333,10 @@ $(TARGET_CODEBASE): # FMS # Set up the FMS build environment variables -FMS_ENV = PATH="${PATH}:$(realpath ../ac)" FCFLAGS="$(FCFLAGS_FMS)" +FMS_ENV = \ + PATH="${PATH}:$(realpath ../ac)" \ + FCFLAGS="$(FCFLAGS_FMS)" \ + REPORT_ERROR_LOGS="$(REPORT_ERROR_LOGS)" deps/lib/libFMS.a: deps/fms/build/libFMS.a $(MAKE) -C deps lib/libFMS.a diff --git a/ac/deps/Makefile b/ac/deps/Makefile index af567f6a72..84d43eb26d 100644 --- a/ac/deps/Makefile +++ b/ac/deps/Makefile @@ -14,13 +14,16 @@ FMS_COMMIT ?= 2019.01.03 # List of source files to link this Makefile's dependencies to model Makefiles # Assumes a depth of two, and the following extensions: F90 inc c h # (1): Root directory -# NOTE: extensions could be a second variable SOURCE = \ $(foreach ext,F90 inc c h,$(wildcard $(1)/*/*.$(ext) $(1)/*/*/*.$(ext))) FMS_SOURCE = $(call SOURCE,fms/src) +# If `true`, print logs if an error is encountered. +REPORT_ERROR_LOGS ?= + + #--- # Rules @@ -33,13 +36,8 @@ all: lib/libFMS.a # NOTE: We emulate the automake `make install` stage by storing libFMS.a to # ${srcdir}/deps/lib and copying module files to ${srcdir}/deps/include. -# This is a flawed approach, since module files are untracked and could be -# handled more safely, but this is adequate for now. - - -# TODO: track *.mod copy? lib/libFMS.a: fms/build/libFMS.a - mkdir -p {lib,include} + mkdir -p lib include cp fms/build/libFMS.a lib/libFMS.a cp fms/build/*.mod include @@ -51,10 +49,15 @@ fms/build/libFMS.a: fms/build/Makefile fms/build/Makefile: Makefile.fms.in fms/src/configure mkdir -p fms/build cp Makefile.fms.in fms/src/Makefile.in - cd $(@D) && ../src/configure --srcdir=../src + cd $(@D) && { \ + ../src/configure --srcdir=../src \ + || { \ + if [ "${REPORT_ERROR_LOGS}" = true ]; then cat config.log ; fi ; \ + false; \ + } \ + } -# TODO: Track m4 macros? fms/src/configure: configure.fms.ac $(FMS_SOURCE) | fms/src cp configure.fms.ac fms/src/configure.ac cp -r m4 $(@D) From 00b0c9f522edca27d3642ded85fb7d618ac2c6e4 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Fri, 5 Aug 2022 21:53:12 -0400 Subject: [PATCH 2/2] CI: Replace GitHub Actions MacOS compiler env This patch fixes the gcc compiler environment variables on their MacOS systems. GitHub recently made some GCC compiler changes on their MacOS machines; specifically, `gcc-11` and `gfortran-11` appear to no longer be available. Previously, we were unable to use the default gcc and had to use these executables. On this newer version, we can use the default system gcc, and the `CC` environment variable can be left unset. We still need `FC` to point to `gfortran`, since it otherwise tries to build with `f77`, which does not exist. --- .github/workflows/macos-regression.yml | 3 +-- .github/workflows/macos-stencil.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/macos-regression.yml b/.github/workflows/macos-regression.yml index d975854e0c..e8f7469cca 100644 --- a/.github/workflows/macos-regression.yml +++ b/.github/workflows/macos-regression.yml @@ -8,8 +8,7 @@ jobs: runs-on: macOS-latest env: - CC: gcc-11 - FC: gfortran-11 + FC: gfortran defaults: run: diff --git a/.github/workflows/macos-stencil.yml b/.github/workflows/macos-stencil.yml index 33436c221f..e0fcfeef8e 100644 --- a/.github/workflows/macos-stencil.yml +++ b/.github/workflows/macos-stencil.yml @@ -8,8 +8,7 @@ jobs: runs-on: macOS-latest env: - CC: gcc-11 - FC: gfortran-11 + FC: gfortran defaults: run: