[cfe-dev] [PATCH]: add support for FreeBSD
Chris Lattner
clattner at apple.com
Wed Oct 15 08:14:29 PDT 2008
On Oct 14, 2008, at 11:35 PM, Roman Divacky wrote:
>>> I think you are right.... the __FreeBSD_cc_version is used to denote
>>> what gcc is used on a given FreeBSD. I believe we can easily pretend
>>> it's always X00001 where X is the FreeBSD major number. do you like
>>> this
>>> patch? I could not test it but it should be ok...
>>
>> The patch looks great to me, can you please resend as an attachment?
>> It is coming through inline and I can't copy/paste it successfully,
>> thanks!
>
> here it is.
Ah, I'm sorry, one more change please.
The code to detect the OS should go into the llvm::sys::osVersion()
function in libsystem. This causes clang to set the target triple in
CreateTargetTriple() in clang.cpp. You will want it to set a target
triple like "freebsd8-..." etc.
Based on the target triple, you want getFreeBSDDefines to set the
"release". For an example, look at how getDarwinDefines extracts the
"darwin8-..." into some logic that eventually sets
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__.
Splitting the patch into these two pieces is important because you
want clang to *default* to the current dynamic system, but you want to
be able to override/cross compile with the -target=... option. Also,
calling uname in Targets.cpp doesn't work because not all hosts have
it (which is why it needs to be in libsystem).
One trick here is that osName is not very well factored. Daniel, were
you planning to make the interface be "return a target triple"?
-Chris
More information about the cfe-dev
mailing list