[fpc-devel] Building cross-compiler for arm-linux on win32
Nikolai Zhubr
n-a-zhubr at yandex.ru
Sun Dec 16 11:51:02 CET 2018
Hi all,
16.12.2018 3:44, I wrote:
[...]
> Got it, somewhat:
> -mfpu=softvfp is passed to arm-linux-as while compiling intermediate .s
> files (when using -Cfsoft), not sure if it is correct and intentional,
> and no special flags passed to arm-linux-as while compiling assembler
> sources.
> Hence the difference reported by objdump.
>
> Now apparently, current binutils' ld wants that somehow fpu type is also
> specified for linking output if it was specified when assembling input
> and they probably need to match each other. I could not find such
> option, but e.g. gcc apparently has some way to automagically do it.
And after looking some more into current binutils, it seems machine code
with this "VFP float format" and machine code without it are considered
by ld not interoperable whatsoever. Therefore, when building for
arm-elf, -mfpu=softvfp option should be passed either for _all_
generated object files or for _none_. Otherwise, linking normally can
not succeed. And probably it is for a reason.
Apparently there is no way to explicitely specify something like -mfpu
to ld, but because the setting can not be mixed anyway, the value is
just inherited by the output elf executable from some (first ?) input
object file ld encounters, afaics.
Looking into e.g. rtl/linux/Makefile[.fpc] there is e.g. this:
$(AS) $(ASTARGET) -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) $(ARCH)/prt0.as
So inserting
ASTARGET+=-mfpu=softvfp
allowed full cross-build to succeed. I have yet to see if the generated
binaries are actually usable.
Thank you!
Regards,
Nikolai
>
>
> Thank you!
>
> Regards,
> Nikolai
>
>> Thing is, object files compiled from pascal (like system.o) still get
>> this suspicious VFP flag even after I started using CROSSOPT="-CpARMV6
>> -Cfsoft". However, object files compiled from assembler sources (like
>> prt0.o) does not. I'm trying to find where it comes from.
>>
>> arm-linux-objdump.exe -p prt0.o
>> prt0.o: file format elf32-littlearm
>> private flags = 0: [APCS-32] [FPA float format]
>>
>> arm-linux-objdump.exe -p system.o
>> system.o: file format elf32-littlearm
>> private flags = 600: [APCS-32] [VFP float format] [software FP]
>>
>> As a side note, I suddenly realised that I don't need any specially
>> crafted version of binutils as long as I target linux and build binutils
>> from source. Standard binutils source tar compiles with almost zero
>> effort on modern mingw, at least for linux target.
>>
>>
>> Thank you!
>>
>> Regards,
>> Nikolai
>>
>>
>> 15.12.2018 23:23, I wrote:
>>> Still can not understand this ".o uses VFP instructions, whereas .\pp
>>> does not", but because I build binutils myself I've found and disabled
>>> the ld error exit on (in_flags & EF_ARM_VFP_FLOAT) != (out_flags &
>>> EF_ARM_VFP_FLOAT), and then with such "fixed" binutils crossfpc build
>>> completed somehow. I can now produce arm-linux executables, but probably
>>> something is wrong anyway because this "VFP float format" is present in
>>> .o files but not in final elf executables:
>>>
>>> arm-linux-objdump.exe -p t.o
>>> t.o: file format elf32-littlearm
>>> private flags = 400: [APCS-32] [VFP float format]
>>>
>>> arm-linux-objdump.exe -p t
>>> t: file format elf32-littlearm
>>> Program Header:
>>> ......
>>> private flags = 0: [APCS-32] [FPA float format]
>>>
>>> (t.pas is a helloworld one-liner.)
>>>
>>> Besides, I get tons of warning from ld like this:
>>> C:\FPC\3.0.4\bin\i386-Win32\arm-linux-ld.exe:
>>> C:\FPC\3.0.4\units\arm-linux\rtl\system.o: Warning: Arm BLX instruction
>>> targets Arm function 'SYSTEM_$$_SYSINITSTDIO'.
>>>
>>> It looks like literally every function in every unit produce such a "Arm
>>> BLX instruction" warning. Seems suspicious.
>>>
>>> And finally, on the target board, the executable totally fails with:
>>>
>>> "Illegal instruction"
>>>
>>> Any hints?
>>>
>>>
>>> Thank you!
>>>
>>> Regards,
>>> Nikolai
>>>
>>>> It successfully produced object files, but ld refsuses to link them.
>>>> Again, the message is:
>>>> pp.o uses VFP instructions, whereas .\pp does not
>>>> (lots of these repeated)
>>>>
>>>> I'm guessing is that either some option is missing for ld to actually
>>>> accept that VFP is present, or rather I need to rebuild my binutils for
>>>> a different (hard fp) target?
>>>>
>>>> (The exact call that fails now is arm-linux-ld.exe -s -L. -o .\pp
>>>> .\link.res)
>>>>
>>>>
>>>> Thank you!
>>>>
>>>> Regards,
>>>> Nikolai
>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> fpc-devel maillist - fpc-devel at lists.freepascal.org
>>>>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>>>
>>>> _______________________________________________
>>>> fpc-devel maillist - fpc-devel at lists.freepascal.org
>>>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>>
>>> _______________________________________________
>>> fpc-devel maillist - fpc-devel at lists.freepascal.org
>>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
More information about the fpc-devel
mailing list