xref: /netbsd-src/share/man/man8/compat_freebsd.8 (revision 4b355e27b782b65a4e71cbb6e8c3431e4914ca37)
1.\"	$NetBSD: compat_freebsd.8,v 1.19 2018/02/10 08:54:22 maxv Exp $
2.\"	from: compat_linux.8,v 1.1 1995/03/05 23:30:36 fvdl Exp
3.\"
4.\" Copyright (c) 1995 Frank van der Linden
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"      This product includes software developed for the NetBSD Project
18.\"      by Frank van der Linden
19.\" 4. The name of the author may not be used to endorse or promote products
20.\"    derived from this software without specific prior written permission
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32.\"
33.Dd February 10, 2018
34.Dt COMPAT_FREEBSD 8
35.Os
36.Sh NAME
37.Nm compat_freebsd
38.Nd setup procedure for running FreeBSD binaries
39.Sh DESCRIPTION
40.Bf -symbolic
41compat_freebsd is not maintained anymore, and new FreeBSD binaries cannot
42be expected to work.
43The compat_freebsd feature is available in NetBSD only to support the
44FreeBSD tw_cli driver.
45.Ef
46.Pp
47.Nx
48supports running
49.Fx
50binaries.
51Most binaries should work, except programs that use
52.Fx Ns -specific
53features.
54These include i386-specific calls, such as syscons utilities.
55The
56.Fx
57compatibility feature is active for kernels compiled
58with the
59.Dv COMPAT_FREEBSD
60option enabled.
61.Pp
62A lot of programs are dynamically linked.
63This means, that you will also need the
64.Fx
65shared libraries that the program depends on, and the runtime
66linker.
67Also, you will need to create a
68.Dq shadow root
69directory for
70.Fx
71binaries on your
72.Nx
73system.
74This directory is named
75.Pa /emul/freebsd .
76Any file operations done by
77.Fx
78programs run under
79.Nx
80will look in this directory first.
81So, if a
82.Fx
83program opens, for example,
84.Pa /etc/passwd ,
85.Nx
86will
87first try to open
88.Pa /emul/freebsd/etc/passwd ,
89and if that does not exist open the
90.Sq real
91.Pa /etc/passwd
92file.
93It is recommended that you install
94.Fx
95packages that include configuration files, etc under
96.Pa /emul/freebsd ,
97to avoid naming conflicts with possible
98.Nx
99counterparts.
100Shared libraries should also be installed in the shadow tree.
101.Pp
102Generally, you will need to look for the shared libraries that
103.Fx
104binaries depend on only the first few times that you install a
105.Fx
106program on your
107.Nx
108system.
109After a while, you will have a sufficient set of
110.Fx
111shared libraries on your system to be able to run newly imported
112.Fx
113binaries without any extra work.
114.Ss Setting up shared libraries
115How to get to know which shared libraries
116.Fx
117binaries need, and where
118to get them? Basically, there are 2 possibilities (when following
119these instructions: you will need to be root on your
120.Nx
121system to do the necessary installation steps).
122.Pp
123.Bl -enum -compact
124.It
125You have access to a
126.Fx
127system.
128In this case you can temporarily install the binary there, see what
129shared libraries it needs, and copy them to your
130.Nx
131system.
132Example: you have just ftp-ed the
133.Fx
134binary of SimCity.
135Put it on the
136.Fx
137system you have access to, and check which shared libraries it
138needs by running
139.Sq ldd sim :
140.Bd -literal -offset indent
141me@freebsd% ldd /usr/local/lib/SimCity/res/sim
142/usr/local/lib/SimCity/res/sim:
143	-lXext.6 => /usr/X11R6/lib/libXext.so.6.0 (0x100c1000)
144	-lX11.6 => /usr/X11R6/lib/libX11.so.6.0 (0x100c9000)
145	-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
146	-lm.2 => /usr/lib/libm.so.2.0 (0x101a7000)
147	-lgcc.261 => /usr/lib/libgcc.so.261.0 (0x101bf000)
148.Ed
149.Pp
150You would need go get all the files from the last column, and
151put them under
152.Pa /emul/freebsd .
153This means you eventually have these files on your
154.Nx
155system:
156.Bl -item -compact
157.It
158.Pa /emul/freebsd/usr/X11R6/lib/libXext.so.6.0
159.It
160.Pa /emul/freebsd/usr/X11R6/lib/libX11.so.6.0
161.It
162.Pa /emul/freebsd/usr/lib/libc.so.2.1
163.It
164.Pa /emul/freebsd/usr/lib/libm.so.2.0
165.It
166.Pa /emul/freebsd/usr/lib/libgcc.so.261.0
167.El
168.Pp
169Note that if you already have a
170.Fx
171shared library with a matching major revision number to the first
172column of the
173.Ic ldd
174output, you won't need to copy the file named
175in the last column to your system, the one you already have should
176work.
177It is advisable to copy the shared library anyway if it is a newer version,
178though.
179You can remove the old one.
180So, if you have these libraries on your system:
181.Bl -item -compact
182.It
183.Pa /emul/freebsd/usr/lib/libc.so.2.0
184.El
185.Pp
186and you find that the ldd output for a new binary you want to
187install is:
188.Bd -literal
189\-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
190.Ed
191.Pp
192You won't need to worry about copying
193.Pa /usr/lib/libc.so.2.1
194too, because the program should work fine with the slightly older version.
195You can decide to replace the libc.so anyway, and that should leave
196you with:
197.Bl -item -compact
198.It
199.Pa /emul/freebsd/usr/lib/libc.so.2.1
200.El
201.Pp
202Finally, you must make sure that you have the
203.Fx
204runtime linker and its config files on your system.
205You should copy these files from the
206.Fx
207system to their appropriate place on your
208.Nx
209system (in the
210.Pa /emul/freebsd
211tree):
212.Bl -item -compact
213.It
214.Pa usr/libexec/ld.so
215.It
216.Pa var/run/ld.so.hints
217.El
218.It
219You don't have access to a
220.Fx
221system.
222In that case, you should get the extra files you need from various ftp sites.
223Information on where to look for the various files is appended
224below.
225For now, let's assume you know where to get the files.
226.Pp
227Retrieve the following files (from _one_ ftp site to avoid
228any version mismatches), and install them under
229.Pa /emul/freebsd
230(i.e.
231.Pa foo/bar
232is installed as
233.Pa /emul/freebsd/foo/bar ) :
234.Bl -item -compact
235.It
236.Pa sbin/ldconfig
237.It
238.Pa usr/bin/ldd
239.It
240.Pa usr/lib/libc.so.x.y.z
241.It
242.Pa usr/libexec/ld.so
243.El
244.Pp
245.Ic ldconfig
246and
247.Ic ldd
248don't necessarily need to be under
249.Pa /emul/freebsd ,
250you can install them elsewhere in the system too.
251Just make sure they don't conflict with their
252.Nx
253counterparts.
254A good idea would be to install them in
255.Pa /usr/local/bin
256as
257.Ic ldconfig-freebsd
258and
259.Ic ldd-freebsd .
260.Pp
261Run the
262.Fx
263ldconfig program with directory arguments in which the
264.Fx
265runtime linker should look for shared libs.
266.Pa /usr/lib
267are standard, you could run like the following:
268.Bd -literal -offset indent
269me@netbsd% mkdir -p /emul/freebsd/var/run
270me@netbsd% touch /emul/freebsd/var/run/ld.so.hints
271me@netbsd% ldconfig-freebsd /usr/X11R6/lib /usr/local/lib
272.Ed
273.Pp
274Note that argument directories of ldconfig are
275mapped to
276.Pa /emul/freebsd/XXXX
277by
278.Nx Ns 's
279compat code, and should exist as such on your system.
280Make sure
281.Pa /emul/freebsd/var/run/ld.so.hints
282is existing when you run
283.Fx Ns 's
284ldconfig, if not, you may lose
285.Nx Ns 's
286.Pa /var/run/ld.so.hints .
287.Fx
288.Ic ldconfig
289should be statically
290linked, so it doesn't need any shared libraries by itself.
291It will create the file
292.Pa /emul/freebsd/var/run/ld.so.hints .
293You should rerun the
294.Fx
295version of the ldconfig program each time you add a new shared library.
296.Pp
297You should now be set up for
298.Fx
299binaries which only need a shared libc.
300You can test this by running the
301.Fx
302.Ic ldd
303on itself.
304Suppose that you have it installed as
305.Ic ldd-freebsd ,
306it should produce something like:
307.Bd -literal -offset indent
308me@netbsd% ldd-freebsd `which ldd-freebsd`
309/usr/local/bin/ldd-freebsd:
310	-lc.2 => /usr/lib/libc.so.2.1 (0x1001a000)
311.Ed
312.Pp
313This being done, you are ready to install new
314.Fx
315binaries.
316Whenever you install a new
317.Fx
318program, you should check if it needs shared libraries, and if so,
319whether you have them installed in the
320.Pa /emul/freebsd
321tree.
322To do this, you run the
323.Fx
324version
325.Ic ldd
326on the new program, and watch its output.
327.Ic ldd
328(see also the manual page for
329.Xr ldd 1 )
330will print a list
331of shared libraries that the program depends on, in the
332form -l<majorname> => <fullname>.
333.Pp
334If it prints
335.Dq not found
336instead of <fullname> it means that you need an extra library.
337Which library this is, is shown
338in <majorname>, which will be of the form XXXX.<N>
339You will need to find a libXXXX.so.<N>.<mm> on a
340.Fx
341ftp site, and install it on your system.
342The XXXX (name) and <N> (major
343revision number) should match; the minor number(s) <mm> are
344less important, though it is advised to take the most
345recent version.
346.Pp
347.It
348In some cases,
349.Fx
350binary needs access to certain device file.
351For example,
352.Fx
353X server software needs
354.Fx
355.Pa /dev/ttyv0
356for ioctls.
357In this case, create a symbolic link from
358.Pa /emul/freebsd/dev/ttyv0
359to a
360.Xr wscons 4
361device file like
362.Pa /dev/ttyE0 .
363You will need to have at least
364.Cd options WSDISPLAY_COMPAT_SYSCONS
365and probably also
366.Cd options WSDISPLAY_COMPAT_USL
367in your kernel (see
368.Xr options 4
369and
370.Xr wscons 4 ) .
371.El
372.Ss Finding the necessary files
373.Em Note :
374the information below is valid as of the time this
375document was written (June, 1995), but certain details
376such as names of ftp sites, directories and distribution names
377may have changed by the time you read this.
378.Pp
379The
380.Fx
381distribution is available on a lot of ftp sites.
382Sometimes the files are unpacked, and you can get the individual
383files you need, but mostly they are stored in distribution sets,
384usually consisting of subdirectories with gzipped tar files in them.
385The ftp site for the distributions is:
386.Lk ftp://ftp.FreeBSD.org/pub/FreeBSD
387.Pp
388This distribution consists of a number of tar-ed and gzipped files,
389Normally, they're controlled by an install program, but you can
390retrieve files
391.Dq by hand
392too.
393The way to look something up is to retrieve all the files in the
394distribution, and ``tar ztvf'' through them for the file you need.
395Here is an example of a list of files that you might need.
396.Bd -literal -offset indent
397Needed                 Files
398
399ld.so                  2.0-RELEASE/bindist/bindist.??
400ldconfig               2.0-RELEASE/bindist/bindist.??
401ldd                    2.0-RELEASE/bindist/bindist.??
402libc.so.2              2.0-RELEASE/bindist/bindist.??
403libX11.so.6.0          2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz
404libX11.so.6.0          XFree86-3.1.1/X311bin.tgz
405libXt.so.6.0           2.0-RELEASE/XFree86-3.1/XFree86-3.1-bin.tar.gz
406libXt.so.6.0           XFree86-3.1.1/X311bin.tgz
407.\" libX11.so.3            oldlibs
408.\" libXt.so.3             oldlibs
409.Ed
410.Pp
411The files called
412.Dq bindist.??
413are tar-ed, gzipped and split, so you can extract contents by
414.Dq cat bindist.?? | tar zpxf - .
415.Pp
416Extract the files from these gzipped tarfiles in your
417.Pa /emul/freebsd
418directory (possibly omitting or afterwards removing files you don't
419need), and you are done.
420.Sh BUGS
421The information about
422.Fx
423distributions may become outdated.
424