Subject: Re: Object compatibility between BSDs
To: None <crvich@us.ibm.com>
From: Thor Lancelot Simon <tls@rek.tjls.com>
List: port-i386
Date: 01/20/2000 11:11:54
On Thu, Jan 20, 2000 at 10:48:26AM -0500, crvich@us.ibm.com wrote:
> 
> 
>      Having ported our project to NetBSD 1.3.3, we are obviously interested
> in porting to FreeBSD and OpenBSD as well.  A colleague claimed that BSD
> a.out objects should be usable as-is on all three OS's, but I've tried our
> exe's on OpenBSD 2.5 with no luck ("Bad system call").  And we are even
> statically linked with ALL libraries (libc, etc.), so it shouldn't be a lib
> compatibility problem.

Your colleague was correct that all three BSD variants can execute a.out
format files.

The problem occurs -- even with statically linked binaries -- when your
program makes a system call that is not supported by the kernel you are
trying to use to execute the file in question.  Since FreeBSD diverged
from NetBSD around NetBSD 0.8, and OpenBSD diverged from NetBSD around
NetBSD 1.2, you can assume that you'll run into plenty of system calls
in the NetBSD 1.3.3 C library that aren't included in the other variants,
or, possibly, are included but have different system call numbers.

If what I surmise about your environment is correct, you may encounter
another problem: you may have some libraries that aren't included in
the stock NetBSD 1.3.3 release, or that have been modified and now
use nonstandard system calls (if you were running NCOS, this would
definitely be the case).  A program linked to such libraries might
appear to work fine until suddenly in some rare case it hit a bad
system call and crashed...

Basically, the only way to maintain your sanity is to build distinct
binaries for each operating system.  There are tricks you could try
like porting to a *very* old NetBSD such as 1.0 or 1.1, but I think
you'd end up wishing you hadn't -- even up-to-date NetBSD users
couldn't run the resulting binaries without a lot of compatibility
options turned on.

If you've ported cleanly (with #ifdef BSD, #if BSD > N instead of
#ifdef __NetBSD__ wherever possible) it shouldn't be tootoomuch
work to do more ports.

-- 
Thor Lancelot Simon	                                      tls@rek.tjls.com
	"And where do all these highways go, now that we are free?"