Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Oct 1995 17:41:48 -0500 (EST)
From:      John Fieber <jfieber@indiana.edu>
To:        Nate Williams <nate@rocky.sri.MT.net>
Cc:        stable@FreeBSD.org
Subject:   Re: Linux emulator working?
Message-ID:  <Pine.BSF.3.91.951018174034.13692A-100000@fieber-john.campusview.indiana.edu>
In-Reply-To: <199510182217.QAA11314@rocky.sri.MT.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 18 Oct 1995, Nate Williams wrote:

> Does anyone have the emulator working under -stable?
> 
> Here's the steps I did:

...

> What am I doing wrong?  What can I do to fix this?  I'm going to try to
> get Linux-IDL running under FreeBSD to see how the performance compares
> to the SPARC version we have.

Maybe the attached will help?

-john

== jfieber@indiana.edu ===========================================
== http://fieber-john.campusview.indiana.edu/~jfieber ============

>From rich@lamprey.utmb.eduWed Oct 18 17:40:15 1995
Date: Wed, 20 Sep 1995 09:27:00 -0500
From: Rich Murphey <rich@lamprey.utmb.edu>
To: FreeBSD-current@freefall.freebsd.org
Subject: linux compatibility man page

I took netbsd's man page for linux compatibility and added a
brief installation guide.  I've sent Jordan the nroff source
for review.

Any suggestions are welcome!


Many thanks to Soren Schmidt for the emulator itself! Rich




COMPAT LINUX(8)          UNIX System Manager's Manual          COMPAT LINUX(8)
      -                                                              -

NAME
     COMPAT LINUX - setup procedure for running Linux binaries
           -

INSTALL
     In order to run static and dynamicly linked Linux binaries, you need a
     kernel configured with options COMPAT LINUX. Include options SYSVSHM as
                                          -
     well if you plan to run the linux version of doom.

     cd /sys/i386/conf
     echo options '"COMPAT LINUX"' >> GENERIC
                          -
     echo options SYSVSHM >> GENERIC
     config GENERIC
     cd /sys/compile/GENERIC
     make depend; make
     make install

     If you don't already have it, build the loadable kernel module
     /lkm/linux mod.o.
               -

     cd /usr/src/lkm/linux
     make all install clean

     Once you have both the kernel and lkm installed, invoke

     linux

     as root to load the emulator into the kernel.

TESTING
     To test the emulator using the linux version of the game doom, first get
     the linux shared libraries.

     mkdir /compat/linux
     cd /compat/linux
     ncftp ftp.freebsd.org:pub/FreeBSD/2.0.5-RELEASE/xperimnt/linux-emu/linux-emu.tar.gz
     tar xzf linux-emu.tar.gz
     rm -rf usr lkm linux-emu.tar.gz

     The lkm and usr portion of this tar file are redundant since you already
     have the lkm and /usr/bin/linux.  Next install doom itself.

     ncftp ftp.freebsd.org:pub/FreeBSD/2.0.5-RELEASE/xperimnt/linux-emu/linux-doom-1.8.tar.gz
     tar xzf linux-doom-1.8.tar.gz
     cd doom-1.8
     xdoom

DESCRIPTION
     Most Linux binaries should work, except programs that use Linux-specific
     features. These include the Linux /proc filesystem (which is different
     from the optional FreeBSD /proc filesystem), and i386-specific calls,
     such as enabling virtual 8086 mode.

     Many linux programs are dynamically linked. So you will also need the
     Linux shared libraries that the program depends on, and the runtime link-
     er.  Also, you will need to create a "shadow root" directory for Linux
     binaries on your FreeBSD system. This directory is named /compat/linux.
     Any file operations done by Linux programs run under FreeBSD will look in
     this directory first.  So, if a Linux program opens, for example,
     /etc/passwd, FreeBSD will first try to open /compat/linux/etc/passwd, and
     if that does not exist open the packages that include configuration
     files, etc under /compat/linux, to avoid naming conflicts with possible
     FreeBSD counterparts. Shared libraries should also be installed in the
     shadow tree.

     Generally, you will need to look for the shared libraries that Linux bi-
     naries depend on only the first few times that you install a Linux pro-
     gram on your FreeBSD system. After a while, you will have a sufficient
     set of Linux shared libraries on your system to be able to run newly im-
     ported Linux binaries without any extra work.


   Setting up shared libraries
     How to get to know which shared libraries Linux binaries need, and where
     to get them? Basically, there are 2 possibilities (when following these
     instructions: you will need to be root on your FreeBSD system to do the
     necessary installation steps).

     1.   If you have access to a Linux system, see what shared libraries it
          needs, and copy them to your FreeBSD system. Example: you have just
          ftp-ed the Linux binary of Doom. Put it on the Linux system you have
          access to, and check which shared libraries it needs by running `ldd
          linuxxdoom':

                (me@linux) ldd linuxxdoom
                     libXt.so.3 (DLL Jump 3.1) => /usr/X11/lib/libXt.so.3.1.0
                     libX11.so.3 (DLL Jump 3.1) => /usr/X11/lib/libX11.so.3.1.0
                     libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29

          You would need go get all the files from the last column, and put
          them under /compat/linux, with the names in the first column as sym-
          bolic links pointing to them. This means you eventually have these
          files on your FreeBSD system:

          /compat/linux/usr/X11/lib/libXt.so.3.1.0
          /compat/linux/usr/X11/lib/libXt.so.3 (symbolic link to the above)
          /compat/linux/usr/X11/lib/libX11.so.3.1.0
          /compat/linux/usr/X11/lib/libX11.so.3 (symbolic link to the above)
          /compat/linux/lib/libc.so.4.6.29
          /compat/linux/lib/libc.so.4 (symbolic link to the above)

          Note that if you already have a Linux shared library with a matching
          major revision number to the first column of the 'ldd' output, you
          won't need to copy the file named in the last column to your system,
          the one you already have should work. It is advisable to copy the
          shared library anyway if it is a newer version, though. You can re-
          move the old one, as long as you make the symbolic link point to the
          new one. So, if you have these libraries on your system:

          /compat/linux/lib/libc.so.4.6.27
          /compat/linux/lib/libc.so.4 -> /compat/linux/lib/libc.so.4.6.27

          and you find that the ldd output for a new binary you want to in-
          stall is:

          libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29

          you won't need to worry about copying /lib/libc.so.4.6.29 too, be-
          cause the program should work fine with the slightly older version.
          You can decide to replace the libc.so anyway, and that should leave
          you with:

          /compat/linux/lib/libc.so.4.6.29
          /compat/linux/lib/libc.so.4 -> /compat/linux/lib/libc.so.4.6.29

          Please note that the symbolic link mechanism is only needed for Lin-
          ux binaries, the FreeBSD runtime linker takes care of looking for
          matching major revision numbers itself, you don't need to worry
          about that.

          Finally, you must make sure that you have the Linux runtime linker
          and its config files on your system. You should copy these files
          from the Linux system to their appropriate place on your FreeBSD
          system (to the /compat/linux tree):

          /lib/ld.so
          /etc/ld.so.cache
          /etc/ld.so.config

     2.   You don't have access to a Linux system. In that case, you should
          get the extra files you need from various ftp sites.  Information on
          where to look for the various files is appended below. For now,
          let's assume you know where to get the files.

          Retrieve the following files (all from the same ftp site to avoid
          any version mismatches), and install them under /compat/linux (i.e.
          /foo/bar is installed as /compat/linux/foo/bar):

          /sbin/ldconfig
          /usr/bin/ldd
          /lib/libc.so.x.y.z
          /lib/ld.so

          ldconfig and ldd don't necessarily need to be under /compat/linux,
          you can install them elsewhere in the system too. Just make sure
          they don't conflict with their FreeBSD counterparts. A good idea
          would be to install them in /usr/local/bin as ldconfig-linux and
          ldd-linux.

          Create the file /compat/linux/etc/ld.so.conf, containing the direc-
          tories in which the Linux runtime linker should look for shared
          libs. It is a plain text file, containing a directory name on each
          line. /lib and /usr/lib are standard, you could add the following:

          /usr/X11/lib
          /usr/local/lib

          Note that these are mapped to /compat/linux/XXXX by FreeBSD's compat
          code, and should exist as such on your system.

          Run the Linux ldconfig program. It should be statically linked, so
          it doesn't need any shared libraries by itself.  It will create the
          file /compat/linux/etc/ld.so.cache You should rerun the Linux ver-
          sion of the ldconfig program each time you add a new shared library.

          You should now be set up for Linux binaries which only need a shared
          libc. You can test this by running the Linux ldd on itself. Suppose
          that you have it installed as ldd-linux, it should produce something
          like:

                (me@FreeBSD) ldd-linux `which ldd-linux`
                     libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29

          This being done, you are ready to install new Linux binaries.  When-
          ever you install a new Linux program, you should check if it needs
          shared libraries, and if so, whether you have them installed in the
          /compat/linux tree. To do this, you run the Linux version ldd on the
          new program, and watch its output.  ldd (see also the manual page
          for ldd(1)) will print a list of shared libraries that the program
          depends on, in the form  <majorname> (<jumpversion>) => <fullname>.

          If it prints "not found" in stead of <fullname> it means that you
          need an extra library. Which library this is, is shown in <major-
          name>, which will be of the form libXXXX.so.<N> You will need to
          find a libXXXX.so.<N>.<mm> on a Linux ftp site, and install it on
          your system. The XXXX (name) and <N> (major revision number) should
          match; the minor number(s) <mm> are less important, though it is ad-
          vised to take the most recent version.


   Finding the necessary files.
     Note: the information below is valid as of the ime this document was
     written (March, 1995), but certain details such as names of ftp sites,
     directories and distribution names may have changed by the time you read
     this.

     Linux is distributed by several groups that make their own set of bina-
     ries that they distribute. Each distribution has its own name, like
     "Slackware" or "Yggdrasil". The distributions are available on a lot of
     ftp sites. Sometimes the files are unpacked, and you can get the individ-
     ual files you need, but mostly they are stored in distribution sets, usu-
     ally consisting of subdirectories with gzipped tar files in them. The
     primary ftp sites for the distributions are:

     sunsite.unc.edu:/pub/Linux/distributions
     tsx-11.mit.edu:/pub/linux/distributions

     Some European mirrors:

     ftp.luth.se:/pub/linux/distributions
     ftp.demon.co.uk:/pub/linux/distributions
     src.doc.ic.ac.uk:/packages/linux/distributions

     For simplicity, let's concentrate on Slackware here. This distribution
     consists of a number of subdirectories, containing separate packages.
     Normally, they're controlled by an install program, but you can retrieve
     files "by hand" too. First of all, you will need to look in the "con-
     tents" subdir of the distribution. You will find a lot of small textfiles
     here describing the contents of the seperate packages. The fastest way to
     look something up is to retrieve all the files in the contents subdirec-
     tory, and grep through them for the file you need. Here is an example of
     a list of files that you might need, and in which contents-file you will
     find it by grepping through them:

           Needed                  Package

           ld.so                   ldso
           ldconfig                ldso
           ldd                     ldso
           libc.so.4               shlibs
           libX11.so.6.0           xf lib
                                     -
           libXt.so.6.0            xf lib
                                     -
           libX11.so.3             oldlibs
           libXt.so.3              oldlibs

     So, in this case, you will need the packages ldso, shlibs, xf lib and
                                                                  -
     oldlibs.  In each of the contents-files for these packages, look for a
     line saying "PACKAGE LOCATION", it will tell you on which 'disk' the
     package is, in our case it will tell us in which subdirectory we need to
     look.  For our example, we would find the following locations:

           Package                 Location

           ldso                    diska2
           shlibs                  diska2
           oldlibs                 diskx6
           xf lib                  diskx9
             -

     The locations called "diskXX" refer to the "slakware/XX" subdirectories
     of the distribution, others may be found in the "contrib" subdirectory.
     In this case, we could now retrieve the packages we need by retrieving
     the following files (relative to the root of the Slackware distribution
     tree):

     slakware/a2/ldso.tgz
     slakware/a2/shlibs.tgz
     slakware/x6/oldlibs/tgz
     slakware/x9/xf lib.tgz
                   -

     Extract the files from these gzipped tarfiles in your /compat/linux di-
     rectory (possibly omitting or afterwards removing files you don't need),
     and you are done.

BUGS
     The information about Linux distributions may become outdated.

SEE ALSO
     ftp.freebsd.org:pub/FreeBSD/2.0.5-RELEASE/xperimnt/linux-emu/README

     /usr/src/sys/i386/ibcs2/README.iBCS2

4th Berkeley Distribution        March 2, 1995                               5




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.951018174034.13692A-100000>