Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembly failure on armv7 #11

Closed
PureTryOut opened this issue Mar 8, 2020 · 16 comments
Closed

Assembly failure on armv7 #11

PureTryOut opened this issue Mar 8, 2020 · 16 comments
Labels
bug Something isn't working
Milestone

Comments

@PureTryOut
Copy link
Contributor

On armv7, we get an assembly failure on Alpine Linux. See the CI pipeline here.

The error:

g++ -Os -fomit-frame-pointer -Wall -fPIC -fno-strict-aliasing -o obj/as_callfunc_arm_gcc.o -c ../../source/as_callfunc_arm_gcc.S
../../source/as_callfunc_arm_gcc.S: Assembler messages:
../../source/as_callfunc_arm_gcc.S:336: Error: thumb conditional instruction should be in IT block -- `ldrge r0,[r6]'
../../source/as_callfunc_arm_gcc.S:338: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:340: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:342: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:413: Error: thumb conditional instruction should be in IT block -- `ldrge r0,[r6]'
../../source/as_callfunc_arm_gcc.S:415: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:416: Error: thumb conditional instruction should be in IT block -- `movlt r1,r5'
../../source/as_callfunc_arm_gcc.S:418: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:419: Error: thumb conditional instruction should be in IT block -- `movlt r2,r5'
../../source/as_callfunc_arm_gcc.S:421: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:422: Error: thumb conditional instruction should be in IT block -- `movlt r3,r5'
../../source/as_callfunc_arm_gcc.S:423: Error: thumb conditional instruction should be in IT block -- `movlt r5,#0'
../../source/as_callfunc_arm_gcc.S:503: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6]'
../../source/as_callfunc_arm_gcc.S:505: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:506: Error: thumb conditional instruction should be in IT block -- `movlt r2,r5'
../../source/as_callfunc_arm_gcc.S:508: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:509: Error: thumb conditional instruction should be in IT block -- `movlt r3,r5'
../../source/as_callfunc_arm_gcc.S:510: Error: thumb conditional instruction should be in IT block -- `movlt r5,#0'
../../source/as_callfunc_arm_gcc.S:514: Error: thumb conditional instruction should be in IT block -- `ldrge r7,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:515: Error: thumb conditional instruction should be in IT block -- `strge r7,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:520: Error: thumb conditional instruction should be in IT block -- `movge r5,#4'
../../source/as_callfunc_arm_gcc.S:591: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6]'
../../source/as_callfunc_arm_gcc.S:593: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:595: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:597: Error: thumb conditional instruction should be in IT block -- `movge r11,#4'
../../source/as_callfunc_arm_gcc.S:669: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6]'
../../source/as_callfunc_arm_gcc.S:671: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:673: Error: thumb conditional instruction should be in IT block -- `movge r11,#4'
../../source/as_callfunc_arm_gcc.S:675: Error: thumb conditional instruction should be in IT block -- `movge r11,#8'
../../source/as_callfunc_arm_gcc.S:676: Error: thumb conditional instruction should be in IT block -- `ldrlt r7,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:677: Error: thumb conditional instruction should be in IT block -- `strlt r7,[r6,#12]'
@MayaPosch
Copy link
Owner

That's in an AngelScript ASM file. I wonder if it's an AngelScript ARMv7 issue?

@MayaPosch
Copy link
Owner

Looking at as_callfunc_arm_gcc.S, it appears that this issue is due to it trying to compile the ASM file for the Thumb ISA when it should use the regular ARM ISA. I'll have to see whether I can replicate this issue and maybe fix it in the Makefile.

@MayaPosch MayaPosch added this to the v0.1 milestone Mar 20, 2020
@MayaPosch MayaPosch added the bug Something isn't working label Apr 9, 2020
@MayaPosch
Copy link
Owner

MayaPosch commented Apr 9, 2020

Reproduced under Debian Buster armhf with GCC 8.3.0.

g++ -Wall -fPIC -fno-strict-aliasing -o obj/as_callfunc_arm_gcc.o -c ../../source/as_callfunc_arm_gcc.S
../../source/as_callfunc_arm_gcc.S: Assembler messages:
../../source/as_callfunc_arm_gcc.S:336: Error: thumb conditional instruction should be in IT block -- `ldrge r0,[r6]'
../../source/as_callfunc_arm_gcc.S:338: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:340: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:342: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:413: Error: thumb conditional instruction should be in IT block -- `ldrge r0,[r6]'
../../source/as_callfunc_arm_gcc.S:415: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:416: Error: thumb conditional instruction should be in IT block -- `movlt r1,r5'
../../source/as_callfunc_arm_gcc.S:418: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:419: Error: thumb conditional instruction should be in IT block -- `movlt r2,r5'
../../source/as_callfunc_arm_gcc.S:421: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:422: Error: thumb conditional instruction should be in IT block -- `movlt r3,r5'
../../source/as_callfunc_arm_gcc.S:423: Error: thumb conditional instruction should be in IT block -- `movlt r5,#0'
../../source/as_callfunc_arm_gcc.S:503: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6]'
../../source/as_callfunc_arm_gcc.S:505: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:506: Error: thumb conditional instruction should be in IT block -- `movlt r2,r5'
../../source/as_callfunc_arm_gcc.S:508: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:509: Error: thumb conditional instruction should be in IT block -- `movlt r3,r5'
../../source/as_callfunc_arm_gcc.S:510: Error: thumb conditional instruction should be in IT block -- `movlt r5,#0'
../../source/as_callfunc_arm_gcc.S:514: Error: thumb conditional instruction should be in IT block -- `ldrge r7,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:515: Error: thumb conditional instruction should be in IT block -- `strge r7,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:520: Error: thumb conditional instruction should be in IT block -- `movge r5,#4'
../../source/as_callfunc_arm_gcc.S:591: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6]'
../../source/as_callfunc_arm_gcc.S:593: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:595: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:597: Error: thumb conditional instruction should be in IT block -- `movge r11,#4'
../../source/as_callfunc_arm_gcc.S:669: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6]'
../../source/as_callfunc_arm_gcc.S:671: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:673: Error: thumb conditional instruction should be in IT block -- `movge r11,#4'
../../source/as_callfunc_arm_gcc.S:675: Error: thumb conditional instruction should be in IT block -- `movge r11,#8'
../../source/as_callfunc_arm_gcc.S:676: Error: thumb conditional instruction should be in IT block -- `ldrlt r7,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:677: Error: thumb conditional instruction should be in IT block -- `strlt r7,[r6,#12]'
make[1]: *** [Makefile:160: obj/as_callfunc_arm_gcc.o] Error 1

@MayaPosch
Copy link
Owner

I managed to make the AngelScript runtime build on armv7l architectures by adding -Wa,-mimplicit-it=thumb when an armv7l architecture is detected, per the instructions here: https://wiki.ubuntu.com/ARM/Thumb2

This modifies only the projects/gnuc/Makefile file in the AngelScript build system. The AngelScript author has also been made aware of these changes.

Theoretically this modification should not impact building NymphCast on other platforms, but it should be tested regardless.

@PureTryOut
Copy link
Contributor Author

Doesn't seem to work for me, it still fails on armv7.

https://gitlab.alpinelinux.org/PureTryOut/aports/-/jobs/90488

@MayaPosch
Copy link
Owner

The Makefile checks with uname -m what the underlying system architecture is. What does the environment which you're running it in return? Since on Debian I got armv7l back, that's what I'm checking for.

@PureTryOut
Copy link
Contributor Author

Ah makes sense, but that isn't a reliable check. In Alpine's case, armhf and armv7 packages are actually built on a 32-bit capable aarch64 system. uname -m thus reports armv8l and the build system doesn't realize it's incorrect.

@MayaPosch
Copy link
Owner

MayaPosch commented Apr 11, 2020

I have removed the use of uname. Instead the Makefile uses the -dumpmachine flag of GCC to determine the target architecture.

@PureTryOut
Copy link
Contributor Author

Still no luck sadly, not sure what's up... https://gitlab.alpinelinux.org/PureTryOut/aports/-/jobs/90618

@MayaPosch
Copy link
Owner

MayaPosch commented Apr 11, 2020

I'm not sure what kind of GCC toolchain is used there. It should target arm-linux-gnu, no?

The Makefile just checks for a string that starts with arm-, so that covers a lot of territory.

@PureTryOut
Copy link
Contributor Author

Just the usual.

On my local (x86_64) machine gcc -dumpmachine gives me

▶ gcc -dumpmachine
x86_64-alpine-linux-musl

I'm guessing that should be armv7l-alpine-linux-musl on armv7?

@MayaPosch
Copy link
Owner

It should start with arm- since the toolchain targets ARMv7. ARMv8 (64-bit) uses aarch64-.

@MayaPosch
Copy link
Owner

I have changed the Makefile to output the GCC triplet, so we can more easily see what gcc -dumpmachine actually returns :)

@PureTryOut
Copy link
Contributor Author

GCC ARCH: armv7-alpine-linux-musleabihf

https://gitlab.alpinelinux.org/PureTryOut/aports/-/jobs/91563

@MayaPosch
Copy link
Owner

Huh, that's an odd one. Only seen similar triplets with clang so far.

I have added the armv7- option as well to the Makefile. It better work now :)

@PureTryOut
Copy link
Contributor Author

Yup that worked, thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants