Skip to content

Commit ed1e3b4

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Use lang_compiler_flags to avoid breaking C libraries
Summary: We need to use `runtime.cxx_library` to build C++ and C libraries. For C libraries we can't have the compiler flag `-std=c++17`. Here I'm using a `lang_compiler_flags` to support the old feature without breaking C libraries. Reviewed By: mcr229 Differential Revision: D48086453 fbshipit-source-id: e5ff21f88f681cdafa6aa340da70cea7d076c04d
1 parent 1e996d3 commit ed1e3b4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

shim/xplat/executorch/build/env_interface.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ def _patch_pp_flags(kwargs):
120120
return kwargs
121121

122122
def _patch_cxx_compiler_flags(kwargs):
123-
"""Compiler flags to enable C++17 features."""
124-
if "compiler_flags" in kwargs:
125-
kwargs["compiler_flags"].append("-std=c++17")
123+
"""CXX Compiler flags to enable C++17 features."""
124+
if "lang_compiler_flags" not in kwargs:
125+
kwargs["lang_compiler_flags"] = {"cxx_cpp_output": ["-std=c++17"]}
126+
elif "cxx_cpp_output" not in kwargs["lang_compiler_flags"]:
127+
kwargs["lang_compiler_flags"]["cxx_cpp_output"] = ["-std=c++17"]
126128
else:
127-
kwargs["compiler_flags"] = ["-std=c++17"]
129+
kwargs["lang_compiler_flags"]["cxx_cpp_output"].append("-std=c++17")
128130
return kwargs
129131

130132
# buildifier: disable=unused-variable

0 commit comments

Comments
 (0)