lang/fpc: Restore DragonFly support

FPC cannot use the gold linker.  Gold requires that the linker script have
the --script flag passed, but doing so will break FreePascal (the flags
causes the internal linker to be bypassed).  Since DragonFly switches
linkers through the environment and it's not clear how to set that, I've
hardcoded the linker path for DragonFly for now.  Also, we must avoid using
Gold for the bootstrap compiler (which has not been hardcoded) so passing
LDVER=ld.bfd during the bootstrap stage is necessary to guarantee this.
FreeBSD doesn't use this variable so its harmless on that OPSYS.

The other major fix was fixing the dirent record which differs on DragonFly.
This is why unit searching has always failed.

All patches will be submitted upstream.  This should be a no-op for FreeBSD,
thus no bump.
This commit is contained in:
John Marino 2015-12-21 09:57:34 +00:00
parent d247ee2150
commit 971c1c596a
5 changed files with 77 additions and 1 deletions

View file

@ -115,7 +115,7 @@ do-build:
# build fpc compiler
@${ECHO_MSG} "##### STARTING COMPILER #####"
(cd ${WRKDIR}/${FPCSRCDIR}/compiler && ${SETENV} ${MAKE_ENV} \
${MAKE_CMD} cycle ${MAKE_ARGS} ${BOOTPPC})
LDVER=ld.bfd ${MAKE_CMD} cycle ${MAKE_ARGS} ${BOOTPPC})
@${ECHO_MSG} "##### COMPLETE COMPILER #####"
# build fpcmkcfg

View file

@ -0,0 +1,12 @@
--- compiler/cfileutl.pas.orig 2015-11-13 21:15:29 UTC
+++ compiler/cfileutl.pas
@@ -23,9 +23,7 @@ unit cfileutl;
{$i fpcdefs.inc}
-{$ifndef DragonFly}
{$define usedircache}
-{$endif DragonFly}
interface

View file

@ -0,0 +1,23 @@
--- compiler/systems/t_bsd.pas.orig 2015-11-13 21:15:29 UTC
+++ compiler/systems/t_bsd.pas
@@ -192,6 +192,8 @@ begin
DynamicLinker:='/usr/libexec/ld.so'
else if target_info.system in systems_netbsd then
DynamicLinker:='/usr/libexec/ld.elf_so'
+ else if target_info.system=system_x86_64_dragonfly then
+ DynamicLinker:='/libexec/ld-elf.so.2'
else
DynamicLinker:='';
end;
@@ -718,7 +720,10 @@ begin
Replace(cmdstr,'$DYNLINK',DynLinkStr);
if (target_info.system in systems_darwin) then
Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
- BinStr:=FindUtil(utilsprefix+BinStr);
+ if target_info.system=system_x86_64_dragonfly then
+ BinStr:='/usr/libexec/binutils225/elf/ld.bfd'
+ else
+ BinStr:=FindUtil(utilsprefix+BinStr);
{ create dsym file? }
extdbgbinstr:='';

View file

@ -0,0 +1,14 @@
--- rtl/bsd/ossysc.inc.orig 2015-11-13 21:15:29 UTC
+++ rtl/bsd/ossysc.inc
@@ -282,7 +282,11 @@ begin
repeat
novalid:=false;
CurEntry:=pdirent(dirp^.dd_rewind);
+{$ifdef dragonfly}
+ RecLen:=(CurEntry^.d_namlen + 24) and $FFFFFFF8;
+{$else}
RecLen:=CurEntry^.d_reclen;
+{$endif}
if RecLen<>0 Then
begin {valid direntry?}
if CurEntry^.d_fileno<>0 then

View file

@ -0,0 +1,27 @@
--- rtl/bsd/ostypes.inc.orig 2015-11-13 21:15:29 UTC
+++ rtl/bsd/ostypes.inc
@@ -145,6 +145,16 @@ TYPE
{ directory services }
{$ifndef darwinarm}
+{$ifdef dragonfly}
+ dirent = record
+ d_fileno : ino_t; // file number of entry
+ d_namlen : cuint16; // strlen (d_name)
+ d_type : cuint8; // file type, see below
+ d_unused1 : cuint8; // padding, reserved
+ d_unused2 : cuint32; // reserved
+ d_name : array[0..255] of char; // name, null terminated
+ end;
+{$else}
dirent = record
d_fileno : cuint32; // file number of entry
d_reclen : cuint16; // length of this record
@@ -152,6 +162,7 @@ TYPE
d_namlen : cuint8; // length of string in d_name
d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
end;
+{$endif}
{$else not darwinarm}
{$packrecords 4}
{ available on Mac OS X 10.6 and later, and used by all iPhoneOS versions }