openhwgroup / corev-binutils-gdb

GNU General Public License v2.0
9 stars 26 forks source link

Zc toolchain does not seem to allow half-word aligned functions #45

Closed silabs-kjetil closed 1 year ago

silabs-kjetil commented 2 years ago

When building code with the zc* extensions enabled I notice that functions are always word aligned and padding bytes are added which makes the code size larger than expected. Is this a bug in the binutils part of the toolchain, or somewhere else? Is there a way I can force the compiler to accept half-word aligned functions? I am using the following march and mabi arguments:

-march=rv32ima_zca_zcb_zcmb_zcmp_zcmt -mabi=ilp32

simonpcook commented 2 years ago

@jeremybennett, I believe this is the issue you were testing a fix for? Does it make sense to assign this one to yourself?

jeremybennett commented 2 years ago

Yes. Will you give a reply and note that I will pick it up

Thx, J

On Thu, 15 Sept 2022, 17:54 Simon Cook, @.***> wrote:

@jeremybennett https://github.com/jeremybennett, I believe this is the issue you were testing a fix for? Does it make sense to assign this one to yourself?

— Reply to this email directly, view it on GitHub https://github.com/openhwgroup/corev-binutils-gdb/issues/45#issuecomment-1248293962, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMVYRING33CTUZOKAZSFVDV6NBD3ANCNFSM6AAAAAAQNN2FAY . You are receiving this because you were mentioned.Message ID: @.***>

silabs-kjetil commented 2 years ago

Sounds good, glad you are picking this up @jeremybennett. Do you know if there is an easy way to patch my local toolchain to always allow half-word aligned functions temporarily as a workaround until the proper fix is in place?

silabs-kjetil commented 2 years ago

Looks like it was gcc that inserter alignment requirements, so I was able to force 16 bit function alignment by doing the following modification inside gcc/config/riscv/riscv.h as a temporary workaround.

//#define FUNCTION_BOUNDARY (TARGET_RVC ? 16 : 32)
#define FUNCTION_BOUNDARY (16)
jeremybennett commented 2 years ago

Hi @silabs-kjetil I'm just back from GNU Tools Cauldron and it sounds like you have already found the place to fix. We'll work on getting this fixed generically.

pz9115 commented 2 years ago

I think I can fix it

jeremybennett commented 2 years ago

@pz9115 is going to provide the patch

pz9115 commented 2 years ago

Updated with PR https://github.com/openhwgroup/corev-gcc/pull/11

jeremybennett commented 1 year ago

This was actually a GCC issue, which is now fixed.