This is an archive of the discontinued LLVM Phabricator instance.

[docs] Add a new tutorial that talk about how to make a change to llvm.
AcceptedPublic

Authored by xzq0528 on Apr 17 2021, 8:38 PM.

Details

Summary

This tutorial will guide you through the process of making a change to LLVM, and contributing it back to the LLVM project.
We'll be making a change to Clang, but the steps for other parts of LLVM are the same.Even though the change we'll be making is simple,
we're going to cover steps like building LLVM, running the tests, and code review. This isgood practice, and you'll be prepared for making larger changes.

Authors: Mikhail Goncharov
Commit: Zhiqian Xia

Diff Detail

Event Timeline

xzq0528 created this revision.Apr 17 2021, 8:38 PM
xzq0528 requested review of this revision.Apr 17 2021, 8:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2021, 8:38 PM

LGTM, thx for converting this!
I guess we should also link to this tutorial from the getting involved page, what do you think?

@meikeb , @gribozavr can you please take a look?

kuhnel accepted this revision.Apr 19 2021, 4:43 AM
This revision is now accepted and ready to land.Apr 19 2021, 4:43 AM
xgupta accepted this revision.Apr 19 2021, 5:52 AM
xgupta added a subscriber: xgupta.

Very useful tutorial.

xgupta added inline comments.Apr 19 2021, 6:55 AM
llvm/docs/MyFirstTypoFix.rst
61

nit - clang -> Clang, gcc -> GCC

117

nit - a comma after Usually

189

nit - a comma after In ninja and space before If

198

nit - space before When

232

nit - space after in this case

233

nit - space before Let's

290

space before Instead

291

nit - space before `There'

371

space is needed after D58291

380

kind -> kinds

393

space before Note

428

space before The reviewer and Leave

459

-dev is not clear I think, maybe cfe-dev or respective dev understood better.

484

space before The

494

space before At missing.

522
529

Again git push https://github.com/llvm/llvm-project.git HEAD:main recommended here see above doc.

531

space before You

I tried applying this patch on my local repository, an error message comes during make docs-llvm-html-

Warning, treated as error:
/home/xgupta/llvm-project/llvm/docs/MyFirstTypoFix.rst:document isn't included in any toctree
make[3]: *** [docs/CMakeFiles/docs-llvm-html.dir/build.make:77: docs/CMakeFiles/docs-llvm-html] Error 2
make[2]: *** [CMakeFiles/Makefile2:244554: docs/CMakeFiles/docs-llvm-html.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:244561: docs/CMakeFiles/docs-llvm-html.dir/rule] Error 2
make: *** [Makefile:47070: docs-llvm-html] Error 2

@xzq0528 could you please fix it?

llvm/docs/MyFirstTypoFix.rst
325

Beginners often forget to add a tag like for this patch Zhiqian didn't add [Docs] tag :)
Should be mention here.

please replace every instance of master to main where appropriate.

llvm/docs/MyFirstTypoFix.rst
518

master is switch to main

mehdi_amini added inline comments.
llvm/docs/MyFirstTypoFix.rst
129

For development purpose, I'd advise enabling assertions: -DLLVM_ENABLE_ASSERTIONS=ON.
(this is the default in DEBUG builds, but since you're enabling release build here...)

369–370

This is automatic in Phabricator I believe: the relevant list will be added based on the path in the monorepo.

438

Seems like some other docs should be linked from this docs in the relevant sections, I don't see a ref to https://llvm.org/docs/CodeReview.html or https://llvm.org/docs/CodeReview.html for example.

( But also below in the revert section which like could link https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy )

mehdi_amini added inline comments.Apr 20 2021, 12:56 PM
llvm/docs/MyFirstTypoFix.rst
325

Is there a reference in an existing doc about the use of tags? I'm not sure we should tell beginners about things that aren't our documented norms.
(I don't use any tag other than "NFC")

325

(I wouldn't see the need to add a tag to this very clear and explicit commit title for example)

xgupta added inline comments.Apr 20 2021, 8:16 PM
llvm/docs/MyFirstTypoFix.rst
325

So It depends on the person, LLVM Project is large with around 100 commits a day. I don't read the complete line of commit/patch. A tag is useful for me.

So if it is not documented, we can document it. Otherwise, I left this on other reviewers and patch author to decide what is best.

mehdi_amini added inline comments.Apr 20 2021, 8:18 PM
llvm/docs/MyFirstTypoFix.rst
325

Regardless, this seems to me to be out-of-line for a tutorial to define new conventions.

dblaikie added inline comments.
llvm/docs/MyFirstTypoFix.rst
325

Eh, I disagree a bit here - it's the sort of feedback I'd give someone on the mailing list, so might as well write it down here - can be written down other places too.

mehdi_amini added inline comments.Apr 21 2021, 4:19 PM
llvm/docs/MyFirstTypoFix.rst
325

You're not clear with what you are disagreeing exactly: there is my point that a tutorial should not introduce new conventions, and whether in this case this is a documented convention or something that we've been consistently doing for a while.

We can talk about the latter, but I disagree that this is a settled thing which goes back to my former point: this isn't the revision to settle this.

(to expand a bit, even if this is out-of-scope for this revision I belive: this practice seems like a recent thing people have been doing, and it hasn't been introduced in a coordinated way and without clear guidelines as far as I know. In practice I see this as *noise* and I disagree that this a good use of the commit title limited space. (common guidelines are for git commit titles to be *short*))

dblaikie added inline comments.Apr 21 2021, 4:38 PM
llvm/docs/MyFirstTypoFix.rst
325

Sorry, to be clear: I disagree that documenting the convention of using tags is inappropriate for this documentation at this time.

Tags have been used in commit descriptions from before the commit message was used in email titles (previously the title was a list of the files touched - so the title gave some sense of what part of the project the patch related to - albeit rather roughly/poorly) - but they're even more useful since that change (~8 years ago), eg: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20130128/163757.html

But sure, if you fundamentally object to it being done in this patch, so be it.

mehdi_amini added inline comments.Apr 21 2021, 4:44 PM
llvm/docs/MyFirstTypoFix.rst
325

Yeah I fundamentally object to a tutorial introducing recommendation for this while there is no documentation and guidelines for it.
If you want to propose a documentation for a guideline regarding this, why not, but please do as a separate patch and make sure it is documented outside of a tutorial.

dblaikie added inline comments.Apr 21 2021, 4:51 PM
llvm/docs/MyFirstTypoFix.rst
325

My perspective is that this would be a fine place to include such a suggestion (I don't think as an explicit statement of what you must do, but as a suggestion of some things people do if you think that might clarify things, etc) - in the same way I would in mailing list usage (& have, several times - asking people to flag NFC changes as such as it makes it easier to review). I don't think everything in this document has to be (& I doubt it is, though I haven't read the whole thing) only things that are already formalized in other documentation. (for instance the heuristics mentioned under "Commit access" don't seem to be documented elsewhere - but I don't object to them either, I think it's reasonable to describe to newcomers some norms about how people generally interact in the community))

kuhnel added inline comments.Apr 27 2021, 9:07 AM
llvm/docs/MyFirstTypoFix.rst
325

Does someone have a (complete) list of tags to be used and their semantics?

kuhnel added inline comments.Apr 27 2021, 9:16 AM
llvm/docs/MyFirstTypoFix.rst
325

Just looked at the commit history: https://github.com/llvm/llvm-project/commits/main

I can't really see a consistent set of tags people are using. Sometimes it's sub-prrojects (e.g. mlir, clangd) or architectures (ARM, x86) or features or change semantic (NFC). So I guess it would be hard to explain how to pick the right tag.

IMHO the only thing we can say here is that they exist and contributors should try to guess something reasonable...

nikic added a subscriber: nikic.Apr 27 2021, 9:20 AM
nikic added inline comments.
llvm/docs/MyFirstTypoFix.rst
431

This is missing Please use "My Name <my@email>" to commit the change.

481

This looks outdated?

dblaikie added inline comments.Apr 27 2021, 10:40 AM
llvm/docs/MyFirstTypoFix.rst
325

It's fairly informal - NFC, target (if it's in a target backend), specific optimization, or general library (ADT, Support, etc) or feature area (DebugInfo) are probably the broad categories.

But I'm not adamant this must be in the document - I'm a bit middle of the road. I don't think missing a tag is necessarily "forgetting" to do something that's required, nor that adding them is problematic or harmful either.

Seems easy enough to leave them out for now if they weren't added - or include it in the example commit message without necessarily any indicator that they must be included or a whole paragraph about them either.

PIng @xzq0528 for addressing the comments.

xzq0528 updated this revision to Diff 343537.May 6 2021, 4:58 PM
xzq0528 marked 35 inline comments as done.
xzq0528 retitled this revision from Add a new tutorial that talk about how to make a change to llvm. to [docs] Add a new tutorial that talk about how to make a change to llvm..
  1. add some space for readability.
  2. add some description for tags.
  3. update some outdated content: such as origin/master to origin/main, svn tool to git tool.
  4. add the link to https://llvm.org/docs/CodeReview.html.
xgupta added inline comments.May 7 2021, 9:12 AM
llvm/docs/MyFirstTypoFix.rst
325

@xzq0528 Actually, here a [Diagnostic] tag would be appropriate, instead of [Docs] one.

kuhnel accepted this revision.May 10 2021, 6:54 AM
gribozavr2 accepted this revision.May 10 2021, 12:15 PM
gribozavr2 added a subscriber: gribozavr2.
gribozavr2 added inline comments.
llvm/docs/MyFirstTypoFix.rst
3

I'd suggest removing automatically numbered header-ABCD links, I don't think other documents do this. Sphinx will generate a link based on the section title.

xzq0528 updated this revision to Diff 345116.May 13 2021, 6:19 AM
xzq0528 marked 2 inline comments as done.
  1. Remove the automatically numbered header.
  2. Instead of tags [Docs] with [Diagnostic] at line 324.
xzq0528 updated this revision to Diff 345119.May 13 2021, 6:32 AM
xzq0528 updated this revision to Diff 345121.May 13 2021, 6:41 AM

I guess we should also link to this tutorial from the getting involved page, what do you think?

@xzq0528 I think you need to address this comment in this patch. because of it following warning/error is generating during build

Warning, treated as error:
/home/xgupta/llvm-project/llvm/docs/MyFirstTypoFix.rst:document isn't included in any toctree
make[3]: *** [docs/CMakeFiles/docs-llvm-html.dir/build.make:77: docs/CMakeFiles/docs-llvm-html] Error 2
make[2]: *** [CMakeFiles/Makefile2:244554: docs/CMakeFiles/docs-llvm-html.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:244561: docs/CMakeFiles/docs-llvm-html.dir/rule] Error 2
make: *** [Makefile:47070: docs-llvm-html] Error 2```.
xgupta added inline comments.May 14 2021, 2:31 AM
llvm/docs/MyFirstTypoFix.rst
325

@xzq0528 Actually, here a [Diagnostic] tag would be appropriate, instead of [Docs] one.

this comment is still not done?

xgupta resigned from this revision.May 17 2021, 11:26 AM
xgupta added inline comments.
llvm/docs/MyFirstTypoFix.rst
325

Is there a reference in an existing doc about the use of tags? I'm not sure we should tell beginners about things that aren't our documented norms.
(I don't use any tag other than "NFC")

This [Tag] guideline is documented here: https://llvm.org/docs/DeveloperPolicy.html#commit-messages

I guess we should also link to this tutorial from the getting involved page, what do you think?

@xzq0528 I think you need to address this comment in this patch. because of it following warning/error is generating during build

Warning, treated as error:
/home/xgupta/llvm-project/llvm/docs/MyFirstTypoFix.rst:document isn't included in any toctree
make[3]: *** [docs/CMakeFiles/docs-llvm-html.dir/build.make:77: docs/CMakeFiles/docs-llvm-html] Error 2
make[2]: *** [CMakeFiles/Makefile2:244554: docs/CMakeFiles/docs-llvm-html.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:244561: docs/CMakeFiles/docs-llvm-html.dir/rule] Error 2
make: *** [Makefile:47070: docs-llvm-html] Error 2```.

 I will check it as soon as possible.
llvm/docs/MyFirstTypoFix.rst
3

i'll remove it later. Thank you.

325

@xgupta thank you for pointing out the issue.

438

Thanks for your helpful sugeestions, I'll add it later.

481

Thanks for point out the issue.

xzq0528 updated this revision to Diff 347404.May 24 2021, 8:29 AM

adding the docs into toctree.

xgupta added a comment.Jun 9 2021, 2:32 AM

Thank you Zhiqian for updating the revision. But now I am not able to apply patch ( using arc patch D100714) to check the doc build.
Otherwise everything is fine and ready to commit IMO.

I think you should upload the patch with full context by git diff HEAD~1 -U999999 > mypatch.patch, please see the phabricator documentation.

maybe that was the reason of failed to apply patch error. The error I am getting is

Checking patch llvm/docs/GettingStartedTutorials.rst...
error: while searching for:

GettingStartedVS
ProgrammersManual
tutorial/index

:doc:GettingStarted

Discusses how to get up and running quickly with the LLVM infrastructure.

error: patch failed: llvm/docs/GettingStartedTutorials.rst:12
error: while searching for:

on Windows.

:doc:CompilerWriterInfo

A list of helpful links for compiler writers.

error: patch failed: llvm/docs/GettingStartedTutorials.rst:35
Applied patch llvm/docs/MyFirstTypoFix.rst cleanly.
Applying patch llvm/docs/GettingStartedTutorials.rst with 2 rejects...
Rejected hunk #1.
Rejected hunk #2.

Patch Failed!

llvm/docs/MyFirstTypoFix.rst
170

$ is missing in the beginning.

229

$ is missing in the beginning.

254

$ is missing in the beginning.

275

$ is missing in the beginning.

@xzq0528 and @meikeb I have send a draft (only did copy) revision for this patch in https://reviews.llvm.org/D108267 and fix the above mention error. If you have no objection we can commit from there as I thought It is a very useful tutorial, should be landed earlier.

@xgupta thx for moving forward on this patch.
I fully agree that the tutorial is useful in the current version already and we also improve it after it's publication.

It's probably easier to discuss small modifications after we landed the basic tutorial.

kwk added a subscriber: kwk.Oct 1 2021, 3:14 AM
kwk added inline comments.
llvm/docs/MyFirstTypoFix.rst
71

@kuhnel ehm, isn't this a bit outdated? I mean we no longer have to use subversion.

kuhnel added inline comments.Oct 1 2021, 3:53 AM
llvm/docs/MyFirstTypoFix.rst
71

This was fixed already in the current version:
https://llvm.org/docs/MyFirstTypoFix.html