From fcb637bea17e4ddcbf15375535c4680ff4596746 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Wed, 22 May 2024 22:41:50 -0400 Subject: [PATCH] fix(mac/gcc/g++): use classic linker with gnu compilers on c/c++ files --- autotest/test_build.py | 16 ++++++++++++++-- autotest/test_gridgen.py | 8 +++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/autotest/test_build.py b/autotest/test_build.py index 75e602e8..67315b22 100644 --- a/autotest/test_build.py +++ b/autotest/test_build.py @@ -1,10 +1,11 @@ import os import sys import time +from platform import system import pytest from flaky import flaky -from modflow_devtools.misc import get_ostag, set_dir +from modflow_devtools.misc import get_ostag, set_dir, set_env import pymake @@ -65,9 +66,15 @@ def build_with_makefile(target, path, fc): @pytest.mark.parametrize("target", targets) def test_build(function_tmpdir, target: str) -> None: with set_dir(function_tmpdir): + pm = pymake.Pymake(verbose=True) + pm.target = target + pm.inplace = True + if system() == "Darwin": + pm.syslibs = "-Wl,-ld_classic" assert ( pymake.build_apps( target, + pm, verbose=True, clean=False, ) @@ -79,7 +86,10 @@ def test_build(function_tmpdir, target: str) -> None: @flaky(max_runs=RERUNS) @pytest.mark.parametrize("target", targets_meson) def test_meson_build(function_tmpdir, target: str) -> None: - with set_dir(function_tmpdir): + kwargs = {} + if system() == "Darwin": + kwargs["LDFLAGS"] = "-Wl,-ld_classic" + with set_dir(function_tmpdir), set_env(**kwargs): assert ( pymake.build_apps( target, @@ -103,6 +113,8 @@ def test_makefile_build(function_tmpdir, target: str) -> None: pm.inplace = True pm.dryrun = True pm.makeclean = False + if system() == "Darwin": + pm.syslibs = "-Wl,-ld_classic" with set_dir(function_tmpdir): pm.download_target(target) diff --git a/autotest/test_gridgen.py b/autotest/test_gridgen.py index ef1365c3..6dbb1b38 100644 --- a/autotest/test_gridgen.py +++ b/autotest/test_gridgen.py @@ -1,6 +1,6 @@ -import os import pathlib as pl import subprocess +from os import environ from platform import system import pytest @@ -30,8 +30,10 @@ def pm(module_tmpdir, target) -> pymake.Pymake: pm = pymake.Pymake(verbose=True) pm.target = str(target) pm.appdir = str(module_tmpdir) - pm.cc = os.environ.get("CXX", "g++") - pm.fc = os.environ.get("FC", "gfortran") + pm.cc = environ.get("CXX", "g++") + pm.fc = environ.get("FC", "gfortran") + if system() == "Darwin": + pm.syslibs = "-Wl,-ld_classic" pm.inplace = True pm.makeclean = True yield pm