[llvm-dev] git strategy for handling the llvm-project repo together with ours
Geoffrey Martin-Noble via llvm-dev
llvm-dev at lists.llvm.org
Fri May 7 10:55:20 PDT 2021
To avoid the issue of constantly having to rewrite history, you could merge
from your main branch instead of rebasing. If I was contributing to a
project and I constantly had to drop my local history, I'd probably be a
bit grumpy. You lose the benefit of your entire stream of patches being
based on HEAD, but I'm guessing that eventual upstreaming wouldn't be
merging things in the historical order of patches anyway? (but maybe I'm
wrong, I've never upstreamed a target). Merge commits get a bad rap, but I
think they're actually quite a useful tool in git when used judiciously,
and if you know about `git log --first-parent` most of people's complaints
about them are handled.
On Fri, May 7, 2021 at 9:42 AM Min-Yih Hsu via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi,
>
> On Fri, May 7, 2021 at 5:52 AM <paul.robinson at sony.com> wrote:
>
>> > Dear all,
>> >
>> > we are integrating support in Clang + LLVM for a target architecture (an
>> > accelerator device) we are developing. Currently, we have a git
>> > repository, which contains LLVM 9 together with the added/changed files
>> > from us.
>> >
>> > Now, we want to have a sustainable strategy for handling the
>> > llvm-project repository together with our changes. To summarize, we want
>> > to migrate to LLVM 12, start with 12.0.0, add our target architecture
>> > support based on this version, continue development of our target, and
>> > from time to time get the latest changes from the official llvm-project
>> > repo so we keep up to date over time.
>> >
>> > Hence, we somehow have to "merge" the llvm-project and our repository,
>> > and keep history of both. As far as I know, there are several ways we
>> > could do this, e.g. using submodules or subtree merge.
>
>
>> I haven't personally had to deal with a new target, so someone who
>> has done it might have different suggestions. I've cc'd Min who
>> seems to be the one driving the recent addition of the M68K target,
>> which is the most recent new target added to LLVM.
>>
>
> Yes, we actually had the exact same problem when we tried to migrate from
> LLVM 8 or so to mono repo. We used a script back then:
> https://github.com/M680x0/M680x0-llvm/issues/58
> But note that this script only does ~70% of the work. I still spent quite
> some time doing some migrations manually and cleaning up.
>
>
>>
>> I do have extensive experience with managing downstream changes and
>> handling merges, so I have suggestions based on that experience.
>>
>> In your situation, I think the simplest way to manage your changes
>> is to start with a clone of upstream LLVM, which has its 'main'
>> branch. Then create a 'target' branch off of 'main' and do all your
>> work on 'target'. When you decide to update to a new revision of
>> LLVM, you use 'git pull' to update 'main', and then *rebase* your
>> 'target' branch. This tactic keeps all your changes at HEAD, with
>> history intact, which vastly simplifies figuring out where bugs
>> have come from. It would also be straightforward to move from a
>> rare pull/rebase to doing this more frequently, which will reduce
>> the "merge pain" of each pull/rebase.
>>
>
> Second this approach. This is also roughly what I did before M68k got
> upstreamed. It's also easier for you to collect patches if you plan to
> upstream your target in the future (just pick commits on the tip of your
> target branch). The only (little) downside was that there were some users
> who wanted to try our tree and using rebase meant that they needed to `git
> pull --force` every time they updated.
>
>
>>
>> I do *not* recommend what we (Sony) did, which is to keep our
>> changes intermixed with upstream changes. That decision was made
>> too long ago to do anything about it with practical cost. We have
>> an automated merge system to keep ourselves continually updated to
>> upstream HEAD, which is an ongoing maintenance cost but much much
>> better than trying to do the same thing once every six months or so.
>>
>> More about how we operate can be found here:
>> https://llvm.org/devmtg/2015-10/#tutorial4
>>
>> > In the future, if support for our target architecture is mature, and the
>> > hardware is publicly available, for us it would be interesting to have
>> > our target support in the official llvm-project repository, in which
>> > case our additions potentially would have to go into the official repo.
>>
>>
> Upstream the target is another whole story. I can provide some tips and
> suggestions on this matter when you decide to do so.
>
> Best
> -Min
>
>
>> This is another reason to try to keep your downstream changes at HEAD.
>> It will be much easier to post your new target's patches if you are
>> already based on top of 'main'.
>
>
>> Best Regards,
>> --paulr
>>
>>
>
> --
> Min-Yih Hsu
> Ph.D Student in ICS Department, University of California, Irvine (UCI).
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210507/799efd9d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3992 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210507/799efd9d/attachment-0001.bin>
More information about the llvm-dev
mailing list