How to Test a GCC Patch Using RSB

You have a GCC patch and want to test it using RTEMS source builder (RSB)? There are multiple options.

Note: This started as a Discord discussion.

I usually use the first method (Hacking in a Patch in RSB). I didn’t personally test the second method. If someone has a better method: Let me know.

Hacking in a Patch in RSB

One possibility is to just add it as a patch in RSB. This is a quick and dirty solution.

  1. Create the gcc patch. Add it to RSB as rtems/patches/my-gcc-patch.patch (with a better name). Note that you have to force-add a file there if you want to have it commited because this directory is usually ignored by a .gitignore file.
  2. Calculate the sha512 hash of the patch. You can use the script in source-builder/sha512-base64 for that.
  3. Search for the config for your GCC version. For example rtems/config/tools/rtems-gcc-13.3-newlib-head.cfg. Add a patch line to that like follows:
    %patch add gcc -p1 file://my-gcc-patch.patch
    %hash sha512 my-gcc-patch.patch z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg==
    

Now rebuild your toolchain using the patched RSB.

Using RSB macro maps

You can add a RSB macro map configuration file similar to the following to achieve a similar goal:

https://gitlab.rtems.org/rtems/tools/rtems-source-builder/-/blob/b6d95403cc142c4abd04df80bb27b5b28efe38d6/rtems/config/snapshots/gcc-4.8-branch.mc

The patch is tested. What’s next?

  1. Create a MR in the RTEMS fork of GCC to discuss the change.
  2. After the discussion: Contribute the patch to the upstream GCC and hope that it will be accepted there.
  3. Either wait till a GCC release picks the patch up. Or add a patch to RSB that pulls the patch from the discussion in our gitlab or from the gcc commit. You can do that also parallel to bringing the patch upstream.

Well using the ‘hack it in’ method it seems like I’ve successfully convinced rsb to build the floating point version of the libs as well. Onward to convert a bsp or two.