Skip to content

Commit

Permalink
enable custom llvm build flags (bytecodealliance#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
xujuntwt95329 authored Mar 5, 2023
1 parent e8d7180 commit e6a0184
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions build-scripts/build_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def query_llvm_version(llvm_info):
return response['sha']


def build_llvm(llvm_dir, platform, backends, projects, use_clang=False):
def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags=''):
LLVM_COMPILE_OPTIONS = [
'-DCMAKE_BUILD_TYPE:STRING="Release"',
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
Expand Down Expand Up @@ -143,7 +143,7 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False):
+ LLVM_INCLUDE_TOOLS_OPTION
)

CONFIG_CMD = f"cmake {compile_options} ../llvm"
CONFIG_CMD = f"cmake {compile_options} {extra_flags} ../llvm"
if "windows" == platform:
if "mingw" in sysconfig.get_platform().lower():
CONFIG_CMD += " -G'Unix Makefiles'"
Expand Down Expand Up @@ -227,6 +227,12 @@ def main():
action="store_true",
help="use clang instead of gcc",
)
parser.add_argument(
"--extra-cmake-flags",
type=str,
default="",
help="custom extra cmake flags",
)
options = parser.parse_args()

# if the "platform" is not identified in the command line option,
Expand Down Expand Up @@ -275,7 +281,8 @@ def main():
llvm_dir = clone_llvm(deps_dir, llvm_info["repo"], llvm_info["branch"])
if (
build_llvm(
llvm_dir, platform, options.arch, options.project, options.use_clang
llvm_dir, platform, options.arch, options.project, options.use_clang,
options.extra_cmake_flags
)
is not None
):
Expand Down

0 comments on commit e6a0184

Please sign in to comment.