Skip to content

Commit 40d12ff

Browse files
dgerlancbrandonwillard
authored andcommitted
Fix C++11 narrowing error on MacOS
Resolves #127
1 parent 2f9a9e6 commit 40d12ff

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

aesara/link/c/cmodule.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,12 @@ def join_options(init_part):
23632363
# Use the already-loaded python symbols.
23642364
cxxflags.extend(["-undefined", "dynamic_lookup"])
23652365

2366+
# Resolves C++11 narrowing error on Mac OS
2367+
# https://github.com/aesara-devs/aesara/issues/127
2368+
no_cpp_narrowing_flag = "-Wno-c++11-narrowing"
2369+
if no_cpp_narrowing_flag not in cxxflags:
2370+
cxxflags.append(no_cpp_narrowing_flag)
2371+
23662372
if sys.platform == "win32":
23672373
# Workaround for https://github.com/Theano/Theano/issues/4926.
23682374
# https://github.com/python/cpython/pull/11283/ removed the "hypot"

tests/link/c/test_cmodule.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,19 @@ def f_build(factor):
263263
assert not any(
264264
exit_code != 0 for exit_code in [proc.exitcode for proc in procs]
265265
)
266+
267+
268+
@patch("sys.platform", "darwin")
269+
def test_osx_narrowing_compile_args():
270+
no_narrowing_flag = "-Wno-c++11-narrowing"
271+
assert no_narrowing_flag in GCC_compiler.compile_args()
272+
273+
cxxflags = f"{aesara.config.gcc__cxxflags} {no_narrowing_flag}"
274+
with aesara.config.change_flags(gcc__cxxflags=cxxflags):
275+
print(cxxflags)
276+
res = GCC_compiler.compile_args()
277+
print(res)
278+
flag_idx = res.index(no_narrowing_flag)
279+
# Make sure it's not in there twice
280+
with pytest.raises(ValueError):
281+
res.index(no_narrowing_flag, flag_idx + 1)

0 commit comments

Comments
 (0)