Skip to content

Commit

Permalink
fix(mac/gcc/g++): use classic linker with gnu compilers on c/c++ files
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed May 23, 2024
1 parent 51313b0 commit fcb637b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 14 additions & 2 deletions autotest/test_build.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
Expand All @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions autotest/test_gridgen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import pathlib as pl
import subprocess
from os import environ
from platform import system

import pytest
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fcb637b

Please sign in to comment.