Updating From Outside Sources

The ELLCC project uses several open source projects together to make a cross development environment. These projects include:

  • binutils – Assemblers, linkers, and various utilities for manipulating object files.
  • clang – The LLVM based C/C++/Objective-C/Objective-C++ compiler front end.
  • compiler-rt – The low level support library for handling of things, like floating point numbers, that a particular target may not support in hardware.
  • gdb – The source level debugger.
  • llvm – The compiler back end.
  • qemu – The target emulator.

One of the problems with a project like this is that you’d like to stay up to date with changes to outside projects. I’ll describe how I do this for the LLVM relates projects clang, compiler-rt, and llvm. Subversion is used as the source code control system for ELLCC, so the following procedures are subversion specific.

For all the outside projects that I use or reference I keep a copy of the sources that I never edit. I keep them in my ~/vendor directory:

[~/vendor] main% ls
binutils/ clang/ gdb/ glibc-2.12.2/ linux-2.6.36.1/ ptmalloc3/ src/ u-boot/
bzip2-1.0.6/ compiler-rt/ getvendor* lastrev llvm/ qemu/ tcsh-6.17.00/
[~/vendor] main%

I’ll go ahead and get the latest stuff from llvm, etc.:

[~/vendor] main% cd llvm
[~/vendor/llvm] main% svn update
...
U examples/Kaleidoscope/Chapter6/toy.cpp
U examples/Kaleidoscope/Chapter7/toy.cpp
U examples/ExceptionDemo/ExceptionDemo.cpp
Updated to revision 131667.
[~/vendor/llvm] main% cd ../clang/
[~/vendor/clang] main% svn update
...
U lib/Parse/ParseDeclCXX.cpp
U lib/Parse/ParseExprCXX.cpp
Updated to revision 131667.
[~/vendor/clang] main% cd ../compiler-rt/
[~/vendor/compiler-rt] main% svn update
...
U make/platform/darwin_bni.mk
U make/platform/clang_darwin.mk
Updated to revision 131667.
[~/vendor/compiler-rt] main%

At this point I make a note of the version number I’ve updated to (131667) so I can use it for labeling the updated code in my repository.

The next step is to import the changes into the ELLCC repository’s copy of the vendor code. I have a short script that does it for the llvm stuff:

#! /bin/sh
if [ $# -ne 2 ] ; then
echo "$0: <revision> <password>"
exit 1
fi
/usr/share/doc/subversion-1.6.16/svn_load_dirs.pl -svn_username rich -svn_password $2 -t svn-$1 http://ellcc.org/svn/vendor/llvm current llvm
/usr/share/doc/subversion-1.6.16/svn_load_dirs.pl -svn_username rich -svn_password $2 -t svn-$1 http://ellcc.org/svn/vendor/clang current clang
/usr/share/doc/subversion-1.6.16/svn_load_dirs.pl -svn_username rich -svn_password $2 -t svn-$1 http://ellcc.org/svn/vendor/compiler-rt current compiler-rt
echo $1 >lastrev

This script takes two arguments, the vendor version number that was just picked up, and the password for the subversion repository.
In this case I’d use:

[~/vendor] main% ./getvendor 131667 XXXXXXXX

Where XXXXXXXX is the real repository password.

The ELLCC project keeps the vendor code tagged by revision, so for llvm, the repository looks like this:

svn - Revision 2434: /vendor/llvm
* ..
* current/
* svn-119910/
* svn-121798/
* svn-122630/
* svn-122785/
* svn-122854/
* svn-122855/
* svn-122942/
* svn-122956/
* svn-124532/
* svn-126041/
* svn-126579/
* svn-127082/
* svn-127564/
* svn-127949/
* svn-131667/

Note that we now have a tag called svn-131667. The previous tagged version was svn-127949, The next steps will update the actual code in the ELLCC source code with the differences between these two versions. The next commands should be executed in a checkout of the latest trunk ellcc. I usually checkout the latest ellcc trunk in ~/ellcc, so the commands I use to merge are:

[~/vendor] main% cd ~/ellcc
[~/ellcc] main% ./mergellvm 127949


The mergellvm script looks like this:

#! /bin/sh
if [ $# -ne 1 ] ; then
echo "$0: <revision>"
exit 1
fi
svn merge --accept edit http://ellcc.org/svn/vendor/llvm/svn-$1 http://ellcc.org/svn/vendor/llvm/current llvm
cd libecc/src
svn merge --accept edit http://ellcc.org/svn/vendor/compiler-rt/svn-$1 http://ellcc.org/svn/vendor/compiler-rt/current compiler-rt
cd ../../llvm/tools
svn merge --accept edit http://ellcc.org/svn/vendor/clang/svn-$1 http://ellcc.org/svn/vendor/clang/current clang

If you encounter any merge conflicts the offending file will be opened in an editor.
Search for the merge conflicts, with e.g. (in vi) “/<<<<<":
<<<<<<< .working case llvm::Triple::ppc64: return *(TheTargetCodeGenInfo = new PPC64TargetCodeGenInfo(Types)); ======= case llvm::Triple::ptx32: case llvm::Triple::ptx64: return *(TheTargetCodeGenInfo = new PTXTargetCodeGenInfo(Types)); >>>>>>> .merge-right.r2434

In this case the resolved merge becomes:

case llvm::Triple::ppc64:
return *(TheTargetCodeGenInfo = new PPC64TargetCodeGenInfo(Types));
case llvm::Triple::ptx32:
case llvm::Triple::ptx64:
return *(TheTargetCodeGenInfo = new PTXTargetCodeGenInfo(Types));

After you finish editing, subversion will ask if the conflict has been resolved. Answer yes.

Leave a Reply

Your email address will not be published.