system-arm: Rework boot loader makefile to be more generic
[gem5.git] / CONTRIBUTING.md
1 Authors: Jason Lowe-Power
2 Andreas Sandberg
3 Steve Reinhardt
4
5 If you've made changes to gem5 that might benefit others, we strongly encourage
6 you to contribute those changes to the public gem5 repository. There are
7 several reasons to do this:
8 * Share your work with others, so that they can benefit from new functionality.
9 * Support the scientific principle by enabling others to evaluate your
10 suggestions without having to guess what you did.
11 * Once your changes are part of the main repo, you no longer have to merge
12 them back in every time you update your local repo. This can be a huge time
13 saving!
14 * Once your code is in the main repo, other people have to make their changes
15 work with your code, and not the other way around.
16 * Others may build on your contributions to make them even better, or extend
17 them in ways you did not have time to do.
18 * You will have the satisfaction of contributing back to the community.
19
20 The main method for contributing code to gem5 is via our code review website:
21 https://gem5-review.googlesource.com/. This documents describes the details of
22 how to create code changes, upload your changes, have your changes
23 reviewed, and finally push your changes to gem5. More information can be found
24 from the following sources:
25 * http://gem5.org/Submitting_Contributions
26 * https://gerrit-review.googlesource.com/Documentation/index.html
27 * https://git-scm.com/book
28
29
30 High-level flow for submitting changes
31 ======================================
32
33 +-------------+
34 | Make change |
35 +------+------+
36 |
37 |
38 v
39 +-------------+
40 | Run tests |<--------------+
41 +------+------+ |
42 | |
43 | |
44 v |
45 +------+------+ |
46 | Post review | |
47 +------+------+ |
48 | |
49 v |
50 +--------+---------+ |
51 | Wait for reviews | |
52 +--------+---------+ |
53 | |
54 | |
55 v |
56 +----+----+ No +------+------+
57 |Reviewers+--------->+ Update code |
58 |happy? | +------+------+
59 +----+----+ ^
60 | |
61 | Yes |
62 v |
63 +----+-----+ No |
64 |Maintainer+----------------+
65 |happy? |
66 +----+-----+
67 |
68 | Yes
69 v
70 +------+------+
71 | Submit code |
72 +-------------+
73
74 After creating your change to gem5, you can post a review on our Gerrit
75 code-review site: https://gem5-review.googlesource.com. Before being able to
76 submit your code to the mainline of gem5, the code is reviewed by others in the
77 community. Additionally, the maintainer for that part of the code must sign off
78 on it.
79
80 Contributing long-lived feature branches
81 ----------------------------------------
82 Oftentimes users or institutions add features that are necessarily complex,
83 and require many changes on long-lived feature branches. In this case,
84 maintaining a perfect history where all changes work individually is infeasible.
85 When contributing long-lived feature branches back to gem5's public repository
86 users may merge entire long-lived branches into a single changeset and contribute
87 their code back as long as 1) the changes have been reviewed by the maintainer
88 2) the maintainer agrees to allow such a change, and 3) the changes are passing
89 the public tests. Changes that affect common code (outside of a specific
90 maintainer's purview) will still need to follow the standard gem5 protocol.
91
92
93 Cloning the gem5 repo to contribute
94 ===================================
95
96 If you plan on contributing, it is strongly encouraged for you to clone the
97 repository directly from our gerrit instance at
98 https://gem5.googlesource.com/.
99
100 To clone the master gem5 repository:
101 ```
102 git clone https://gem5.googlesource.com/public/gem5
103 ```
104
105 Other gem5 repositories
106 -----------------------
107
108 There are a few repositories other than the main gem5 development repository.
109
110 * public/m5threads: The code for a pthreads implementation that works with
111 gem5's syscall emulation mode.
112
113 Other gem5 branches
114 -------------------
115
116 None right now.
117
118 Making changes to gem5
119 ======================
120
121 It is strongly encouraged to use git branches when making changes to gem5.
122 Additionally, keeping changes small and concise and only have a single logical
123 change per commit.
124
125 Unlike our previous flow with Mercurial and patch queues, when using git, you
126 will be committing changes to your local branch. By using separate branches in
127 git, you will be able to pull in and merge changes from mainline and simply
128 keep up with upstream changes.
129
130 Requirements for change descriptions
131 ------------------------------------
132 To help reviewers and future contributors more easily understand and track
133 changes, we require all change descriptions be strictly formatted.
134
135 A canonical commit message consists of three parts:
136 * A short summary line describing the change. This line starts with one or
137 more keywords (found in the MAINTAINERS file) separated by commas followed
138 by a colon and a description of the change. This line should be no more than
139 65 characters long since version control systems usually add a prefix that
140 causes line-wrapping for longer lines.
141 * (Optional, but highly recommended) A detailed description. This describes
142 what you have done and why. If the change isn't obvious, you might want to
143 motivate why it is needed. Lines need to be wrapped to 75 characters or
144 less.
145 * Tags describing patch metadata. You are highly recommended to use
146 tags to acknowledge reviewers for their work. Gerrit will automatically add
147 most tags.
148
149 Tags are an optional mechanism to store additional metadata about a patch and
150 acknowledge people who reported a bug or reviewed that patch. Tags are
151 generally appended to the end of the commit message in the order they happen.
152 We currently use the following tags:
153 * Signed-off-by: Added by the author and the submitter (if different).
154 This tag is a statement saying that you believe the patch to be correct and
155 have the right to submit the patch according to the license in the affected
156 files. Similarly, if you commit someone else's patch, this tells the rest
157 of the world that you have have the right to forward it to the main
158 repository. If you need to make any changes at all to submit the change,
159 these should be described within hard brackets just before your
160 Signed-off-by tag. By adding this line, the contributor certifies the
161 contribution is made under the terms of the Developer Certificate of Origin
162 (DCO) [https://developercertificate.org/].
163 * Reviewed-by: Used to acknowledge patch reviewers. It's generally considered
164 good form to add these. Added automatically.
165 * Reported-by: Used to acknowledge someone for finding and reporting a bug.
166 * Reviewed-on: Link to the review request corresponding to this patch. Added
167 automatically.
168 * Change-Id: Used by Gerrit to track changes across rebases. Added
169 automatically with a commit hook by git.
170 * Tested-by: Used to acknowledge people who tested a patch. Sometimes added
171 automatically by review systems that integrate with CI systems.
172
173 Other than the "Signed-off-by", "Reported-by", and "Tested-by" tags, you
174 generally don't need to add these manually as they are added automatically by
175 Gerrit.
176
177 It is encouraged for the author of the patch and the submitter to add a
178 Signed-off-by tag to the commit message. By adding this line, the contributor
179 certifies the contribution is made under the terms of the Developer Certificate
180 of Origin (DCO) [https://developercertificate.org/].
181
182 It is imperative that you use your real name and your real email address in
183 both tags and in the author field of the changeset.
184
185 For significant changes, authors are encouraged to add copyright information
186 and their names at the beginning of the file. The main purpose of the author
187 names on the file is to track who is most knowledgeable about the file (e.g.,
188 who has contributed a significant amount of code to the file).
189
190 Note: If you do not follow these guidelines, the gerrit review site will
191 automatically reject your patch.
192 If this happens, update your changeset descriptions to match the required style
193 and resubmit. The following is a useful git command to update the most recent
194 commit (HEAD).
195
196 ```
197 git commit --amend
198 ```
199
200 Running tests
201 =============
202
203 Before posting a change to the code review site, you should always run the
204 quick tests!
205 See TESTING.md for more information.
206
207 Posting a review
208 ================
209
210 If you have not signed up for an account on the Gerrit review site
211 (https://gem5-review.googlesource.com), you first have to create an account.
212
213 Setting up an account
214 ---------------------
215 1. Go to https://gem5.googlesource.com/
216 2. Click "Sign In" in the upper right corner. Note: You will need a Google
217 account to contribute.
218 3. After signing in, click "Generate Password" and follow the instructions.
219
220 Submitting a change
221 -------------------
222
223 In gerrit, to submit a review request, you can simply push your git commits to
224 a special named branch. For more information on git push see
225 https://git-scm.com/docs/git-push.
226
227 There are three ways to push your changes to gerrit.
228
229 Push change to gerrit review
230 ----------------------------
231
232 ```
233 git push origin HEAD:refs/for/master
234 ```
235
236 Assuming origin is https://gem5.googlesource.com/public/gem5 and you want to
237 push the changeset at HEAD, this will create a new review request on top of the
238 master branch. More generally,
239
240 ```
241 git push <gem5 gerrit instance> <changeset>:refs/for/<branch>
242 ```
243
244 See https://gerrit-review.googlesource.com/Documentation/user-upload.html for
245 more information.
246
247 Pushing your first change
248 --------------------------
249 The first time you push a change you may get the following error:
250
251 ```
252 remote: ERROR: [fb1366b] missing Change-Id in commit message footer
253 ...
254 ```
255
256 Within the error message, there is a command line you should run. For every new
257 clone of the git repo, you need to run the following command to automatically
258 insert the change id in the the commit (all on one line).
259
260 ```
261 curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
262 https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; \
263 chmod +x `git rev-parse --git-dir`/hooks/commit-msg
264 ```
265
266 If you receive the above error, simply run this command and then amend your
267 changeset.
268
269 ```
270 git commit --amend
271 ```
272
273 Push change to gerrit as a draft/private
274 ----------------------------------------
275
276 See https://gerrit-review.googlesource.com/Documentation/intro-user.html#private-changes
277 for details on private gerrit changes.
278
279 ```
280 git push origin HEAD:refs/for/master%private
281 ```
282
283 Once you have pushed your change as "private", you can log onto [gerrit]
284 (https://gem5-review.googlesource.com) and once you're happy with the commit
285 click the "unmark private" which may be hidden in the "more options" dropdown
286 in the upper right corner.
287
288 Push change bypassing gerrit
289 -----------------------------
290
291 Only maintainers can bypass gerrit review. This should very rarely be used.
292
293 ```
294 git push origin HEAD:refs/heads/master
295 ```
296
297 Other gerrit push options
298 -------------------------
299
300 There are a number of options you can specify when uploading your changes to
301 gerrit (e.g., reviewers, labels). The gerrit documentation has more
302 information.
303 https://gerrit-review.googlesource.com/Documentation/user-upload.html
304
305
306 Reviewing patches
307 =================
308
309 Reviewing patches is done on our gerrit instance at
310 https://gem5-review.googlesource.com/.
311
312 After logging in with your Google account, you will be able to comment, review,
313 and push your own patches as well as review others' patches. All gem5 users are
314 encouraged to review patches. The only requirement to review patches is to be
315 polite and respectful of others.
316
317 There are multiple labels in Gerrit that can be applied to each review detailed
318 below.
319 * Code-review: This is used by any gem5 user to review patches. When reviewing
320 a patch you can give it a score of -2 to +2 with the following semantics.
321 * -2: This blocks the patch. You believe that this patch should never be
322 committed. This label should be very rarely used.
323 * -1: You would prefer this is not merged as is
324 * 0: No score
325 * +1: This patch seems good, but you aren't 100% confident that it should be
326 pushed.
327 * +2: This is a good patch and should be pushed as is.
328 * Maintainer: Currently only PMC members are maintainers. At least one
329 maintainer must review your patch and give it a +1 before it can be merged.
330 * Verified: This is automatically generated from the continuous integrated
331 (CI) tests. Each patch must receive at least a +1 from the CI tests before
332 the patch can be merged. The patch will receive a +1 if gem5 builds and
333 runs, and it will receive a +2 if the stats match.
334 * Style-Check: This is automatically generated and tests the patch against the
335 gem5 code style (http://www.gem5.org/Coding_Style). The patch must receive a
336 +1 from the style checker to be pushed.
337
338 Note: Whenever the patch creator updates the patch all reviewers must re-review
339 the patch. There is no longer a "Fix it, then Ship It" option.
340
341 Once you have received reviews for your patch, you will likely need to make
342 changes. To do this, you should update the original git changeset. Then, you
343 can simply push the changeset again to the same Gerrit branch to update the
344 review request.
345
346 ```
347 git push origin HEAD:refs/for/master
348 ```
349
350 Committing changes
351 ==================
352
353 Each patch must meet the following criteria to be merged:
354 * At least one review with +2
355 * At least one maintainer with +1
356 * At least +1 from the CI tests (gem5 must build and run)
357 * At least +1 from the style checker
358
359 Once a patch meets the above criteria, the submitter of the patch will be able
360 to merge the patch by pressing the "Submit" button on Gerrit. When the patch is
361 submitted, it is merged into the public gem5 branch.
362
363 Review moderation and guidelines
364 --------------------------------
365
366 Once a change is submitted, reviewers shall review the change. This may require
367 several iterations before a merge. Comments from reviewers may include
368 questions, and requests for alterations to the change prior to merging. The
369 overarching philosophy in managing this process is that there should be
370 politeness and clear communication between all parties at all times, and,
371 whenever possible, permission should be asked before doing anything that may
372 inconvenience another party. Included below are some guidelines we expect
373 contributors and reviewers to follow.
374
375 * In all forms of communication, contributors and reviewers must be polite.
376 Comments seen as being needlessly hostile or dismissive will not be
377 tolerated.
378 * Change contributors should respond to, or act upon, each item of feedback
379 given by reviewers. If there is disagreement with a piece of
380 feedback, a sufficiently detailed reason for this disagreement should
381 be given. Polite discussion, and sharing of information and expertise
382 is strongly encouraged.
383 * Contributors are advised to assign reviewers when submitting a change.
384 Anyone who contributes to gem5 can be assigned as a reviewer. However,
385 all changes must be accepted by at least one maintainer prior to a
386 merge, ergo assigning of at least one maintainer as a reviewer is
387 strongly recommended. Please see MAINTAINERS for a breakdown of
388 gem5 maintainers and which components they claim responsibility for.
389 Maintainers should be chosen based on which components the change is
390 targeting. Assigning of reviewers is not strictly enforced, though not
391 assigning reviewers may slow the time in which a change is reviewed.
392 * If a contributor posts a change and does not receive any reviews after two
393 working days (excluding regional holidays), it is acceptable to "prod"
394 reviewers. This can be done by adding a reply to the changeset review
395 (e.g., "Would it be possible for someone to review my change?"). If the
396 contributor has yet to assign reviewers, they are strongly advised to do so.
397 Reviewers will get notified when assigned to referee a change.
398 * By default, the original contributor is assumed to own a change. I.e.,
399 they are assumed to be the sole party to submit patchsets. If someone
400 other than the original contributor wishes to submit patchsets to a
401 change on the original contributor's behalf, they should first ask
402 permission. If two working days pass without a response, a patchset may be
403 submitted without permission. Permission does not need to be asked to submit
404 a patchset consisting of minor, inoffensive, changes such a typo and format
405 fixes.
406 * Once a change is ready to merge, it enters a "Ready to Submit" state. The
407 original contributor should merge their change at this point, assuming they
408 are content with the commit in its present form. After two working days, a
409 reviewer may message a contributor to remind them of the change being in a
410 "Ready to Submit" state and ask if they can merge the change on the
411 contributors behalf. If a further two working days elapse without a
412 response, the reviewer may merge without permission. A contributor may keep
413 a change open for whatever reason though this should be communicated to the
414 reviewer when asked.
415 * After a month of inactivity from a contributor on an active change, a
416 reviewer may post a message on the change reminding the submitter, and
417 anyone else watching the change, of its active status and ask if they are
418 still interested in eventually merging the change. After two weeks of no
419 response the reviewer reserves the right to abandon the change under the
420 assumption there is no longer interest.
421 * The final arbiter in any dispute between reviewers and/or contributors
422 is the PMC (PMC members are highlighted in MAINTAINERS). Disputes requiring
423 intervention by the PMC are undesirable. Attempts should be made to resolve
424 disagreements via respectful and polite discourse before being escalated to
425 this level.