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

build_llvm.py: Speed up llvm build with multiple procs (#3497) #3512

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

wenyongh
Copy link
Contributor

@wenyongh wenyongh commented Jun 7, 2024

No description provided.

@@ -156,11 +156,14 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
CONFIG_CMD += " -A x64"
else:
CONFIG_CMD += " -G'Ninja'"
print("Config command: " + CONFIG_CMD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Config command: " + CONFIG_CMD)
print(f"Config command: {CONFIG_CMD}")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks.

subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir)

BUILD_CMD = "cmake --build . --target package" + (
" --config Release" if "windows" == platform else ""
)
BUILD_CMD += " --parallel " + str(os.cpu_count())
print("Build command: " + BUILD_CMD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Build command: " + BUILD_CMD)
print(f"Build command: {BUILD_CMD}")

subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir)

BUILD_CMD = "cmake --build . --target package" + (
" --config Release" if "windows" == platform else ""
)
BUILD_CMD += " --parallel " + str(os.cpu_count())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it's simpler to leave it to ninja when it's used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, not sure whether ninja will set the cpu count when -j or --parallel isn't set? I uploaded this PR since it took long time for the CI to compile the llvm library when creating a new release, e.g.
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/9394335353/job/25877128841
It will be good if we can speed it up.

BTW, in windows, it doesn't add -G'Ninja', instead it adds -G'Unix Makefiles' or -A x64. Maybe adding --parellel n option also benefits the compilation for windows.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc, ninja decides the concurrency by itself, based on the number of processors, unless you override it with -j N.

@wenyongh wenyongh merged commit 1434c45 into bytecodealliance:main Jun 13, 2024
371 checks passed
@wenyongh wenyongh deleted the enhance_build_llvm branch June 26, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants