Skip to content

Fixes for building KPP on MacOSX#153

Merged
yantosca merged 7 commits into
devfrom
hotfix/MacOs
Jul 2, 2026
Merged

Fixes for building KPP on MacOSX#153
yantosca merged 7 commits into
devfrom
hotfix/MacOs

Conversation

@yantosca

@yantosca yantosca commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This is the companion PR to #152 by @HartwigHarder, in which we have added several fixes for building KPP on MacOSX:

In src/Makefile.defs

  • Removed using -DMACOS in src/Makefile.defs and instead add pass a command to the C compiler to bump up the memory via C_FLAGS.
  • Use brew --prefix to obtain the root path for Homebrew-built libraries.
  • Replaced CC = gcc with CC ?= gcc, so that Make will use the compiler specified by the CC environment variable before trying to use hardcoded value "gcc". This was problematic because the default gcc on MacOS points to Clang.
  • Simplified code to be more architecture-independent.

In util/Makefile.c

  • Replaced CC = gcc with CC ?= gcc.
  • Added make list target to print compiler version information.

In util/Makefile_f90 and util/Makefile_upper_F90:

  • Replaced FC= gfortran with FC ?= gfortran
  • Added make list target to print compiler version information.

In src/gen.c

  • In the F90 language block, set the UPDATE_RCONST variable to 0 to avoid getting a "maybe-uninitialized-variable" compiler warning. This tends to happen with the newer GNU compiler versions (e.g. 14 and 15).

In function print_compiler_versions (located in `.ci-pipelines/ci-common-defs.sh):

  • Use ${CC} --version instead of gcc --version to ensure that we display the proper C compiler
  • Use ${FC} --version instead of gfortran --version to ensure that we display the proper Fortran compiler.

In docs/source/getting_started/01_installation.rst

  • Updated the MacOS-specific documentation with new shell script snippets that will ensure that the GNU compiler is chosen instead of Clang.

RolfSander and others added 7 commits June 16, 2026 20:50
src/Makefile.defs
- Use "CC ?= gcc" (instead of "CC := gcc") so that Make will first use
  the value of the $CC environment variable from the shell instead of
  setting it to "gcc".  This matters because the default gcc on MacOSX
  points to Clang rather than to GNU Compiler Collection.

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
docs/source/getting-started/01_installation.rst
- Updated the MacOSX-specific instructions to use a path-agnostic
  algorithm in .bashrc to search for the GCC compiler.
- Minor formatting updates

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
util/Makefile_c
- Now use "CC ?= gcc" which will use the value of the CC env var
  if it has already been defined in the shell
- Added "list" target to print compiler version info

util/Makefile_f90
util/Makefile_upper_F90
- Now use "FC_GFORTRAN ?= gfortran", which will use the value of
  the FC env var if it has been already defined in the shell
- Added "list" target to print compiler version info

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
src/Makefile.defs
- Added an architecture-agnostic block that calls "brew --prefix flex"
  (if Homebrew is present) instead of hardwiring the FLEX_LIB_DIR path.
- Define _BREW_PREFIX to store the value of "brew --prefix".  This
  allows us the FLEX and BISON paths in an architecture-indepenedent way.
- Updated comments

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
.ci-pipelines/ci-common-defs.sh
- Replace "gcc --version" with "${CC} --version", which will use the
  C compiler defined in the shell.  (Using "gcc" may point to clang").
- Replace "gfortran --version" with "${FC}" version, for the same reason

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
src/gen.c
- In function GenerateUpdateRconst, set the UPDATE_RCONST value to
  zero so that it will not generate a "maybe-unassigned-variable"
  compiler warning with GCC 15+.

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
@yantosca yantosca added this to the 3.4.1 milestone Jun 17, 2026
@yantosca yantosca requested a review from RolfSander June 17, 2026 21:06
@yantosca yantosca self-assigned this Jun 17, 2026
@yantosca yantosca linked an issue Jun 17, 2026 that may be closed by this pull request
@yantosca yantosca added build Related to makefiles and/or compilation bugfix Fixes a bug or a technical issue labels Jun 17, 2026
@RolfSander

Copy link
Copy Markdown
Contributor

As I'm not using MacOs, I will ask @HartwigHarder to review this PR.

The non-MacOs-related changes (using ?= and initializing with zero)
look fine.

@RolfSander RolfSander requested review from HartwigHarder and removed request for RolfSander July 2, 2026 10:11

@HartwigHarder HartwigHarder left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed working; tested native and in Caaba/Mecca, MacOS Tahoe 26.5.2

@RolfSander

Copy link
Copy Markdown
Contributor

Thanks, @HartwigHarder! I think we're ready to merge now...

@yantosca

yantosca commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @HartwigHarder and @RolfSander! I'll merge it up.

@yantosca yantosca merged commit d4d2147 into dev Jul 2, 2026
10 checks passed
@yantosca yantosca deleted the hotfix/MacOs branch July 2, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug or a technical issue build Related to makefiles and/or compilation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MacOS

3 participants