[cfe-dev] Patch to distinguish the OS when detecting targets

Eli Friedman eli.friedman at gmail.com
Mon Aug 18 22:19:15 PDT 2008

Per subject, patch to distinguish between OSes when deciding on a
target.  I've been getting annoying with having a patch in my tree to
hack up the Darwin target to act like Linux, so I put together the
attached.  This patch categorizes targets by OS, and adds Linux x86
and x86-64 targets distinct from the Darwin targets.  (The difference
between the two x86 targets that motivated this patch is the
definition of long double, which affects struct layout.)

It may seem a little restrictive to only detect known OSes, but IMO
it's better than silently breaking code in subtle ways, which is what
happens when you use a target which isn't quite right.  That said, we
probably want to update the error message the driver prints out when
it can't find the target; suggestions?

The only thing I'm not particularly happy about is that the cut+paste
is a little excessive; a barebones target is 40 lines minimum, and the
new Linux targets are almost identical to the Darwin ones.  It would
probably be better to reorganize the class hierarchy so that the base
classes are processors rather than OSes.

Unfortunately, I only have Linux-x86 that I can test with, so I'd like
some verification from others that this actually works; the primary
issues I'm worried about is broken detection code not detecting a
target that should be known, and missing some processor+OS combination
that someone is currently using.  Combinations that I know are broken
by this change: Linux+Sparc, Linux+ARM, Linux+PPC, Solaris+x86, and
anything that isn't Linux, Darwin, or Solaris.  In the category of
unknown OSes, I guess I probably need to add Windows-x86 and some
*BSDs.  That said, there isn't any existing information in Targets.cpp
on Windows or *BSD; I don't know what defines those targets are
supposed to define, or whether there are any interesting differences
in the data layout. Any information here would be welcome.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: distinguishos.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080818/c8e31137/attachment.txt>

More information about the cfe-dev mailing list