-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
correct libgcc not getting linked for CONFIG_FLOAT=y on ARM #2092
Comments
by Juro Bystricky: Yes, multilibs need some cleanup. For example, the following should be in Makefile.toolchain.zephyr: {code:java} libgccLIBGCC_DIR_arm = $(shell dirname newlib lib/includeNEWLIB_DIR_arm = {code} Similar setup for other multilib toolchains (ARC, Nios2, ...). Basically, we query the compiler itself which library should be used given compiler flags (options). |
by Kumar Gala: Fixed by combination of SDK 0.8.2 (which supports multilibs for softfp and hard fp ABIs). Plus change to allow user to select which Floating Point ABI they want to build with. |
by Sharron LIU: Please reporter verify and close this. Thanks. |
by Mark Linkmeyer: Hi Kumar Gala , as the Reporter of this bug we need you to verify it's fixed since it's in the Resolved state. Please verify it ASAP so we know whether or not more work is required to fix it before the upcoming 1.5 release. If it's fixed, please move it to the Verified state. Thanks! |
by Marcus Shawcroft: The underlying issue is still present with the SDK 0.8.2, but manifests when building with hard float disabled. The multilib configuration for arm-poki-eabi-gcc is: The KBUILD_CFLAGS options passed for an frdm_k64f build include: The architecture 'armv7e-m' is correct for a cortex-m4. This set of options will match the first multlib (ie thumb;@thumb). The libgcc.a file in that directory was built for armv4t (where thumb and arm state are legitimate). The armv7e-m architecture is thumb2 only, hence a binary linked against this first multilib is illegal. For reference, there is comprehensive multilib support for the full range of ARM R and M profile architecture permutations provided in the the ARM/embedded-5 upstream GCC branch. See here for the first commit: This patch provides support for the following multilibs: While this is not complete, it does provide a viable lowest common denominator for all current arm aarch32 cortex-m/r architectures. This patch/support has not yet been presented for inclusion in upstream GCC trunk, but my understanding is that this is likely in the near future. w.r.t the immediate issue in zephyr, possible short term options include: It's worth noting that folks currently working on cortex-m0 / m0+ support are going to hit the same issue (cortex-m0 == armv6-m), hence a minimum viable set of armv6-m multlibs will be required to enable their work. |
by Marcus Shawcroft: This is still broken: with 0.8.2. On frdm_k64f configured CONFIG_FP_SOFTABI an inappropriate libgcc.a is linked resulting in ARM state code being executed on arm7e-m with CONFIG_FP_HARDABI we get a link error (one object uses VFP registers another does not). See my previous comment above for more detail. |
by Kumar Gala: What error are you seeing. How to reproduce? |
by Marcus Shawcroft: Reproduce like this: $ cat prj.conf $ cat src/main.c int $ make BOARD=frdm_k64f gives.... Adding CONFIG_FP_SOFTABI: Results in an apparently successful build. Howver the binary produced contains ARM state code. If you try to execute the resulting binary it will repeatedly fault. For direct evidence of the issue: ie ARM state code. |
by Kumar Gala: Not able to reproduce. I'm able to run with both CONFIG_FP_SOFTABI and CONFIG_FP_HARDABI without issues. I also don't see the compile issue with HARDABI. Can you build with V=1 and report the link lines you are seeing. |
by Marcus Shawcroft: Its possible to demonstrate correct behaviour here using the pre-built toolchain from https://launchpad.net/gcc-arm-embedded $ arm-none-eabi-gcc -v $ make BOARD=frdm_k64f CROSS_COMPILE=arm-none-eabi- Generates binaries that execute correctly in both of the examples I gave above. |
by Marcus Shawcroft: Hi, Link lines as request:
|
by Marcus Shawcroft: Kumar, when run, does the example above print 0.0000 or something resembling 0.6 ? |
by Kumar Gala: I saw 0.0000 once, but than starting seeing 0.6. Can you try removing '-mfpu=fpv4-sp-d16' from arch/arm/Makefile and see what you get. I'm noticing that -mfloat-abi=hard -mfpu=fpv4-sp-d16 isn't getting me the code I'd expect (with either the SDK toolchain or the ARM embedded toolchain). However if I drop the -mfpu option things seem more inline with what I'd expect. |
by Marcus Shawcroft: Configured for CONFIG_FP_HARDABI with '-mfpu=fpv4-sp-d16' from arch/arm/Makefile the link fails with:
|
by Juro Bystricky: Well, I think the problem is there are missing ARM libgcc.a libraries for each library variant. |
by Juro Bystricky: Confirmed. The binary is linked with incorrect libgcc.a (as it is the only one available - default tune). |
by Kumar Gala: Where are missing, I see: ./sysroots/armv5-poky-eabi/usr/lib/arm-poky-eabi/5.2.0/thumb/libgcc.a |
by Juro Bystricky: Correct. All of the above will be present in the next SDK release. |
by Kumar Gala: Sorry, wasn't clear. I was saying that was my list of libgcc.a from the 0.8.2 sdk install, so not sure what we are missing. |
by Juro Bystricky: Argh, was looking at the next SDK under development. Yes, the libraries are present in SDK 0.8.2. I was not able to reproduce the problem, but I have seen the link error while running sanitycheck (test_fp_shared for ARM). For some reason I don't see it anymore. Marcus, just being paranoid: |
by Juro Bystricky: Additionally, repeating the steps from above (disassembly), I see code that looks like thumb2 code: mix of 32 bit and 16 bit opcodes {code:java}
{code} |
by Marcus Shawcroft: Folks, I've looked at this again this morning with fresh eyes and concluded that I botched my original analysis. It looks like I installed 8.2 but continued to execute 8.1. With 8.2, I do see sane behaviour, my test app runs as expected. Juro, Kumar, sorry for the distraction. |
by Juro Bystricky: All's well that ends well. |
by Mark Linkmeyer: Correcting the priority field |
Reported by Kumar Gala:
When enabling CONFIG_FLOAT=y we aren't linking in the correct libgcc.a on ARM architectures. There are a number of issues here:
/opt/zephyr-sdk/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-eabi/gcc/arm-poky-eabi/5.2.0/real-ld: error: /opt/zephyr-sdk/sysroots/armv5-poky-eabi/usr/lib/arm-poky-eabi/5.2.0/fpu/libgcc.a(_powisf2.o) uses VFP register arguments, .tmp_zephyr.prebuilt does not
/opt/zephyr-sdk/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-eabi/gcc/arm-poky-eabi/5.2.0/real-ld: failed to merge target specific data of file /opt/zephyr-sdk/sysroots/armv5-poky-eabi/usr/lib/arm-poky-eabi/5.2.0/fpu/libgcc.a(_powisf2.o)
/opt/zephyr-sdk/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-eabi/gcc/arm-poky-eabi/5.2.0/real-ld: error: /opt/zephyr-sdk/sysroots/armv5-poky-eabi/usr/lib/arm-poky-eabi/5.2.0/fpu/libgcc.a(_udivmoddi4.o) uses VFP register arguments, .tmp_zephyr.prebuilt does not
/opt/zephyr-sdk/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-eabi/gcc/arm-poky-eabi/5.2.0/real-ld: failed to merge target specific data of file /opt/zephyr-sdk/sysroots/armv5-poky-eabi/usr/lib/arm-poky-eabi/5.2.0/fpu/libgcc.a(_udivmoddi4.o)
collect2: error: ld returned 1 exit status
This is due to building the kernel with -mfloat-abi=softfp, while the Zephyr toolchain only supports -mfloat-abi=hard.
While we can quickly fixing this with some minor tweaks, are more proper fix would utilize -print-libgcc-file-name to get the libgcc path and we'd pickup:
https://gerrit.zephyrproject.org/r/#/c/2899/
To get multilib support for -mfloat-abi=softfp, and -mfloat-abi=hard
(Imported from Jira ZEP-555)
The text was updated successfully, but these errors were encountered: