[fpc-devel] defines by the compiler... / linux, LIBC, SysCall

Martin Frb lazarus at mfriebe.de
Thu Jan 11 16:56:31 CET 2024


On 11/01/2024 16:34, Marco van de Voort via fpc-devel wrote:
>
> Op 11-1-2024 om 15:48 schreef Martin Frb via fpc-devel:
>> - Can (on any linux/unix)  "uses SysCall" be compiled  (without error)
>
> You can test that yourself on a Linux system by compiling a cycle with 
> -dFPC_USE_LIBC and then compiling a test program (without defines)   
> Since there was a bugfix necessary, I assume not.

Not necessary. (as far as I understand the comments that had been made 
already)
-dFPC_USE_LIBC  would not change the os target to sunos.  And therefore 
FPC would not look at the tsysteminfo containing
      extradefines : 'UNIX;LIBC;SUNOS;HASUNIX';

-dFPC_USE_LIBC   would just affect the "uses SysCall" (and that 
hopefully in *exactly* the same manner as compiling on sunos)


>
>> - Does it need to be guarded {$IFnDEF LIBC} ?
>
> That define would be FPC_USE_LIBC.  But afaik that is only defined ad 
> hoc on spots where it is needed during the FPC compilation. I.e. it is 
> set in the build system rather than being a compiler built in. So no.

Sure?

-dFPC_USE_LIBC    would be specified be the user or Makefile when the 
fpc/rtl is build.

But when an fpc (that had been build with -dFPC_USE_LIBC ) is used to 
compile a random project, will then this fpc by tiself define 
-dFPC_USE_LIBC    (without the user needing to do so?)

--------------------------

I have 2 different concerns

1) What happens on sunos?
(Where the compiler defaults to LIBC)

That is the case I wont to cover.

2) What happens, if the user "tampers" with settings building a non 
default fpc.

That 2nd part is not that important in respect to my questions in this mail.
If the user does that, then  (when compiling lazarus or any project)
-  no special define may be set by FPC (and that is ok)
- the user may have to set a define according to the project (lazarus 
could offer a workaround define)


-----------------------------
as for point 1
To make sure it compiles with
- normal build fpc on linux/darwin
- normal build fpc on sunos


{$ifdef linux}
   uses   SysCall;
{$endif}

{$ifdef darwin}
   {$DEFINE FPDEBUG_USE_LIBC}  // darwin: always libc
{$else}
   {$IF not declared(Do_SysCall)}  // Linux, but no Do_SysCall

     {$IFDEF LIBC}                    // Does this define ever exist (by fpc)
       {$DEFINE FPDEBUG_USE_LIBC}     // no DoSysCall ==> use libc
     {$ELSE}
       {$DEFINE FPDEBUG_USE_DUMMY}  // no DoSysCall ==> empty dummy proc
     {$ENDIF}

   {$ENDIF}

      // ELSE: Do_Syscall exists and can be used
{$endif}



Will that work?
==>> Will (on linux, including sunos)
       "uses SysCall"
compile (not throw an error during compilation). (that is for NORMAL / 
non-tampered FPC)

If yes, then that should work. (even if LIBC isn't defined)
If yes, then I can check if "DoSysCall" can be used

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20240111/b6acce0a/attachment.htm>


More information about the fpc-devel mailing list