This is an archive of the discontinued LLVM Phabricator instance.

docs: Add instructions for stand-alone builds of clang
ClosedPublic

Authored by tstellar on Apr 18 2022, 4:52 PM.

Details

Summary

More sub-projects will be added to the table once they have been verified
to be buildable in stand-alone mode.

Diff Detail

Event Timeline

tstellar created this revision.Apr 18 2022, 4:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 4:52 PM
tstellar requested review of this revision.Apr 18 2022, 4:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 4:52 PM

Sorry it took me a while to respond, was AFK last week. This looks like a good start, I can try testing the instructions with the LLVM 15 builds (also RCs) and report back with what I find.

llvm/docs/GettingStarted.rst
142

Isn't CLANG_BUILT_STANDALONE also necessary (honest question)?

mgorny added a subscriber: mgorny.Oct 28 2022, 12:07 AM
mgorny added inline comments.
llvm/docs/GettingStarted.rst
142

In Gentoo, we also check llvm/lib/Transforms/Hello out unconditionally (don't recall why we added it, maybe it's not needed anymore, gotta check at some point), and llvm/lib/Testing/Support and llvm/utils for tests.

MaskRay added inline comments.
llvm/docs/GettingStarted.rst
130

What files are needed for the llvm installation? LLVM_ENABLE_PROJECTS=llvm with everything installed by ninja install ?

132

Add backsticks for /usr/bin, -D, etc.

Is Clang_DIR worth mentioning? See https://lldb.llvm.org/resources/build.html#standalone-builds

tstellar updated this revision to Diff 471601.Oct 28 2022, 11:06 AM

Add a section about how to build LLVM so that it is consumable by
stand-alone builds, and fix some formatting.

tstellar marked an inline comment as done.Oct 28 2022, 11:07 AM
tstellar added inline comments.
llvm/docs/GettingStarted.rst
130

I updated the patch now with instructions about how to build LLVM.

132

Is Clang_DIR worth mentioning? See https://lldb.llvm.org/resources/build.html#standalone-builds

I will mention this if/when I add documention for lldb, but it's not needed for the clang builds.

142

Transforms/Hello is only needed if you build clang-tools-extra (which is not enabled with these instructions). I also have a patch to make the D120301.

Testing/Support is only needed for the unittests which aren't run in the documented configuration (because there is no googletest).

I don't think llvm/utils is needed after https://github.com/llvm/llvm-project/commit/74384c7fcec71cb040b0c874743e5fc38b2cd7a6

This documentation is for the most minimal config that I could get working without any additional changes, so no clang-tools-extra and no unittests.

142

Isn't CLANG_BUILT_STANDALONE also necessary (honest question)?

No, this value is auto-detected based on the source layout.

MaskRay accepted this revision.EditedOct 28 2022, 12:15 PM

LGTM, but worth getting opinions from actual standalone (stand-alone) build users

llvm/docs/GettingStarted.rst
110

I just read https://brians.wsu.edu/2016/05/31/standalone-stand-alone/

When one greps in llvm-project, which word do they more likely use, standalone or stand-alone? I tend to use standalone. Then I checked git shortlog -sn --grep standalone and git shortlog -sn --grep stand-alone. The former is more popular while the latter is not too uncommon...

134

Does install-distribution with LLVM_DISTRIBUTION_COMPONENTS work? From the name, LLVM_DISTRIBUTION_COMPONENTS is recommended for distributions and standalone builds are preferred by distributions.

144
146

Is the formal CMake term "variable" instead of "option"?

157

You may check what flang requires and make the second column sufficiently long to accommodate its needs.

This revision is now accepted and ready to land.Oct 28 2022, 12:15 PM
tstellar updated this revision to Diff 471626.Oct 28 2022, 12:36 PM
tstellar marked an inline comment as done.

More formatting fixes.

tstellar added inline comments.Oct 28 2022, 12:38 PM
llvm/docs/GettingStarted.rst
110

I agree we should be consistent, but I have not preference about which spelling to use.

134

For Fedora, we don't use LLVM_DISTRIBUTION_COMPONENT, mainly because we already install everything, but also because it's very hard to keep the variable updated when new things are added. My concern with using it is that we would easily miss new features.

146

Technically, those are both variables internally, but the cmake man page refers to anything passed to cmake command line as an option.

157

This is going to take a lot of work to figure out, maybe I can just make the column 20 chars longer? I think ideally flang would require just cmake, but I don't have any experience trying to do a stand-alone build.

mgorny added inline comments.Oct 29 2022, 11:07 AM
llvm/docs/GettingStarted.rst
142

Testing/Support is only needed for the unittests which aren't run in the documented configuration (because there is no googletest).

Well, I don't want to hijack your effort but I think unittests are quite important if we're running tests in the first place, and I don't recall needing anything "that special" to run them these days — just llvm/lib/Testing/Support and llvm/utils/{lit,llvm-lit,unittest} (however, given its size I suppose we could just take whole llvm/utils).

tstellar added inline comments.Oct 31 2022, 9:23 AM
llvm/docs/GettingStarted.rst
142

Enabling and documenting the unit tests are something that I'm planning to do, but I wanted to get the minimal configuration documentation done first. I also want to find a solution that doesn't involve having source from the llvm directory available, which will take some time. See D131919.

@mgorny Are you OK with this as is for now?

MaskRay added inline comments.Nov 10 2022, 9:20 AM
llvm/docs/GettingStarted.rst
136
MaskRay accepted this revision.Nov 10 2022, 9:21 AM
MaskRay added inline comments.
llvm/docs/GettingStarted.rst
112

There is usually one blank line after the header.

This revision was landed with ongoing or failed builds.Nov 10 2022, 12:29 PM
This revision was automatically updated to reflect the committed changes.
tstellar marked 2 inline comments as done.