Sign in Join
Wiki copytemporary

FreeBSD: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## FreeBSD bleeding edge notes
22
33This page is mainly a scratchpad where I will try to keep FreeBSD specific issues noted. Some of them may apply to NetBSD/OpenBSD, too. Darwin (macOS) is also sharing a lot of the generic BSD code.
44
55FreeBSD was the most mature of the BSD ports, though Darwin (macOS) has now caught up.
66
77### Supported FreeBSD versions (12.x..15-CURRENT)
88
99FreeBSD is currently targeted at versions 12.x, 13.x, 14.x and 15-CURRENT.
1010
1111#### Required kernel options for non GENERIC kernels
1212
1313The FreeBSD pkg installation and compilation from /usr/ports both include FPC compiler binaries which core dump on FreeBSD 12.4, 13.2, 14.0 and 15.0-CURRENT as follows:
1414
1515``` bash
1616$ truss ./work/ppcx64-3.0.4-freebsd
1717sigaction(SIGFPE,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
1818sigaction(SIGSEGV,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
1919sigaction(SIGBUS,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
2020sigaction(SIGILL,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
2121ioctl(1,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
2222ioctl(2,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
2323ioctl(1,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
2424ioctl(2,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
2525compat6.mmap() ERR#78 'Function not implemented'
2626SIGNAL 12 (SIGSYS) code=SI_KERNEL
2727process killed, signal = 12 (core dumped)
2828```
2929
3030**Solution**
3131
3232Use a GENERIC kernel, or for FreeBSD 11.x ensure the following kernel options are uncommented in your KERNCONF file:
3333
34-`options       COMPAT_FREEBSD6         # Compatible with FreeBSD6`\
35-`options       COMPAT_FREEBSD7         # Compatible with FreeBSD7`\
36-`options       COMPAT_FREEBSD10        # Compatible with FreeBSD10`
34+```text
35+options COMPAT_FREEBSD6 # Compatible with FreeBSD6
36+options COMPAT_FREEBSD7 # Compatible with FreeBSD7
37+options COMPAT_FREEBSD10 # Compatible with FreeBSD10
38+```
3739
38-*`Note 1: COMPAT_FREEBSD7 was necessary otherwise the kernel would fail to build once COMPAT_FREEBSD6 was included.`*\
39-*`Note 2: COMPAT_FREEBSD11 is also be required for FreeBSD 12.0.`*\
40-***`Note 3: Nowadays, lang/fpc port doesn't need COMPAT <= 11 dependencies. It should fix problems when GENERIC kernel is not used (unless compiling trunk from source).`***
40+```text
41+Note 1: COMPAT_FREEBSD7 was necessary otherwise the kernel would fail to build once COMPAT_FREEBSD6 was included.
42+Note 2: COMPAT_FREEBSD11 is also be required for FreeBSD 12.0.
43+Note 3: Nowadays, lang/fpc port doesn't need COMPAT <= 11 dependencies. It should fix problems when GENERIC kernel is not used (unless compiling trunk from source).
44+```
4145
4246It seems the FPC binaries are calling some very old FreeBSD system calls dating back some 14 years.
4347
4448#### FPC 3.3.1 (main)
4549
4650Currently, FreeBSD is enable to compile the source for FPC 3.3.1 from ports tree. Take a look at: <https://www.freshports.org/lang/fpc-devel/>
4751
4852## Ports tree
4953
5054FPC is currently available as 3.2.2 and 3.3.1 in the ports tree, maintained by Alonso Cárdenas Márquez (acm_at_FreeBSD.org).
5155
5256### Official FPC Installer
5357
5458Although the ports collection is brilliant, there are alternative methods of installing FPC too - installing from the official *.tar release packages.
5559
56601. Downloading the official *.tar release from [SourceForge.net](http://sourceforge.net/projects/freepascal/files/FreeBSD/)
57612. Unpack the .tar package into a temporary directory
5862
5963 tar xvf fpc-3.0.0.x86_64-freebsd10.tar
60643. Run the setup program
6165
6266 ./install.sh
63674. Follow the on-screen prompts
6468
6569### Building FPC Main
6670
67711. Get the main (development) source code from GitLab (official repository) <https://gitlab.com/freepascal.org/fpc/source> or GitHub SubVersion mirror <https://github.com/fpc/FPCSource/>.
6872
69732. Make sure you have a fully working **latest released FPC version** installed. It is this compiler that will initially compile the main/development FPC.
7074
71753. gmake build OPT="-Fl/usr/local/lib"
7276
73774. gmake install INSTALL_PREFIX=/data/devel/fpc-3.3.1/x86_64-freebsd FPC=/data/devel/fpc-3.3.1/src/compiler/ppcx64
7478
7579**Note:** In the last command you reference the newly built compiler via the FPC= parameter.
7680
7781### Issues
7882
7983- gdb. After installing FreeBSD 10/11/12 and FPC, I found `gdb` version was 6.1.1. This will be found by Lazarus on first run as `/usr/libexec/gdb` and it will make debugging impossible (at least with Lazarus 1.2.x through 2.0.10). The fix is to install the latest `gdb` version by doing `pkg install devel/gdb`, and then modify the used debugger in Lazarus menu Tools-\>Options-\>Debugger, select from the list `/usr/local/bin/gdb`
8084- make. On the first run Lazarus will find `/usr/bin/make` or simply make as the 'make' command. It will not work, install gmake (pkg install gmake) and change it in Lazarus menu Tools-\>Options-\>Environment-\>Files-\>Make path.
8185- Remember that under FreeBSD, by default `/home` is a link to `/usr/home` which is relevant when installing Lazarus using `pkg install lazarus`, by default it will use a primary config path in `/home/username/.lazarus` but then at some point it starts mixing it as `/usr/home/user/.lazarus` which appears to cause problems only on installing packages from OPM as a normal user. Try change opm directories from /home/user to /usr/home/user using Options section.
8286
8387## Older versions of FPC and FreeBSD
8488
8589### Support for older versions
8690
87914.x is formally no longer supported, but the old code pretty much stayed put, the defaults just changed. The differences are pretty much startup code, threading, and some code under ifdef FREEBSD5: (note, the best chance for this to work is with the code of 2.2.2)
8892
8993- 4.x has other startup code than 7.x, get the old .as files from 2.0.0 or 2.0.2 (or from similar versions svn). (I don't really remember what was different about them. It could only be the ABI number in the ELF ident), assemble them, and copy them over the existing ones.
9094- Now bootstrap the compiler using OPT="-dFREEBSD4 -Xf"
9195- copy sources + bootstrapped (static) compiler to 4.x
9296- Bootstrap system (again with patched startup code and OPT="-Xf -dFREEBSD4"
9397
9498Write your experiences here under this paragraph since this is all just theory till now. I do not have a fbsd4 to actually try anymore.
9599
96100### COMPAT_ requirement of the port
97101
98102I haven't really researched the issue, but somehow the port maintainers added a dependancy to COMPAT_5, probably because the source default puts the .note in cprt0.as to 504000 or so. This can be easily remedied by patching the cprt0.as file before building, and put the output of
99103
100104elfdump -n \`which elfdump\` \|awk '/FreeBSD/{print \$2}'
101105
102106in the .long line AFTER a .string "FreeBSD" line in cprt0.as.
103107
104108A script has been added to -trunk (fpc/rtl/freebsd/i386/identpatch.sh) that does this. If you have improvements, please communicate them back (*to where?*).
105109
106110Note: The COMPAT_ dependency was removed with version 2.2.4 of freepascal, and the value of .long line into cprt0.as file is changed to \${OSVERSION} automatically.
107111
108112See about \${OSVERSION} at: <http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/dads-after-port-mk.html>
109113
110114### FPC_USE_LIBC
111115
112116Since jan 2004, most Unix ports of FPC can be recompiled with FPC_USE_LIBC, and in those cases the RTL will use libc functions as much as possible. This was mainly introduced for the Darwin port, and may also be used for e.g. Lazarus distributions. (Lazarus links its apps to libc anyway, because of gtk)
113117
114118### Unix RTL, 1.0.x/1.9.x RTL compability
115119
116120The 1.0.x rtl was essentially a linux only hackish rtl. The rtl was rewritten in version 1.9.x/2.x (and this still continues), and unfortunately, compatibility had to be broken.
117121
118122For reasons and discussion, see [Unix Rtl Doc](http://www.stack.nl/~marcov/unixrtl.pdf)
119123
120124## See also
121125
122126- [[Portal:FreeBSD|FreeBSD Portal]]
123127- [[FreeBSD specific Release Engineering]]
124128
125129---
126130*From the Free Pascal wiki, page "FreeBSD", as it stood on 2023-10-29 after a change by Acm, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
127131Category: BSD
128132Category: FPC
129133Category: FreeBSD
130134Category: Unix

Back to history