Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jul 2002 13:48:18 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Vahe Khachikyan <vahe@fh-konstanz.de>
Cc:        freebsd-alpha@FreeBSD.ORG
Subject:   Re: Linux DEV breaks CCC! [was - Re: How did I break CCC?]
Message-ID:  <3D3C6F92.AF46F2AE@mindspring.com>
References:  <1026948385.3d35fd2179b20@vvl15.fh-konstanz.de> <1027369332.3d3c69746f1aa@vvl15.fh-konstanz.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Vahe Khachikyan wrote:
> I found out that linux development package installed on FBSD Alpha box
> breaks the functionality of an existing CCC.
> 
> The problem is that the INCLUDE paths seams to be hard coded somewhere.
> It is even imossible to install the ccc package from scratch, cause
> during make install it tries to comile something and ends up
> with a big amount of errors cause of some definitions in include files.
> I traced the program and find out that it reads the include files from
> /compat/linux/usr/include if there is a directory with such name.
> Renaming mentioned directory helps to figure out the problem
> and the compiler becomes quite happy!
> 
> Has anybody any idea why it searches the include files over there ?

The compiler runs under Linux binary compatability mode.

This means that there is an automatic pereference for path
lookups to look in /compat/linux for any abcolute path name
(i.e. beginning with "/").

This is done as part of the emulation so that the libraries
that get used in the running of Linux binaries are Linux
libraries, and so that the data files used by the Linux
libraries (e.g. /etc/host.conf, /etc/resolv.conf) are in the
correct format for those library routines which read them.

The way the compiler works is by running in Linux binary
compatability mode, which then generates Alpha assembly
language.  The Alpha assembly language is then passed to the
local system assembler; if you do not have the Linux "devtools"
installed, this will be the FreeBSD version of gas on the
platform, and the resulting binaries will be FreeBSD native
binaries.

Probably, there should be a "magic" branding mechanism that
causes only path lookups on binary components to be via the
compatability path.  However, there are not seperate open(2)
calls that are used to distinguish binary from non-binary to
the OS.  Also, you might be doing what you are doing as a
result of intent on your part to do Linux developement with
the CCC compiler on FreeBSD ...with the intent that the code
that results be Linux binaries.

Obviously, for that to be true, you would not be using the
ports (FreeBSD) version of the CCC compiler, since you would
want to make sure that the gas and gld being called were in
fact the Linux gas and gld.

But in point of fact, the code can't tell the difference,
and it's being invoked from a FreeBSD shell script, rather
than a FreeBSD binary (or Linux binary).

Probably, your best bet for cohabitation would be to create
a "/FreeBSD" that would not be there in the Linux case, and
link it to the "/" directory, e.g.:

	ln -s / /FreeBSD

And then specify on the compiler command line (if this is
possible) that /FreeBSD/include should be referenced before
/usr/include.  The lookup for /compat/linux/FreeBSD/include
will fail, and everything will just work.

This assumes that the /compat/linux prefix is not reinterpreted
on the traversal of "/" for targets of symbolic links (this is
done in the Linux system call layer for path names, so it should
not be a problem, assuming you can get the compiler to cooperate).

This type of thing should probably be automatic in the FreeBSD
CCC package; it's ugly, but likely necessary, if your peculiar
configuration is to be supported.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D3C6F92.AF46F2AE>