[fpc-devel] Making $FPCABI work as expected for embedded targets

Michael Ring mail at michael-ring.org
Sat Feb 13 15:22:55 CET 2021


There is an issue with compiling code for armv7em, we may compile with 
hardfloat support or without. The compiled files are link-incompatible 
as ABI is different so mixing them is a bad thing.

I played arround with $FPCABI in fpc.cfg but found out that it is always 
set to 'default' because the parameter -Ca is not parsed on firstpass 
and fpc.cfg is evaluated immediately after firstpass and for that reason 
my entries that contain '$FPCABI' get discarded.

I use those entries in fpc.cfg:

-Fu/Users/ring/fpcupdeluxe-embedded/fpc/units/arm-embedded/$FPCSUBARCH/$FPCABI/rtl
-Fu/Users/ring/fpcupdeluxe-embedded/fpc/units/arm-embedded/$FPCSUBARCH/$FPCABI/packages


To solve this I have made -Ca a first-pass option:

diff --git a/compiler/options.pas b/compiler/options.pas
index 4bf2bf35f5..c410d9d4b0 100644
--- a/compiler/options.pas
+++ b/compiler/options.pas
@@ -1118,6 +1118,7 @@ begin
            ((length(opt)>1) and (opt[2] in 
['i','d','v','T','u','n','X','l','U'])) or
            ((length(opt)>3) and (opt[2]='F') and (opt[3]='e')) or
            ((length(opt)>3) and (opt[2]='C') and (opt[3]='p')) or
+          ((length(opt)>3) and (opt[2]='C') and (opt[3]='a')) or
            ((length(opt)>3) and (opt[2]='W') and (opt[3] in ['m','p']))
           )
          ) then

and now evaluation of $FPCABI seems to work just fine.


But as I am not that deep in the internals of FPC the question is if my 
change makes sense or if sonner or later my cat will explode or my Mac 
will suddenly convert to run Windows... or some other harmfull things 
will happen with making Ca firstpass.

If this causes no issue, can this please be applied to trunk to make 
$FPCABI actually work?


Thank you,


Michael





More information about the fpc-devel mailing list