Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C++11 narrowing error on Mac OS #972

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)