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: Prevent Unnecessary Rebuilds Due to QEMU Config File Regeneration #2036

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

JShweiri
Copy link

Problem:

Currently, the Unicorn engine subproject is configured to regenerate QEMU's config-host.h and the architecture-specific config-target.h files every time CMake is run. This happens even if there haven't been any relevant changes to the project, leading to unnecessary rebuilds of the Unicorn library and any projects depending on it.

Solution:

This PR introduces conditional regeneration of the QEMU config files. The logic now checks if the files already exist in the build directory. If they do, regeneration is skipped, saving valuable build time.

Further Considerations:

While this PR addresses the most common case of unnecessary regeneration, there might be more subtle scenarios where we still want to regenerate the config files. Here are some potential approaches for future refinement:

  • Timestamp Comparison: We could compare the timestamps of the input (e.g., qemu/configure script) and output (e.g., config-host.h) files. If the input file is newer, it suggests changes have been made that require regeneration.

  • Configuration Hashing: A more robust approach would be to hash relevant configuration options and store the hash. If the configuration changes, the hash would change, triggering regeneration.

  • User-Controllable Option: Provide a CMake option (e.g., UNICORN_FORCE_REGEN) to give users control over forcing regeneration when desired.

@wtdcode
Copy link
Member

wtdcode commented Oct 18, 2024

Hey, thanks for your contribution but you shall send to our dev branch.

@JShweiri JShweiri changed the base branch from master to dev October 18, 2024 15:17
@wtdcode
Copy link
Member

wtdcode commented Oct 29, 2024

I went through cmake documents and ADDITIONAL_CLEAN_FILES seems to help easier regeneration. If we want to trigger a regeneration, we can simply make clean.

Could you also add the generated file to ADDITIONAL_CLEAN_FILES?

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.

2 participants