Sign in Join
Wiki copytemporary

FreeBSD: what changed

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

Title: FreeBSD

OldNewLine
1+## FreeBSD bleeding edge notes
2+
3+This 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.
4+
5+FreeBSD was the most mature of the BSD ports, though Darwin (macOS) has now caught up.
6+
7+### Supported FreeBSD versions (12.x..15-CURRENT)
8+
9+FreeBSD is currently targeted at versions 12.x, 13.x, 14.x and 15-CURRENT.
10+
11+#### Required kernel options for non GENERIC kernels
12+
13+The 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:
14+
15+``` bash
16+$ truss ./work/ppcx64-3.0.4-freebsd
17+sigaction(SIGFPE,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
18+sigaction(SIGSEGV,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
19+sigaction(SIGBUS,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
20+sigaction(SIGILL,{ 0x4224f0 SA_SIGINFO ss_t },{ SIG_DFL 0x0 ss_t }) = 0 (0x0)
21+ioctl(1,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
22+ioctl(2,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
23+ioctl(1,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
24+ioctl(2,TIOCGETA,0x7fffffffe4a0) = 0 (0x0)
25+compat6.mmap() ERR#78 'Function not implemented'
26+SIGNAL 12 (SIGSYS) code=SI_KERNEL
27+process killed, signal = 12 (core dumped)
28+```
29+
30+**Solution**
31+
32+Use a GENERIC kernel, or for FreeBSD 11.x ensure the following kernel options are uncommented in your KERNCONF file:
33+
34+`options       COMPAT_FREEBSD6         # Compatible with FreeBSD6`\
35+`options       COMPAT_FREEBSD7         # Compatible with FreeBSD7`\
36+`options       COMPAT_FREEBSD10        # Compatible with FreeBSD10`
37+
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).`***
41+
42+It seems the FPC binaries are calling some very old FreeBSD system calls dating back some 14 years.
43+
44+#### FPC 3.3.1 (main)
45+
46+Currently, 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/>
47+
48+## Ports tree
49+
50+FPC 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).
51+
52+### Official FPC Installer
53+
54+Although the ports collection is brilliant, there are alternative methods of installing FPC too - installing from the official *.tar release packages.
55+
56+1. Downloading the official *.tar release from [SourceForge.net](http://sourceforge.net/projects/freepascal/files/FreeBSD/)
57+2. Unpack the .tar package into a temporary directory
58+
59+ tar xvf fpc-3.0.0.x86_64-freebsd10.tar
60+3. Run the setup program
61+
62+ ./install.sh
63+4. Follow the on-screen prompts
64+
65+### Building FPC Main
66+
67+1. 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/>.
68+
69+2. Make sure you have a fully working **latest released FPC version** installed. It is this compiler that will initially compile the main/development FPC.
70+
71+3. gmake build OPT="-Fl/usr/local/lib"
72+
73+4. gmake install INSTALL_PREFIX=/data/devel/fpc-3.3.1/x86_64-freebsd FPC=/data/devel/fpc-3.3.1/src/compiler/ppcx64
74+
75+**Note:** In the last command you reference the newly built compiler via the FPC= parameter.
76+
77+### Issues
78+
79+- 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`
80+- 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.
81+- 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.
82+
83+## Older versions of FPC and FreeBSD
84+
85+### Support for older versions
86+
87+4.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)
88+
89+- 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.
90+- Now bootstrap the compiler using OPT="-dFREEBSD4 -Xf"
91+- copy sources + bootstrapped (static) compiler to 4.x
92+- Bootstrap system (again with patched startup code and OPT="-Xf -dFREEBSD4"
93+
94+Write your experiences here under this paragraph since this is all just theory till now. I do not have a fbsd4 to actually try anymore.
95+
96+### COMPAT_ requirement of the port
97+
98+I 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
99+
100+elfdump -n \`which elfdump\` \|awk '/FreeBSD/{print \$2}'
101+
102+in the .long line AFTER a .string "FreeBSD" line in cprt0.as.
103+
104+A 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?*).
105+
106+Note: 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.
107+
108+See about \${OSVERSION} at: <http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/dads-after-port-mk.html>
109+
110+### FPC_USE_LIBC
111+
112+Since 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)
113+
114+### Unix RTL, 1.0.x/1.9.x RTL compability
115+
116+The 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.
117+
118+For reasons and discussion, see [Unix Rtl Doc](http://www.stack.nl/~marcov/unixrtl.pdf)
119+
120+## See also
121+
122+- [[Portal:FreeBSD|FreeBSD Portal]]
123+- [[FreeBSD specific Release Engineering]]
124+
125+---
126+*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).*
127+Category: BSD
128+Category: FPC
129+Category: FreeBSD
130+Category: Unix

Back to history