[cfe-dev] [PATCH]: add support for FreeBSD

Chris Lattner clattner at apple.com
Thu Oct 9 11:40:25 PDT 2008

On Oct 8, 2008, at 3:04 AM, Roman Divacky wrote:

> On Wed, Oct 08, 2008 at 10:24:30AM +0100, David Chisnall wrote:
>> On 7 Oct 2008, at 17:00, Roman Divacky wrote:
>>> hi
>>> the attached patch add support for FreeBSD to clang. if you
>>> consider it ok, please commit :)
>>> +  Define(Defs, "__FreeBSD__", "8");
>>> +  Define(Defs, "__FreeBSD_cc_version", "800001");
>> You are hard-coding the version to a FreeBSD release that currently
>> corresponds to -CURRENT.  This would be better done by calling  
>> uname()
>> and setting it to the release field of the returned structure, or
>> getting it from some other source if building a cross-compiler.
> this number is hardcoded in gcc as well. It's not exported outside gcc
> in any header file or something.
> do you want me to check for existence of
>   /usr/src/gnu/usr.bin/cc/cc_tools/freebsd-native.h
> and including it in a case it exists and otherwise putting there  
> some dummy
> number?

I think that wrapping the configuration logic with #ifdef __freebsd__  
(or whatever is appropriate) would make sense.  Follow the lead of the  
similar darwin code.

> I might ignite a discussion on the fbsd mailing list if we can change
> the sources to export these two numbers to be exported in some  
> header file.

On darwin, we autodetect using the "approved system interfaces".  The  
idea is that we want to be able to build a binary on darwin9 and have  
it run find on darwin10.  The idea is that we want the compiler to  
default to generating code for the current OS, but that requires  
detecting it (since the build may have been done on a different one).

Make sense?


More information about the cfe-dev mailing list