In this section, we learn how to contribute to gem5
This page closely follows the slides. Please consider these as notes for the presentation. It may be helpful to reference the slides while following these notes.
Important note: This module is somewhat flawed “in the wild” as CodeSpaces does not allow users to contribute to Gerrit from the CodeSpace. This is something that needs fixed before this is tried again. This bug only affects people who work from the forked CodeSpace, not from the main repo.
We want to teach people how to use gem5 so they use gem5. We want people to use gem5 so they’ll develop for gem5. We want people who develop gem5 to contribute to gem5. We want contributions to improve the project. We want improvements to the project to garner interest. We want this interest to result in more people learning gem5.
If you’ve:
Understandable! Very few patches get in straight away. Most patches are only accepted after requests for changes.
We try our best to keep feedback as constructive as possible (don’t take it personally!).
The purpose of this session is to make it less scary.
We are making changes to the gem5-website repository.
We strongly recommend users create their own branch with git switch -c my-change
.
In this example they are working atop the gem5-stable branch. This is permitted for the gem5-website repository. If your patch is accepted the website will be updated with that change ASAP.
You may work atop the “develop” branch if your change to the website should be published upon the next major gem5 release (good for next release documentation updates).
In the gem5-resources repo you can build atop “stable” to make changes for the current release. You can build atop “develop” to make changes for the upcoming release.
Build atop “stable” to make changes for the current release.
Built atop “develop” to make changes for the upcoming release.
Build atop “develop to make changes. You cannot push to the “stable” branch.
Please conform to to the gem5 CPP style guide (a high-level overview is available in the gem5 repository).
Doxygen is highly recommended when making changes to CPP code. Doxygen is automatically generated to create: http://doxygen.gem5.org.
To format Python we utilize Python black:
pip install black
black <python file>
For variable/method/etc. naming conventions, please follow the PEP 8 naming convention recommendations. While we try our best to enforce naming conventions across the gem5 project, we are aware there are instances where they are not. In such cases please follow the convention of the code you are modifying.
git add <files to add>
This adds a file to the pre-commit staging area
git commit
This will start the commit process, but a commit message is required.
The rules for a gem5 commit message:
git log
This will show the log of all commits. You can use this to see how gem5 git commits look.
git push origin HEAD:refs/for/stable%wip
stable
is the branch you want to contribute to.
%wip
means the patch is “Work In Progress”.
However, if you do this you’ll run into an error
A new tab will open explaining how authenticate your machine thus allowing contributions to Gerrit. Follow these instructions and try pushing again.
However, even then you’ll receive an error when pushing.
f=`git rev-parse --git-dir`/hooks/commit-msg ; mkdir -p $(dirname $f) ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f
git commit --amend --no-edit
This is all you need to do. It’ll append the “Change-ID” to your commits. This is how Gerrit keeps track of your changes. Any commit with the same Change-ID is considered to be the same change.
git log
Will show the change with the Change-ID applied.
You should be able to push now.
This only applies to the gem5 repository contributions.
You need sign off by a reviewer and a maintainer to get a patch into gem5.
Sometimes a maintainers will give votes for both (as a reviewer and as a maintainer) but we only recommend this for stuff the maintainer has high confidence in. Typically, we like two separate people to sign off on a patch.
This only applies to gem5 repository contributions.
Here we encourage users to make their own contributions to gem5.