From 89bd13b30e2592c4b3a2042aab69730acef8d90d Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 11 Aug 2013 19:00:57 -0700 Subject: [PATCH] Added Clang toolchain support for Linux. --- include/bx/platform.h | 5 +++++ include/bx/spscqueue.h | 4 ++-- premake/toolchain.lua | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/bx/platform.h b/include/bx/platform.h index 4c4b520..cca25b8 100644 --- a/include/bx/platform.h +++ b/include/bx/platform.h @@ -140,6 +140,11 @@ # pragma warning(error:4505) // ENABLE warning C4505: '' : unreferenced local function has been removed #endif // BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS && BX_COMPILER_MSVC +#if BX_COMPILER_CLANG && BX_PLATFORM_LINUX +// Clang on Linux complains about missing __float128 type... +typedef struct { long double x, y; } __float128; +#endif // BX_COMPILER_CLANG && BX_PLATFORM_LINUX + #if BX_PLATFORM_WINDOWS // http://msdn.microsoft.com/en-us/library/6sehtctf.aspx # if !defined(WINVER) && !defined(_WIN32_WINNT) diff --git a/include/bx/spscqueue.h b/include/bx/spscqueue.h index 001d353..85d2a60 100644 --- a/include/bx/spscqueue.h +++ b/include/bx/spscqueue.h @@ -6,13 +6,13 @@ #ifndef __BX_SPSCQUEUE_H__ #define __BX_SPSCQUEUE_H__ -#include - #include "bx.h" #include "cpu.h" #include "mutex.h" #include "uint32_t.h" +#include + namespace bx { // http://drdobbs.com/article/print?articleId=210604448&siteSectionName= diff --git a/premake/toolchain.lua b/premake/toolchain.lua index 60545e9..f9fc714 100755 --- a/premake/toolchain.lua +++ b/premake/toolchain.lua @@ -15,6 +15,7 @@ function toolchain(_buildDir, _libDir) { "android-arm", "Android - ARM" }, -- { "emscripten-experimental", "Emscripten" }, { "linux", "Linux" }, + { "linux-clang", "Linux (Clang compiler)" }, { "mingw", "MinGW" }, { "nacl", "Native Client" }, { "nacl-arm", "Native Client - ARM" }, @@ -74,6 +75,13 @@ function toolchain(_buildDir, _libDir) location (_buildDir .. "projects/" .. _ACTION .. "-linux") end + if "linux-clang" == _OPTIONS["gcc"] then + premake.gcc.cc = "clang" + premake.gcc.cxx = "clang++" + premake.gcc.ar = "ar" + location (_buildDir .. "projects/" .. _ACTION .. "-linux-clang") + end + if "mingw" == _OPTIONS["gcc"] then premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc" premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++" @@ -242,12 +250,21 @@ function toolchain(_buildDir, _libDir) } buildoptions { "-m64" } - configuration { "linux" } + configuration { "linux and not linux-clang" } + buildoptions { + "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic. + } + + configuration { "linux-clang" } + buildoptions { + "--analyze", + } + + configuration { "linux or linux-clang" } buildoptions { "-std=c++0x", "-U__STRICT_ANSI__", "-Wunused-value", - "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic. "-msse2", } links { @@ -273,6 +290,22 @@ function toolchain(_buildDir, _libDir) "-m64", } + configuration { "linux-clang", "x32" } + targetdir (_buildDir .. "linux32_clang" .. "/bin") + objdir (_buildDir .. "linux32_clang" .. "/obj") + libdirs { _libDir .. "lib/linux32_clang" } + buildoptions { + "-m32", + } + + configuration { "linux-clang", "x64" } + targetdir (_buildDir .. "linux64_clang" .. "/bin") + objdir (_buildDir .. "linux64_clang" .. "/obj") + libdirs { _libDir .. "lib/linux64_clang" } + buildoptions { + "-m64", + } + configuration { "android-arm" } targetdir (_buildDir .. "android-arm" .. "/bin") objdir (_buildDir .. "android-arm" .. "/obj")