Upstrem Method

This page describes the method of working with the crosstool-NG (hi Yann!) upstream.

The problems are:

  • tooling: upstream uses Mercurial; we use bzr or git
  • non-upstream patches: some necessary changes aren't upstreamable
  • local patches: some patches only make sense locally

In general we work upstream and use upstream's methods. Upstream is responsive (< 1 week), does frequent releases, and either accepts patches or provides a good reason why not.


  1. Create and test the patch locally
  2. Commit using a message in the upstream style like:
    • debug/config: Add strace-4.6
      Now that xz support is in crosstool-ng, Add strace-4.6.
      Signed-off-by: Bryan Hundven <>
  3. Send the patch using hg email like

    • hg email --to '"Yann E. MORIN" <yann.morin.1998 at-fixme>' --cc '' --cc '' -n -r 1234

      Note that the -n means dry run and lets you check the patch before sending. Don't forget to cc

  4. Once upstream has reviewed and committed it, backport to the Linaro branch.


  1. Start with your local clone of the upstream repo
  2. Turn the upstream commit into a patch
  3. Change to your bzr checkout
  4. Update
  5. Apply the patch
  6. Commit using a message like:
    • debug/config: Add strace-4.6 (backport)
      Backport r1234.
      Note that the first line comes from the upstream commit with '(backport)' on the end. The body lists just the revision that was backported.
  7. Push

Or, blow by blow:

michaelh@crucis:~/linaro/binary/crosstool-ng$ hg log | head -n 30
changeset:   2792:49af7802dcd5
tag:         tip
user:        Titus von Boxberg <>
date:        Tue Nov 22 10:08:10 2011 +0100
summary:     scripts/functions: extract: portable call for old and defective tars

changeset:   2791:258160822e35
user:        Zhenqiang Chen <>
date:        Wed Nov 23 13:15:27 2011 +0800
summary:     debug/gdb: add extra config for gdb cross.

(we want to backport r2791)

Create the patch:

michaelh@crucis:~/linaro/binary/crosstool-ng$ hg diff -c 2791 |tee ../tmp.diff
diff -r 2f4e3c312b65 -r 258160822e35 config/debug/
--- a/config/debug/ Tue Nov 22 14:18:14 2011 +0800
+++ b/config/debug/ Wed Nov 23 13:15:27 2011 +0800
@@ -38,5 +38,12 @@
       Building a static gdb can help in this regard, although there
       have been reports of problems when linking gdb to the static
       libpython.a. This should be fixed in gdb >=7.3. YMMV.
+    string
+    prompt "Cross-gdb extra config"
+    default ""
+    help
+      Extra flags to pass onto ./configure when configuring the gdb cross.
 endif # GDB_CROSS
diff -r 2f4e3c312b65 -r 258160822e35 scripts/build/debug/
--- a/scripts/build/debug/    Tue Nov 22 14:18:14 2011 +0800
+++ b/scripts/build/debug/    Wed Nov 23 13:15:27 2011 +0800
@@ -147,7 +147,8 @@
             --with-sysroot="${CT_SYSROOT_DIR}"          \
             --with-expat=yes                            \
             --disable-werror                            \
-            "${cross_extra_config[@]}"
+            "${cross_extra_config[@]}"                  \
+            "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}"
         CT_DoLog EXTRA "Building cross-gdb"
         CT_DoExecLog ALL make ${JOBSFLAGS}

Update and apply the patch:

michaelh@crucis:~/linaro/binary/linaro$ bzr pull
Using saved parent location: bzr+ssh://
No revisions to pull.      

michaelh@crucis:~/linaro/binary/linaro$ bzr patch -p1 ../tmp.diff

michaelh@crucis:~/linaro/binary/linaro$ bzr status

Commit and push:

michaelh@crucis:~/linaro/binary/linaro$ bzr commit

debug/gdb: add extra config for gdb cross (backport)
Backport r2791.

Committing to: /home/michaelh/linaro/binary/linaro/                                                                                                                                                             
modified config/debug/
modified scripts/build/debug/
Committed revision 2261.

michaelh@crucis:~/linaro/binary/linaro$ bzr push
Using saved push location: bzr+ssh://
Pushed up to revision 2261.                                                                                   

Local patches

Local patches use the same style as upstream. Append '(local)' to the end of the first line of the commit so we can tell them apart.

WorkingGroups/ToolChain/BinaryBuild/UpstreamMethod (last modified 2011-11-27 20:52:17)