<div dir="auto">All this should go in the wiki, maybe on a dedicated section.</div><div dir="auto"><br></div><div dir="auto">-ovidiu</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 5, 2022 at 09:50 Micael <<a href="mailto:m8847@abc.se">m8847@abc.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
So, in short, what I had to do to cross compile for armv7a using GCC 10.<br>
<br>
<br>
1. Remove the section in Makefile.defs that tries to detect the arm <br>
compiler version, since it is outdated afaict. This could of course be <br>
fixed to also include newer GCC versions in the test. But you guys know <br>
more about the history here, and if it is worth the effort. GCC stayed <br>
still in versioning for a long while, and then it kind of exploded.<br>
<br>
2. For armv7a, also in Makefile.defs, change the macro test from <br>
__ARM_ARCH_7__ to __ARM_ARCH_7A__ (this could probably be added as a <br>
secondary test instead, since it is a rather clean test).<br>
<br>
3. Add -marm to CC options<br>
<br>
4. Edit modules/tls_wolfssl/Makfile, adding --host=arm<br>
There's a good error message in the wolfssl output, so it did not take <br>
too long to figure out this.<br>
<br>
<br>
In my case, I used these options (again, gcc 10);<br>
CC -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -marm<br>
<br>
I don't think they are all needed, but I include them as a 'known good' <br>
setup. :)<br>
<br>
<br>
Note;<br>
I have not yet tested anything really, but the outlook is good.<br>
<br>
Thanks,<br>
Micael<br>
<br>
<br>
<br>
On 2022-01-05 14:53, Bogdan-Andrei Iancu wrote:<br>
> Guys,<br>
> <br>
> if you went thru all the pain of getting to the bottom of this, should <br>
> we document somewhere how this cross compiling should be done? to spare <br>
> some future pain of other users :).<br>
> <br>
> Regards,<br>
> <br>
> Bogdan-Andrei Iancu<br>
> <br>
> OpenSIPS Founder and Developer<br>
> <a href="https://www.opensips-solutions.com" rel="noreferrer" target="_blank">https://www.opensips-solutions.com</a><br>
> OpenSIPS eBootcamp 2021<br>
> <a href="https://opensips.org/training/OpenSIPS_eBootcamp_2021/" rel="noreferrer" target="_blank">https://opensips.org/training/OpenSIPS_eBootcamp_2021/</a><br>
> <br>
> On 1/5/22 3:42 PM, Micael wrote:<br>
>><br>
>> Hi again Răzvan,<br>
>><br>
>> Yes!! That was the final missing bit of the puzzle!<br>
>><br>
>> Everything compiles just fine now!<br>
>><br>
>><br>
>> (I had to also make a minor change in wolfssl/Makefile, adding <br>
>> "–host=arm")<br>
>><br>
>><br>
>> Many thanks for your help,<br>
>><br>
>> Micael<br>
>><br>
>><br>
>><br>
>><br>
>> On 2022-01-05 13:23, Răzvan Crainea wrote:<br>
>>> Hi, Micael!<br>
>>><br>
>>> Can you try to add `-marm` in your CC_EXRTA_FLAGS?<br>
>>><br>
>>> Best regards,<br>
>>><br>
>>> Răzvan Crainea<br>
>>> OpenSIPS Core Developer<br>
>>> <a href="http://www.opensips-solutions.com" rel="noreferrer" target="_blank">http://www.opensips-solutions.com</a><br>
>>><br>
>>> On 1/5/22 12:19, Micael wrote:<br>
>>>><br>
>>>> Hi Răzvan,<br>
>>>><br>
>>>> Thanks, with your input I learned more about what is happening!<br>
>>>><br>
>>>> So I tried you suggestion and variants of it, but it gave the same <br>
>>>> result. So I grep'd the CC_ARCH, and found in Makefile.defs that it <br>
>>>> is overwritten by a compiler predefined macro test (__ARM_ARCH_7__).<br>
>>>> I checked my compiler (gcc 10), and it has __ARM_ARCH_7A__ set.<br>
>>>> So I changed Makefile.defs into testing against that, and that <br>
>>>> changed things.<br>
>>>> First of all, I now see "Target architecture <arm7>", instead of <br>
>>>> <arm> when compiling.<br>
>>>><br>
>>>> But then I arrive into the next problem, I guess this is the same <br>
>>>> code (fastlock.h). But now I'm getting into deep water, I suspect <br>
>>>> the assembler code needs some TLC?<br>
>>>><br>
>>>><br>
>>>> $ make<br>
>>>> Target architecture <arm7>, host architecture <x86_64><br>
>>>> Compiling action.c<br>
>>>> /tmp/ccrHaC9i.s: Assembler messages:<br>
>>>> /tmp/ccrHaC9i.s:145: Error: thumb conditional instruction should be <br>
>>>> in IT block -- `strexeq r3,r1,[r2]'<br>
>>>> make: *** [Makefile.rules:28: action.o] Error 1<br>
>>>><br>
>>>><br>
>>>> I tried to test with different thumb and interwork options, but that <br>
>>>> did not change anything.<br>
>>>><br>
>>>><br>
>>>> For reference, I added -v to see exactly which flags where enabled, <br>
>>>> on the build.<br>
>>>><br>
>>>> COLLECT_GCC_OPTIONS= '-mthumb-interwork' '-mfloat-abi=hard' <br>
>>>> '-mfpu=neon' '-v' '-g' '-I' <br>
>>>> '/volt001/tmp/sysroots-components/cortexa8hf-neon/openssl/usr/include' <br>
>>>> '-D' 'PKG_MALLOC' '-D' 'SHM_MMAP' '-D' 'USE_MCAST' '-D' <br>
>>>> 'DISABLE_NAGLE' '-D' 'STATISTICS' '-D' 'HAVE_RESOLV_RES' '-D' <br>
>>>> 'F_MALLOC' '-D' 'Q_MALLOC' '-D' 'HP_MALLOC' '-D' 'DBG_MALLOC' '-D' <br>
>>>> 'HAVE_STDATOMIC' '-D' 'HAVE_GENERICS' '-D' 'NAME="opensips"' '-D' <br>
>>>> 'VERSION="3.2.4"' '-D' 'ARCH="arm7"' '-D' 'OS="linux"' '-D' <br>
>>>> 'COMPILER="/opt/toolchains/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc <br>
>>>> 10.2.1"' '-D' '__CPU_arm7' '-D' '__OS_linux' '-D' '__SMP_yes' '-D' <br>
>>>> 'CFG_DIR="./test//etc/opensips/"' '-D' 'VERSIONTYPE="git"' '-D' <br>
>>>> 'THISREVISION="50407d340"' '-D' 'FAST_LOCK' '-D' 'ADAPTIVE_WAIT' <br>
>>>> '-D' 'ADAPTIVE_WAIT_LOOPS=1024' '-D' 'HAVE_GETHOSTBYNAME2' '-D' <br>
>>>> 'HAVE_UNION_SEMUN' '-D' 'HAVE_SCHED_YIELD' '-D' 'HAVE_MSG_NOSIGNAL' <br>
>>>> '-D' 'HAVE_MSGHDR_MSG_CONTROL' '-D' 'HAVE_ALLOCA_H' '-D' <br>
>>>> 'HAVE_TIMEGM' '-D' 'HAVE_EPOLL' '-D' 'HAVE_SIGIO_RT' '-D' <br>
>>>> 'HAVE_SELECT' '-c' '-o' 'action.o' '-mthumb' '-mtls-dialect=gnu' <br>
>>>> '-march=armv7-a+simd'<br>
>>>><br>
>>>> /opt/toolchains/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/as <br>
>>>> -v -I <br>
>>>> /volt001/tmp/sysroots-components/cortexa8hf-neon/openssl/usr/include <br>
>>>> -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon <br>
>>>> -meabi=5 -o action.o /tmp/ccZHK18t.s<br>
>>>> GNU assembler version 2.35.1 (arm-none-linux-gnueabihf) using BFD <br>
>>>> version (GNU Toolchain for the A-profile Architecture 10.2-2020.11 <br>
>>>> (arm-10.16)) 2.35.1.20201028<br>
>>>><br>
>>>><br>
>>>> Many thanks,<br>
>>>> Micael<br>
>>>><br>
>>>><br>
>>>> On 2022-01-05 09:25, Răzvan Crainea wrote:<br>
>>>>> Hi, Micael!<br>
>>>>><br>
>>>>> It is not the compiler that generates the swp/swpb instructions, <br>
>>>>> but our locking code for backwards compatibility ARM versions. It <br>
>>>>> is using it because it does not properly detect the target <br>
>>>>> architecture (armv7), but a generic (older) ARM version.<br>
>>>>> I see that in your environment you are exporting the CPU variable, <br>
>>>>> which is not actually really used in the build.<br>
>>>>> I'd suggest you try to export the `CC_ARCH` variable <br>
>>>>> (`CC_ARCH=armv7`) - this should set the proper CPU type.<br>
>>>>><br>
>>>>> Let us know how this goes.<br>
>>>>><br>
>>>>> Best regards,<br>
>>>>><br>
>>>>> Răzvan Crainea<br>
>>>>> OpenSIPS Core Developer<br>
>>>>> <a href="http://www.opensips-solutions.com" rel="noreferrer" target="_blank">http://www.opensips-solutions.com</a><br>
>>>>><br>
>>>>> On 1/3/22 18:18, Bogdan-Andrei Iancu wrote:<br>
>>>>>> Hi Micael and Happy New Year ;)<br>
>>>>>><br>
>>>>>> This is more an cross-compiling issue. The arm v6 and 7 obsoleted <br>
>>>>>> the swp/swpb instructions - this is what the warning are saying. <br>
>>>>>> The problem is that your compiler is generating asm code with <br>
>>>>>> those instruction; and the warnings are reported by assembler <br>
>>>>>> (which knows that those instructions are not valid).<br>
>>>>>><br>
>>>>>> I'm not a cross-compiling export (not even closer :P), but I guess <br>
>>>>>> you are passing some wrong compiling flags, leading to this <br>
>>>>>> conflict here.<br>
>>>>>><br>
>>>>>> Best regards,<br>
>>>>>><br>
>>>>>> Bogdan-Andrei Iancu<br>
>>>>>><br>
>>>>>> OpenSIPS Founder and Developer<br>
>>>>>> <a href="https://www.opensips-solutions.com" rel="noreferrer" target="_blank">https://www.opensips-solutions.com</a><br>
>>>>>> OpenSIPS eBootcamp 2021<br>
>>>>>> <a href="https://opensips.org/training/OpenSIPS_eBootcamp_2021/" rel="noreferrer" target="_blank">https://opensips.org/training/OpenSIPS_eBootcamp_2021/</a><br>
>>>>>><br>
>>>>>> On 1/1/22 11:48 AM, Micael wrote:<br>
>>>>>>> Hi all,<br>
>>>>>>><br>
>>>>>>> (Happy New Year!)<br>
>>>>>>><br>
>>>>>>> I am trying to cross compile 3.2.4 for armv7. Now, I'm new to <br>
>>>>>>> opensips,<br>
>>>>>>> so I have no previous experience to fall back on..<br>
>>>>>>><br>
>>>>>>> In short: I have issues, getting this warning when compiling<br>
>>>>>>> "swp{b} use is deprecated for ARMv6 and ARMv7"<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> What I have done is:<br>
>>>>>>> export <br>
>>>>>>> CC_EXTRA_OPTS="--sysroot=/opt/toolchains/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/arm-none-linux-gnueabihf/libc <br>
>>>>>>><br>
>>>>>>> -I <br>
>>>>>>> /volt001/tmp/sysroots-components/cortexa8hf-neon/openssl/usr/include" <br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> export LD_EXTRA_OPTS="-L <br>
>>>>>>> /volt001/tmp/sysroots-components/cortexa8hf-neon/openssl/usr/lib"<br>
>>>>>>><br>
>>>>>>> export <br>
>>>>>>> CC="/opt/toolchains/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc <br>
>>>>>>> -marm -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon"<br>
>>>>>>><br>
>>>>>>> export CPU=armv7a<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> I then had to remove the following section in Makefile.defs, <br>
>>>>>>> otherwise it would add strongarm1100 as cpu.<br>
>>>>>>><br>
>>>>>>> ---8<---------8<------<br>
>>>>>>> ifeq ($(CC_CLASS), 4.x)<br>
>>>>>>> CFLAGS+=-mcpu=strongarm1100 -ftree-vectorize<br>
>>>>>>> else<br>
>>>>>>> #if gcc 3.0+<br>
>>>>>>> ifeq ($(CC_CLASS), 3.x)<br>
>>>>>>> CFLAGS+= -mcpu=strongarm1100<br>
>>>>>>> else<br>
>>>>>>> ifeq ($(CC_CLASS), 2.9x) #older gcc version (2.9[1-5])<br>
>>>>>>> $(warning Old gcc detected ($(CC_SHORTVER)), use gcc <br>
>>>>>>> 3.0.x \<br>
>>>>>>> for better results)<br>
>>>>>>><br>
>>>>>>> CFLAGS+=<br>
>>>>>>> else<br>
>>>>>>> #really old version<br>
>>>>>>> $(warning You are using an old and unsupported gcc \<br>
>>>>>>> version ($(CC_SHORTVER)), compile at your <br>
>>>>>>> own risk!)<br>
>>>>>>><br>
>>>>>>> endif # CC_CLASS, 2.9x<br>
>>>>>>> endif # CC_CLASS, 3.x<br>
>>>>>>> ---8<---------8<------<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> Once I have done that, everything compiles, but with one and the <br>
>>>>>>> same warning (lots, and lots of them);<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> e.g.:<br>
>>>>>>><br>
>>>>>>> Compiling ip_addr.c<br>
>>>>>>> /tmp/ccj7cheW.s: Assembler messages:<br>
>>>>>>> /tmp/ccj7cheW.s:1857: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/ccj7cheW.s:1892: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/ccj7cheW.s:1928: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/ccj7cheW.s:2171: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/ccj7cheW.s:2206: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/ccj7cheW.s:2242: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> Compiling ipc.c<br>
>>>>>>> Compiling main.c<br>
>>>>>>> Compiling map.c<br>
>>>>>>> /tmp/cc6q8n3v.s: Assembler messages:<br>
>>>>>>> /tmp/cc6q8n3v.s:6001: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/cc6q8n3v.s:6036: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> /tmp/cc6q8n3v.s:6072: swp{b} use is deprecated for ARMv6 and ARMv7<br>
>>>>>>> Compiling md5.c<br>
>>>>>>> Compiling md5utils.c<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> I guess I must not be the only one compiling for arm, so I hope <br>
>>>>>>> someone can point me closer to whats wrong.<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> Any help appreciated,<br>
>>>>>>> Micael<br>
>>>>>>><br>
>>>>>>> _______________________________________________<br>
>>>>>>> Users mailing list<br>
>>>>>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>>>>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>>>>><br>
>>>>>><br>
>>>>>> _______________________________________________<br>
>>>>>> Users mailing list<br>
>>>>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>>>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> Users mailing list<br>
>>>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>>><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> Users mailing list<br>
>>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>><br>
>>> _______________________________________________<br>
>>> Users mailing list<br>
>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Users mailing list<br>
>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">VoIP Embedded, Inc.<br><a href="http://www.voipembedded.com" target="_blank">http://www.voipembedded.com</a></div>