On Sunday, 2 March 2014 at 15:36:01 UTC, Johannes Pfau wrote:
To make sure  that libgcc
is built correctly for Cortex-M4 you have to specify
"--with-arch=armv7e-m --with-cpu=cortex-m4 --with-mode=thumb
--with-tune=" when configuring gcc/gdc.

(And I don't see these flags mentioned in
https://bitbucket.org/timosi/minlibd/src/691c76aa2b543998bb573e6ce6d96951a80817bd/README.gdc?at=default)

Gcc build fails with these. It will take time to check them one by one. Also enable/disable-multilib may affect to this.

Then I updated my host binutils and gcc to latest head and with these I compiled cross binutils and gcc/gdc from head. I used my current settings. Now my own code and minlibd do not have any blx instructions but libgcc has some.

Sounds strange, I don't think we could cause this in the gdc frontend.
I am not saying it is a gdc bug. It may very well be a side effect of a flag that is related to maybe umwinding or relocation. I do have two kind of object files now in my executable and I just like to know what is the difference between them.

I guess binutils generates blx if thumb code calls arm code or the other way round. So I'd verify which libraries are really picked up by ld (ld --verbose) then check if the entry points are in thumb or arm
mode:
http://stackoverflow.com/a/15931232

This sounds a lot as if calls to the same library/object file generate bl instructions as the code is in the same mode, but functions in external libraries are in a different mode and therefore generate blx.

Yes, I think blx is for this. M4 does not have arm mode and there is no this instruction, so it should be a linker error if the user try to mix objects with different modes. As I mentioned, I pass manually everything, including libgcc. Nothing is picked by default. The multilib thing should be just because of this. There are 4 variants of libgcc. If I pick the m4-fpu library it should be already compiled with the right flags. If it is not, I think that is a gcc bug.
How can I check from the library which modes/flags is has?


I'm not sure but I still don't think we could cause this. This
low-level stuff is usually part of the backend, the frontend doesn't
know much about thumb/arm.

Yes, this is going a little off-topic now

Reply via email to