Porting LLVM - MidnightBSD/src GitHub Wiki
This page is a place to document changes needed to get LLVM running.
Ideally, we'd get a correct upstream patchset to LLVM. That was tried around the LLVM 6/7 era and rejected. (We should try again at some point)
MidnightBSD (current 4.0) LLVM 18?
patch 1 patch 2 patch 3 patch 4 patch 5 patch 6 patch 7 patch 8 (LLDB) patch 9 patch 10 ...
These are 'hacks' to get the FreeBSD target to work, not the proper way to do this.
clang/lib/Basic/Targets/OSTargets.h
In the FreeBSD target, we do a hack to get __MidnightBSD__ and __MidnightBSD_cc_version defined
#ifndef MIDNIGHTBSD_CC_VERSION
#define MIDNIGHTBSD_CC_VERSION 0U
#endif
// FreeBSD Target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// FreeBSD defines; list based off of gcc output
unsigned Release = Triple.getOSMajorVersion();
if (Release == 0U)
Release = 8U;
unsigned CCVersion = MIDNIGHTBSD_CC_VERSION;
if (CCVersion == 0U)
CCVersion = Release * 100000U + 1U;
Builder.defineMacro("__MidnightBSD__", Twine(Release));
Builder.defineMacro("__MidnightBSD_cc_version", Twine(CCVersion));
// freebsd compatibility
Builder.defineMacro("__FreeBSD__", Twine(13U));
Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
DefineStd(Builder, "unix", Opts);
if (this->HasFloat128)
Builder.defineMacro("__FLOAT128__");