xref: /netbsd-src/share/man/man8/compat_freebsd.8 (revision 4b355e27b782b65a4e71cbb6e8c3431e4914ca37)
1*4b355e27Smaxv.\"	$NetBSD: compat_freebsd.8,v 1.19 2018/02/10 08:54:22 maxv Exp $
26c2d0559Sexplorer.\"	from: compat_linux.8,v 1.1 1995/03/05 23:30:36 fvdl Exp
36c2d0559Sexplorer.\"
46c2d0559Sexplorer.\" Copyright (c) 1995 Frank van der Linden
56c2d0559Sexplorer.\" All rights reserved.
66c2d0559Sexplorer.\"
76c2d0559Sexplorer.\" Redistribution and use in source and binary forms, with or without
86c2d0559Sexplorer.\" modification, are permitted provided that the following conditions
96c2d0559Sexplorer.\" are met:
106c2d0559Sexplorer.\" 1. Redistributions of source code must retain the above copyright
116c2d0559Sexplorer.\"    notice, this list of conditions and the following disclaimer.
126c2d0559Sexplorer.\" 2. Redistributions in binary form must reproduce the above copyright
136c2d0559Sexplorer.\"    notice, this list of conditions and the following disclaimer in the
146c2d0559Sexplorer.\"    documentation and/or other materials provided with the distribution.
156c2d0559Sexplorer.\" 3. All advertising materials mentioning features or use of this software
166c2d0559Sexplorer.\"    must display the following acknowledgement:
176c2d0559Sexplorer.\"      This product includes software developed for the NetBSD Project
186c2d0559Sexplorer.\"      by Frank van der Linden
196c2d0559Sexplorer.\" 4. The name of the author may not be used to endorse or promote products
206c2d0559Sexplorer.\"    derived from this software without specific prior written permission
216c2d0559Sexplorer.\"
226c2d0559Sexplorer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
236c2d0559Sexplorer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
246c2d0559Sexplorer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
256c2d0559Sexplorer.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
266c2d0559Sexplorer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
276c2d0559Sexplorer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
286c2d0559Sexplorer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
296c2d0559Sexplorer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
306c2d0559Sexplorer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
316c2d0559Sexplorer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
326c2d0559Sexplorer.\"
33*4b355e27Smaxv.Dd February 10, 2018
346c2d0559Sexplorer.Dt COMPAT_FREEBSD 8
3539b11db8Sgarbled.Os
366c2d0559Sexplorer.Sh NAME
371009df02Smikel.Nm compat_freebsd
386c2d0559Sexplorer.Nd setup procedure for running FreeBSD binaries
396c2d0559Sexplorer.Sh DESCRIPTION
40*4b355e27Smaxv.Bf -symbolic
41*4b355e27Smaxvcompat_freebsd is not maintained anymore, and new FreeBSD binaries cannot
42*4b355e27Smaxvbe expected to work.
43*4b355e27SmaxvThe compat_freebsd feature is available in NetBSD only to support the
44*4b355e27SmaxvFreeBSD tw_cli driver.
45*4b355e27Smaxv.Ef
46*4b355e27Smaxv.Pp
4734a98169Sperry.Nx
4834a98169Sperrysupports running
4934a98169Sperry.Fx
50c46ab392Sfairbinaries.
51c46ab392SfairMost binaries should work, except programs that use
5234a98169Sperry.Fx Ns -specific
53c46ab392Sfairfeatures.
54c46ab392SfairThese include i386-specific calls, such as syscons utilities.
5534a98169SperryThe
5634a98169Sperry.Fx
5734a98169Sperrycompatibility feature is active for kernels compiled
586c2d0559Sexplorerwith the
591009df02Smikel.Dv COMPAT_FREEBSD
606c2d0559Sexploreroption enabled.
611009df02Smikel.Pp
62ee97be87SwizA lot of programs are dynamically linked.
63ee97be87SwizThis means, that you will also need the
6434a98169Sperry.Fx
65c46ab392Sfairshared libraries that the program depends on, and the runtime
66ee97be87Swizlinker.
67ee97be87SwizAlso, you will need to create a
687c792961Swiz.Dq shadow root
697c792961Swizdirectory for
7034a98169Sperry.Fx
7134a98169Sperrybinaries on your
7234a98169Sperry.Nx
73ee97be87Swizsystem.
74ee97be87SwizThis directory is named
75c46ab392Sfair.Pa /emul/freebsd .
76c46ab392SfairAny file operations done by
7734a98169Sperry.Fx
78c46ab392Sfairprograms run under
7934a98169Sperry.Nx
80c46ab392Sfairwill look in this directory first.
81c46ab392SfairSo, if a
8234a98169Sperry.Fx
83c46ab392Sfairprogram opens, for example,
84c46ab392Sfair.Pa /etc/passwd ,
8534a98169Sperry.Nx
8634a98169Sperrywill
87c46ab392Sfairfirst try to open
88c46ab392Sfair.Pa /emul/freebsd/etc/passwd ,
897c792961Swizand if that does not exist open the
907c792961Swiz.Sq real
91c46ab392Sfair.Pa /etc/passwd
92c46ab392Sfairfile.
93c46ab392SfairIt is recommended that you install
9434a98169Sperry.Fx
95c46ab392Sfairpackages that include configuration files, etc under
96c46ab392Sfair.Pa /emul/freebsd ,
9734a98169Sperryto avoid naming conflicts with possible
9834a98169Sperry.Nx
99ee97be87Swizcounterparts.
100ee97be87SwizShared libraries should also be installed in the shadow tree.
1016c2d0559Sexplorer.Pp
10234a98169SperryGenerally, you will need to look for the shared libraries that
10334a98169Sperry.Fx
10434a98169Sperrybinaries depend on only the first few times that you install a
10534a98169Sperry.Fx
10634a98169Sperryprogram on your
10734a98169Sperry.Nx
108ee97be87Swizsystem.
109ee97be87SwizAfter a while, you will have a sufficient set of
11034a98169Sperry.Fx
1117c792961Swizshared libraries on your system to be able to run newly imported
11234a98169Sperry.Fx
11334a98169Sperrybinaries without any extra work.
1146c2d0559Sexplorer.Ss Setting up shared libraries
11534a98169SperryHow to get to know which shared libraries
11634a98169Sperry.Fx
11734a98169Sperrybinaries need, and where
1186c2d0559Sexplorerto get them? Basically, there are 2 possibilities (when following
11934a98169Sperrythese instructions: you will need to be root on your
12034a98169Sperry.Nx
121c46ab392Sfairsystem to do the necessary installation steps).
1227c792961Swiz.Pp
1237c792961Swiz.Bl -enum -compact
1247c792961Swiz.It
12534a98169SperryYou have access to a
12634a98169Sperry.Fx
127c46ab392Sfairsystem.
128c46ab392SfairIn this case you can temporarily install the binary there, see what
129c46ab392Sfairshared libraries it needs, and copy them to your
13034a98169Sperry.Nx
131c46ab392Sfairsystem.
132c46ab392SfairExample: you have just ftp-ed the
13334a98169Sperry.Fx
134c46ab392Sfairbinary of SimCity.
135c46ab392SfairPut it on the
13634a98169Sperry.Fx
1376c2d0559Sexplorersystem you have access to, and check which shared libraries it
1387c792961Swizneeds by running
1397c792961Swiz.Sq ldd sim :
140c76e625fSnjoly.Bd -literal -offset indent
141c76e625fSnjolyme@freebsd% ldd /usr/local/lib/SimCity/res/sim
1426c2d0559Sexplorer/usr/local/lib/SimCity/res/sim:
14301869ca4Swiz	-lXext.6 => /usr/X11R6/lib/libXext.so.6.0 (0x100c1000)
14401869ca4Swiz	-lX11.6 => /usr/X11R6/lib/libX11.so.6.0 (0x100c9000)
14501869ca4Swiz	-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
14601869ca4Swiz	-lm.2 => /usr/lib/libm.so.2.0 (0x101a7000)
14701869ca4Swiz	-lgcc.261 => /usr/lib/libgcc.so.261.0 (0x101bf000)
148c76e625fSnjoly.Ed
1496c2d0559Sexplorer.Pp
1506c2d0559SexplorerYou would need go get all the files from the last column, and
151c46ab392Sfairput them under
152c46ab392Sfair.Pa /emul/freebsd .
153c46ab392SfairThis means you eventually have these files on your
15434a98169Sperry.Nx
15534a98169Sperrysystem:
1567c792961Swiz.Bl -item -compact
1577c792961Swiz.It
158c46ab392Sfair.Pa /emul/freebsd/usr/X11R6/lib/libXext.so.6.0
1597c792961Swiz.It
160c46ab392Sfair.Pa /emul/freebsd/usr/X11R6/lib/libX11.so.6.0
1617c792961Swiz.It
162c46ab392Sfair.Pa /emul/freebsd/usr/lib/libc.so.2.1
1637c792961Swiz.It
164c46ab392Sfair.Pa /emul/freebsd/usr/lib/libm.so.2.0
1657c792961Swiz.It
166c46ab392Sfair.Pa /emul/freebsd/usr/lib/libgcc.so.261.0
1677c792961Swiz.El
1686c2d0559Sexplorer.Pp
16934a98169SperryNote that if you already have a
17034a98169Sperry.Fx
171c46ab392Sfairshared library with a matching major revision number to the first
1727c792961Swizcolumn of the
1737c792961Swiz.Ic ldd
1747c792961Swizoutput, you won't need to copy the file named
175c46ab392Sfairin the last column to your system, the one you already have should
176c46ab392Sfairwork.
177c46ab392SfairIt is advisable to copy the shared library anyway if it is a newer version,
178c46ab392Sfairthough.
179c46ab392SfairYou can remove the old one.
180c46ab392SfairSo, if you have these libraries on your system:
1817c792961Swiz.Bl -item -compact
1827c792961Swiz.It
183c46ab392Sfair.Pa /emul/freebsd/usr/lib/libc.so.2.0
1847c792961Swiz.El
1856c2d0559Sexplorer.Pp
1866c2d0559Sexplorerand you find that the ldd output for a new binary you want to
1876c2d0559Sexplorerinstall is:
188c76e625fSnjoly.Bd -literal
18901869ca4Swiz\-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
190c76e625fSnjoly.Ed
1916c2d0559Sexplorer.Pp
192c46ab392SfairYou won't need to worry about copying
1937c792961Swiz.Pa /usr/lib/libc.so.2.1
1947c792961Swiztoo, because the program should work fine with the slightly older version.
1956c2d0559SexplorerYou can decide to replace the libc.so anyway, and that should leave
1966c2d0559Sexploreryou with:
1977c792961Swiz.Bl -item -compact
1987c792961Swiz.It
199c46ab392Sfair.Pa /emul/freebsd/usr/lib/libc.so.2.1
2007c792961Swiz.El
2016c2d0559Sexplorer.Pp
20234a98169SperryFinally, you must make sure that you have the
20334a98169Sperry.Fx
204c46ab392Sfairruntime linker and its config files on your system.
205c46ab392SfairYou should copy these files from the
20634a98169Sperry.Fx
20734a98169Sperrysystem to their appropriate place on your
20834a98169Sperry.Nx
209c46ab392Sfairsystem (in the
210c46ab392Sfair.Pa /emul/freebsd
211c46ab392Sfairtree):
2127c792961Swiz.Bl -item -compact
2137c792961Swiz.It
214c46ab392Sfair.Pa usr/libexec/ld.so
2157c792961Swiz.It
216c46ab392Sfair.Pa var/run/ld.so.hints
2177c792961Swiz.El
2187c792961Swiz.It
21934a98169SperryYou don't have access to a
22034a98169Sperry.Fx
221ee97be87Swizsystem.
222ee97be87SwizIn that case, you should get the extra files you need from various ftp sites.
2236c2d0559SexplorerInformation on where to look for the various files is appended
224ee97be87Swizbelow.
225ee97be87SwizFor now, let's assume you know where to get the files.
2266c2d0559Sexplorer.Pp
2276c2d0559SexplorerRetrieve the following files (from _one_ ftp site to avoid
2287c792961Swizany version mismatches), and install them under
2297c792961Swiz.Pa /emul/freebsd
2307c792961Swiz(i.e.
2317c792961Swiz.Pa foo/bar
2327c792961Swizis installed as
2337c792961Swiz.Pa /emul/freebsd/foo/bar ) :
2347c792961Swiz.Bl -item -compact
2357c792961Swiz.It
236c46ab392Sfair.Pa sbin/ldconfig
2377c792961Swiz.It
238c46ab392Sfair.Pa usr/bin/ldd
2397c792961Swiz.It
240c46ab392Sfair.Pa usr/lib/libc.so.x.y.z
2417c792961Swiz.It
242c46ab392Sfair.Pa usr/libexec/ld.so
2437c792961Swiz.El
2446c2d0559Sexplorer.Pp
2457c792961Swiz.Ic ldconfig
2467c792961Swizand
2477c792961Swiz.Ic ldd
2487c792961Swizdon't necessarily need to be under
249c46ab392Sfair.Pa /emul/freebsd ,
250ee97be87Swizyou can install them elsewhere in the system too.
251ee97be87SwizJust make sure they don't conflict with their
25234a98169Sperry.Nx
253c46ab392Sfaircounterparts.
254c46ab392SfairA good idea would be to install them in
255c46ab392Sfair.Pa /usr/local/bin
2567c792961Swizas
2577c792961Swiz.Ic ldconfig-freebsd
2587c792961Swizand
2597c792961Swiz.Ic ldd-freebsd .
2606c2d0559Sexplorer.Pp
26134a98169SperryRun the
26234a98169Sperry.Fx
263c46ab392Sfairldconfig program with directory arguments in which the
26434a98169Sperry.Fx
26534a98169Sperryruntime linker should look for shared libs.
266c46ab392Sfair.Pa /usr/lib
267c46ab392Sfairare standard, you could run like the following:
268c76e625fSnjoly.Bd -literal -offset indent
269c76e625fSnjolyme@netbsd% mkdir -p /emul/freebsd/var/run
270c76e625fSnjolyme@netbsd% touch /emul/freebsd/var/run/ld.so.hints
271c76e625fSnjolyme@netbsd% ldconfig-freebsd /usr/X11R6/lib /usr/local/lib
272c76e625fSnjoly.Ed
2736c2d0559Sexplorer.Pp
2746c2d0559SexplorerNote that argument directories of ldconfig are
275c46ab392Sfairmapped to
276c46ab392Sfair.Pa /emul/freebsd/XXXX
277c46ab392Sfairby
27834a98169Sperry.Nx Ns 's
27934a98169Sperrycompat code, and should exist as such on your system.
280c46ab392SfairMake sure
281c46ab392Sfair.Pa /emul/freebsd/var/run/ld.so.hints
282c46ab392Sfairis existing when you run
28334a98169Sperry.Fx Ns 's
28434a98169Sperryldconfig, if not, you may lose
28534a98169Sperry.Nx Ns 's
286c46ab392Sfair.Pa /var/run/ld.so.hints .
28734a98169Sperry.Fx
2887c792961Swiz.Ic ldconfig
2897c792961Swizshould be statically
2906c2d0559Sexplorerlinked, so it doesn't need any shared libraries by itself.
291c46ab392SfairIt will create the file
292c46ab392Sfair.Pa /emul/freebsd/var/run/ld.so.hints .
29334a98169SperryYou should rerun the
29434a98169Sperry.Fx
295c46ab392Sfairversion of the ldconfig program each time you add a new shared library.
2966c2d0559Sexplorer.Pp
29734a98169SperryYou should now be set up for
29834a98169Sperry.Fx
299c46ab392Sfairbinaries which only need a shared libc.
300c46ab392SfairYou can test this by running the
30134a98169Sperry.Fx
3027c792961Swiz.Ic ldd
303ee97be87Swizon itself.
304ee97be87SwizSuppose that you have it installed as
3057c792961Swiz.Ic ldd-freebsd ,
3067c792961Swizit should produce something like:
307c76e625fSnjoly.Bd -literal -offset indent
308c76e625fSnjolyme@netbsd% ldd-freebsd `which ldd-freebsd`
3096c2d0559Sexplorer/usr/local/bin/ldd-freebsd:
31001869ca4Swiz	-lc.2 => /usr/lib/libc.so.2.1 (0x1001a000)
311c76e625fSnjoly.Ed
3126c2d0559Sexplorer.Pp
31334a98169SperryThis being done, you are ready to install new
31434a98169Sperry.Fx
31534a98169Sperrybinaries.
31634a98169SperryWhenever you install a new
31734a98169Sperry.Fx
318c46ab392Sfairprogram, you should check if it needs shared libraries, and if so,
319c46ab392Sfairwhether you have them installed in the
320c46ab392Sfair.Pa /emul/freebsd
321c46ab392Sfairtree.
322c46ab392SfairTo do this, you run the
32334a98169Sperry.Fx
3247c792961Swizversion
3257c792961Swiz.Ic ldd
3267c792961Swizon the new program, and watch its output.
3277c792961Swiz.Ic ldd
3287c792961Swiz(see also the manual page for
329c46ab392Sfair.Xr ldd 1 )
330c46ab392Sfairwill print a list
3316c2d0559Sexplorerof shared libraries that the program depends on, in the
33201869ca4Swizform -l<majorname> => <fullname>.
3336c2d0559Sexplorer.Pp
3347c792961SwizIf it prints
3357c792961Swiz.Dq not found
33601869ca4Swizinstead of <fullname> it means that you need an extra library.
337c46ab392SfairWhich library this is, is shown
33801869ca4Swizin <majorname>, which will be of the form XXXX.<N>
33901869ca4SwizYou will need to find a libXXXX.so.<N>.<mm> on a
34034a98169Sperry.Fx
3417c792961Swizftp site, and install it on your system.
34201869ca4SwizThe XXXX (name) and <N> (major
34301869ca4Swizrevision number) should match; the minor number(s) <mm> are
3446c2d0559Sexplorerless important, though it is advised to take the most
3456c2d0559Sexplorerrecent version.
34673383f35Sitojun.Pp
3477c792961Swiz.It
34873383f35SitojunIn some cases,
34973383f35Sitojun.Fx
35073383f35Sitojunbinary needs access to certain device file.
35173383f35SitojunFor example,
35273383f35Sitojun.Fx
35373383f35SitojunX server software needs
35473383f35Sitojun.Fx
35573383f35Sitojun.Pa /dev/ttyv0
356ee97be87Swizfor ioctls.
357ee97be87SwizIn this case, create a symbolic link from
35873383f35Sitojun.Pa /emul/freebsd/dev/ttyv0
359578d9d0fSwizto a
360b72e65d5Sitojun.Xr wscons 4
361b72e65d5Sitojundevice file like
362578d9d0fSwiz.Pa /dev/ttyE0 .
363578d9d0fSwizYou will need to have at least
364578d9d0fSwiz.Cd options WSDISPLAY_COMPAT_SYSCONS
365578d9d0fSwizand probably also
366578d9d0fSwiz.Cd options WSDISPLAY_COMPAT_USL
367578d9d0fSwizin your kernel (see
368578d9d0fSwiz.Xr options 4
369578d9d0fSwizand
370578d9d0fSwiz.Xr wscons 4 ) .
3716c2d0559Sexplorer.El
372f3355d32Swiz.Ss Finding the necessary files
3731009df02Smikel.Em Note :
3741009df02Smikelthe information below is valid as of the time this
3751009df02Smikeldocument was written (June, 1995), but certain details
3766c2d0559Sexplorersuch as names of ftp sites, directories and distribution names
3776c2d0559Sexplorermay have changed by the time you read this.
3786c2d0559Sexplorer.Pp
37934a98169SperryThe
38034a98169Sperry.Fx
381c46ab392Sfairdistribution is available on a lot of ftp sites.
382c46ab392SfairSometimes the files are unpacked, and you can get the individual
383c46ab392Sfairfiles you need, but mostly they are stored in distribution sets,
384c46ab392Sfairusually consisting of subdirectories with gzipped tar files in them.
385a81ff05aSsevanThe ftp site for the distributions is:
3866a689d47Swiz.Lk ftp://ftp.FreeBSD.org/pub/FreeBSD
3876c2d0559Sexplorer.Pp
3886c2d0559SexplorerThis distribution consists of a number of tar-ed and gzipped files,
3896c2d0559SexplorerNormally, they're controlled by an install program, but you can
3907c792961Swizretrieve files
3917c792961Swiz.Dq by hand
392ee97be87Swiztoo.
393ee97be87SwizThe way to look something up is to retrieve all the files in the
394c46ab392Sfairdistribution, and ``tar ztvf'' through them for the file you need.
395c46ab392SfairHere is an example of a list of files that you might need.
396225791c7Swiz.Bd -literal -offset indent
3976c2d0559SexplorerNeeded                 Files
3986c2d0559Sexplorer
3996c2d0559Sexplorerld.so                  2.0-RELEASE/bindist/bindist.??
4006c2d0559Sexplorerldconfig               2.0-RELEASE/bindist/bindist.??
4016c2d0559Sexplorerldd                    2.0-RELEASE/bindist/bindist.??
4026c2d0559Sexplorerlibc.so.2              2.0-RELEASE/bindist/bindist.??
4036c2d0559SexplorerlibX11.so.6.0          2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz
4046c2d0559SexplorerlibX11.so.6.0          XFree86-3.1.1/X311bin.tgz
4056c2d0559SexplorerlibXt.so.6.0           2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz
4066c2d0559SexplorerlibXt.so.6.0           XFree86-3.1.1/X311bin.tgz
4076c2d0559Sexplorer.\" libX11.so.3            oldlibs
4086c2d0559Sexplorer.\" libXt.so.3             oldlibs
4096c2d0559Sexplorer.Ed
4106c2d0559Sexplorer.Pp
4117c792961SwizThe files called
4127c792961Swiz.Dq bindist.??
4137c792961Swizare tar-ed, gzipped and split, so you can extract contents by
4147c792961Swiz.Dq cat bindist.?? | tar zpxf - .
4156c2d0559Sexplorer.Pp
416c46ab392SfairExtract the files from these gzipped tarfiles in your
417c46ab392Sfair.Pa /emul/freebsd
418c46ab392Sfairdirectory (possibly omitting or afterwards removing files you don't
419c46ab392Sfairneed), and you are done.
4206c2d0559Sexplorer.Sh BUGS
42134a98169SperryThe information about
42234a98169Sperry.Fx
42334a98169Sperrydistributions may become outdated.
424