From 3d2113b1a2d32c099fc6857ba039521cb174d370 Mon Sep 17 00:00:00 2001 From: Matthieu Volat Date: Mon, 13 Nov 2017 20:08:02 +0100 Subject: [PATCH] Guard hardcoded defines with cpp. Add support for FreeBSD/OpenBSD defines. --- lib/Driver/ToolChains/Flang.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Driver/ToolChains/Flang.cpp b/lib/Driver/ToolChains/Flang.cpp index eb619a860e..e109a50278 100644 --- a/lib/Driver/ToolChains/Flang.cpp +++ b/lib/Driver/ToolChains/Flang.cpp @@ -572,12 +572,20 @@ void FlangFrontend::ConstructJob(Compilation &C, const JobAction &JA, // Add system include arguments. getToolChain().AddFlangSystemIncludeArgs(Args, UpperCmdArgs); +#if defined(unix) || defined(__unix) || defined(__unix__) UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("unix"); UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__unix"); UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__unix__"); +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("linux"); UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__linux"); UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__linux__"); +#elif defined(__FreeBSD__) + UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__FreeBSD__"); +#elif defined(__OpenBSD__) + UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__OpenBSD__"); +#endif UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__NO_MATH_INLINES"); UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__LP64__"); UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__x86_64");