Bug 239135 - lang/fpc build failure on FBSD 11.2
Summary: lang/fpc build failure on FBSD 11.2
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jose Alonso Cardenas Marquez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-11 05:44 UTC by Trev
Modified: 2019-08-29 05:29 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (acm)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Trev 2019-07-11 05:44:38 UTC
The included bootstrap compiler binary:
-rwxr-xr-x  1 1106  493    3386488 28 Nov  2017 ppcx64-3.0.4-freebsd

Cannot build anything - it simply core dumps with "Bad system call (core dumped)".

Truss reveals:

$ truss ./work/ppcx64-3.0.4-freebsd
sigaction(SIGFPE,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigaction(SIGSEGV,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigaction(SIGBUS,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigaction(SIGILL,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
ioctl(1,TIOCGETA,0x7fffffffe4a0)         = 0 (0x0)
ioctl(2,TIOCGETA,0x7fffffffe4a0)         = 0 (0x0)
ioctl(1,TIOCGETA,0x7fffffffe4a0)         = 0 (0x0)
ioctl(2,TIOCGETA,0x7fffffffe4a0)         = 0 (0x0)
compat6.mmap()                           ERR#78 'Function not implemented'
SIGNAL 12 (SIGSYS) code=SI_KERNEL
process killed, signal = 12 (core dumped)

I installed /usr/ports/misc/compat6x - no change.
Comment 1 Trev 2019-07-21 09:00:15 UTC
The solution was to uncomment these kernel options (they are uncommented in a  GENERIC kernel) and rebuild my kernel.

##options       COMPAT_FREEBSD32        # Compatible with i386 binaries
##options       COMPAT_FREEBSD4         # Compatible with FreeBSD4
##options       COMPAT_FREEBSD5         # Compatible with FreeBSD5
##options       COMPAT_FREEBSD6         # Compatible with FreeBSD6
##options       COMPAT_FREEBSD7         # Compatible with FreeBSD7
##options       COMPAT_FREEBSD9         # Compatible with FreeBSD9
##options       COMPAT_FREEBSD10        # Compatible with FreeBSD10

It seems the FPC binaries are calling some very old FreeBSD system calls dating back some 11 years.
Comment 2 Jose Alonso Cardenas Marquez freebsd_committer 2019-08-15 19:27:26 UTC
I have committed new changes to lang/fpc and editors/lazarus ports. Please, see it at:

https://svnweb.freebsd.org/ports?view=revision&revision=509004
https://svnweb.freebsd.org/ports?view=revision&revision=509005
https://svnweb.freebsd.org/ports?view=revision&revision=509007

It doesn't work with lld and maybe will not work on short time. We must be use binutils from base or from ports and change LDPATH into fpc/Makefile to ld.bfd path. Also I have regenerated fpc bootstrap (i386 and amd64) . It should be work only with COMPAT_FREEBSD11 added to kernel config on 12.X+ (COMPAT from 4 to 10 should not be necessary)

I have removed LD_UNSAFE because now we can set LDPATH to a working linker (It works with ld.bfd from base or installed from binutils port)
Comment 3 Trev 2019-08-16 02:10:09 UTC
Builds with no issues under FreeBSD 12.0p9 (GENERIC kernel)

Fails to build under FreeBSD 11.3-STABLE #7 r349943 due to bootstrap compiler 

-rwxr-xr-x  1 root  wheel  3710776 15 Aug 12:37 /usr/ports/lang/fpc/work/ppcx64-3.0.4-freebsd

core dumping due to:

root@shadow [/usr/ports/editors/lazarus] $ truss /usr/ports/lang/fpc/work/ppcx64-3.0.4-freebsd
sigaction(SIGFPE,{ 0x429630 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigaction(SIGSEGV,{ 0x429630 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigaction(SIGBUS,{ 0x429630 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
sigaction(SIGILL,{ 0x429630 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
ioctl(1,TIOCGETA,0x7fffffffe464)                 = 0 (0x0)
ioctl(2,TIOCGETA,0x7fffffffe464)                 = 0 (0x0)
ioctl(1,TIOCGETA,0x7fffffffe464)                 = 0 (0x0)
ioctl(2,TIOCGETA,0x7fffffffe464)                 = 0 (0x0)
compat6.mmap()                                   ERR#78 'Function not implemented'
SIGNAL 12 (SIGSYS) code=SI_KERNEL
process killed, signal = 12 (core dumped)

Kernel Options:

##options       COMPAT_FREEBSD32        # Compatible with i386 binaries
##options       COMPAT_FREEBSD4         # Compatible with FreeBSD4
##options       COMPAT_FREEBSD5         # Compatible with FreeBSD5
##options       COMPAT_FREEBSD6         # Compatible with FreeBSD6
##options       COMPAT_FREEBSD7         # Compatible with FreeBSD7
##options       COMPAT_FREEBSD9         # Compatible with FreeBSD9
options         COMPAT_FREEBSD10        # Compatible with FreeBSD10
Comment 4 Trev 2019-08-16 06:46:01 UTC
To prevent the bootstrap compiler core dumping I have determined that I need to build a kernel with:

options COMPAT_FREEBSD6         # Compatible with FreeBSD6

and

options COMPAT_FREEBSD7         # Compatible with FreeBSD7

COMPAT_FREEBSD7 was necessary because the kernel would fail to build without it once I added COMPAT_FREEBSD6.