Difference between revisions of "FreeBSD"

From Free Pascal wiki
(FreeBSD page created)
 
Line 6: Line 6:
 
FreeBSD is the most mature of the BSD ports, though Darwin is rapidly catching up.  
 
FreeBSD is the most mature of the BSD ports, though Darwin is rapidly catching up.  
  
== FreeBSD 5.x ==
+
== Supported FreeBSD versions (5.x..7.x)  ==
  
While afaik not available publically ( mailed the script to the lang/fpc porter), there is some support for FreeBSD 5.x now. (5.x means 5.2 and later, 5.0, 5.1)
+
FreeBSD is currently targeted at versions 5.x .. 7.x. There might be some features not available in 5.x, but they will be rare. (think like createguid/uuidgen or so).
  
Actually there are two changes for 5.x:
+
== Support for older versions ==
* the startup code is different due to the addition of an ABI tag, and
 
* (after 5.2) libkse becomes the new scheduler in 5-CURRENT.
 
  
I'll try to keep 4.x working till my provider, Stack doesn't use 4.x anymore on
+
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)
its shell machines.
+
 
 +
* 4.x has other startup code from 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.
 +
* Now bootstrap the compiler using OPT="-dFREEBSD4 -Xf"
 +
* copy sources + bootstrapped (static) compiler to 4.x
 +
* Bootstrap system (again with patched startup code and OPT="-Xf -dFREEBSD4"
 +
 
 +
write your experiences here under this paragraph since this is all just theory till now. I don't have a fbsd4 to actually try anymore.
  
 
=== 5.x startup code ===
 
=== 5.x startup code ===
 
The first can be fixed for 1.0.10 (lang/fpc port) by running
 
The first can be fixed for 1.0.10 (lang/fpc port) by running
 
[http://www.stack.nl/~marcov/fixfpc this shell script] if you have 5.x, which takes the prefix where FPC is installed as optional parameter. (tested on 5.2)
 
[http://www.stack.nl/~marcov/fixfpc this shell script] if you have 5.x, which takes the prefix where FPC is installed as optional parameter. (tested on 5.2)
 
There is no such script for 1.9.x yet, but creating it should not be hard, and I hope to have it running with 1.9.4, maybe even integrate it into the makefiles
 
  
 
=== libkse/libpthreads ===
 
=== libkse/libpthreads ===
  
The second is only fixed in CVS (and therefore will only be available in 1.9.4 and later). This functionality is barely tested though, but adding parameter -Xf to the commandline of the compiler (when linking) or to fpc.cfg should use libpthreads instead of libc_r.
+
Starting with 2.0.4 or so, the default is FreeBSD5 kse/pthreads threading instead of libc_r.  
  
 
For this to work there must be at least one header set that has
 
For this to work there must be at least one header set that has
Line 32: Line 34:
  
 
and there should be no direct use of {$linklib c_r} anymore, the compiler
 
and there should be no direct use of {$linklib c_r} anymore, the compiler
transforms the library list automatically depending on -Xf.
+
transforms the library list automatically to 4.x compat if  -Xf is passed on the cmdline
 
 
The best way to this is by simply use "USES systhrds"
 
  
 
== Ports tree ==
 
== Ports tree ==
  
FPC is currently available in both flavours in the ports tree
+
FPC is currently available as 2.2.0 in the ports tree, maintained by José Alonso Cárdenas Márquez (acm@freebsd.org). Since 2.2.2 doesn't change anything fundamental, as a typical FIXES release, it will probably get updated quickly
 
 
* John Merryweather-Cooper maintains an independant 1.0.10 port as lang/fpc which was originally based on the binary 1.0. .tar.gz, but seems to be changing to source builder using lots of different modules right now.
 
[http://www.freebsd.org/cgi/query-pr-summary.cgi?category=&severity=&priority=&class=&state=&sort=none&text=fpc&responsible=&multitext=&originator=&release= see here for current FPC ports/ PR status]
 
* I myself maintain the lang/fpc-devel port, which is a source based bootstrapping system for the 1.9.x series. (currently 1.9.2).
 
  
The FPC 1.0/freebsd branch is considered legacy since I do all of the FreeBSD development, and have been working on 1.9 nearly exclusively since early 2003.
+
== COMPAT_ requirement of the port==
  
Moreover 1.0.10 is probably is the last release of the 1.0 branch, though maybe there will be some additional releases for the m68k and other non-core platforms that haven't been ported to 1.9.x yet.
+
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
  
So 1.0 is considered legacy, and I advise people to use the 1.9 series as much as possible. While officially a beta, 1.9.x is except some crashes on faulty code occasionally in general a compiler in better shape. The same goes for the 1.9.x rtl.
+
elfdump -n `which elfdump` |awk '/FreeBSD/{print $2}'
  
When when critical problems arrive, I'm willing to make patches for 1.0.x, but I won't do any release engineering for a new 1.0.x releases anymore, let alone
+
in the .long line  AFTER a .string "FreeBSD" line in cprt0.as.  
official ports tree entries.  
 
  
 +
I'm working on a script that I'll hopefully can still include with 2.2 to auto-fix this.
 
== FPC_USE_LIBC ==
 
== FPC_USE_LIBC ==
  
Line 60: Line 56:
  
 
The 1.0.x rtl was essentially a linux only hackish rtl. The rtl was rewritten in
 
The 1.0.x rtl was essentially a linux only hackish rtl. The rtl was rewritten in
version 1.9.x (and this still continues), and unfortunately, compatibility had to be broken.
+
version 1.9.x/2.x (and this still continues), and unfortunately, compatibility had to be broken.
  
 
For reasons and discussion, see [http://www.stack.nl/~marcov/unixrtl.pdf Unix Rtl Doc]
 
For reasons and discussion, see [http://www.stack.nl/~marcov/unixrtl.pdf Unix Rtl Doc]

Revision as of 19:20, 31 May 2008

FREEBSD bleeding edge notes

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, an also Darwin is sharing a lot of the generic BSD.

FreeBSD is the most mature of the BSD ports, though Darwin is rapidly catching up.

Supported FreeBSD versions (5.x..7.x)

FreeBSD is currently targeted at versions 5.x .. 7.x. There might be some features not available in 5.x, but they will be rare. (think like createguid/uuidgen or so).

Support for older versions

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)

  • 4.x has other startup code from 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.
  • Now bootstrap the compiler using OPT="-dFREEBSD4 -Xf"
  • copy sources + bootstrapped (static) compiler to 4.x
  • Bootstrap system (again with patched startup code and OPT="-Xf -dFREEBSD4"

write your experiences here under this paragraph since this is all just theory till now. I don't have a fbsd4 to actually try anymore.

5.x startup code

The first can be fixed for 1.0.10 (lang/fpc port) by running this shell script if you have 5.x, which takes the prefix where FPC is installed as optional parameter. (tested on 5.2)

libkse/libpthreads

Starting with 2.0.4 or so, the default is FreeBSD5 kse/pthreads threading instead of libc_r.

For this to work there must be at least one header set that has {$linklib c} {$linklib pthreads}

and there should be no direct use of {$linklib c_r} anymore, the compiler transforms the library list automatically to 4.x compat if -Xf is passed on the cmdline

Ports tree

FPC is currently available as 2.2.0 in the ports tree, maintained by José Alonso Cárdenas Márquez (acm@freebsd.org). Since 2.2.2 doesn't change anything fundamental, as a typical FIXES release, it will probably get updated quickly

COMPAT_ requirement of the port

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

elfdump -n `which elfdump` |awk '/FreeBSD/{print $2}'

in the .long line AFTER a .string "FreeBSD" line in cprt0.as.

I'm working on a script that I'll hopefully can still include with 2.2 to auto-fix this.

FPC_USE_LIBC

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)

Unix RTL, 1.0.x/1.9.x RTL compability

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.

For reasons and discussion, see Unix Rtl Doc