Skip to content

Commit

Permalink
Fix C++11 narrowing error on MacOS
Browse files Browse the repository at this point in the history
Resolves #127
  • Loading branch information
dgerlanc committed Feb 17, 2023
1 parent ead2c02 commit 71e2f1e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions aesara/link/c/cmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,12 @@ def join_options(init_part):
# Use the already-loaded python symbols.
cxxflags.extend(["-undefined", "dynamic_lookup"])

# Resolves C++11 narrowing error on Mac OS
# https://github.com/aesara-devs/aesara/issues/127
no_cpp_narrowing_flag = "-Wno-c++11-narrowing"
if no_cpp_narrowing_flag not in cxxflags:
cxxflags.append(no_cpp_narrowing_flag)

if sys.platform == "win32":
# Workaround for https://github.com/Theano/Theano/issues/4926.
# https://github.com/python/cpython/pull/11283/ removed the "hypot"
Expand Down
16 changes: 16 additions & 0 deletions tests/link/c/test_cmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,19 @@ def f_build(factor):
assert not any(
exit_code != 0 for exit_code in [proc.exitcode for proc in procs]
)


@patch("sys.platform", "darwin")
def test_osx_narrowing_compile_args():
no_narrowing_flag = "-Wno-c++11-narrowing"
assert no_narrowing_flag in GCC_compiler.compile_args()

cxxflags = f"{aesara.config.gcc__cxxflags} {no_narrowing_flag}"
with aesara.config.change_flags(gcc__cxxflags=cxxflags):
print(cxxflags)
res = GCC_compiler.compile_args()
print(res)
flag_idx = res.index(no_narrowing_flag)
# Make sure it's not in there twice
with pytest.raises(ValueError):
res.index(no_narrowing_flag, flag_idx + 1)

0 comments on commit 71e2f1e

Please sign in to comment.