Преглед изворни кода

Added Clang toolchain support for Linux.

bkaradzic пре 12 година
родитељ
комит
89bd13b30e
3 измењених фајлова са 42 додато и 4 уклоњено
  1. 5 0
      include/bx/platform.h
  2. 2 2
      include/bx/spscqueue.h
  3. 35 2
      premake/toolchain.lua

+ 5 - 0
include/bx/platform.h

@@ -140,6 +140,11 @@
 #	pragma warning(error:4505) // ENABLE warning C4505: '' : unreferenced local function has been removed
 #	pragma warning(error:4505) // ENABLE warning C4505: '' : unreferenced local function has been removed
 #endif // BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS && BX_COMPILER_MSVC
 #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
 #if BX_PLATFORM_WINDOWS
 // http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
 // http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
 #	if !defined(WINVER) && !defined(_WIN32_WINNT)
 #	if !defined(WINVER) && !defined(_WIN32_WINNT)

+ 2 - 2
include/bx/spscqueue.h

@@ -6,13 +6,13 @@
 #ifndef __BX_SPSCQUEUE_H__
 #ifndef __BX_SPSCQUEUE_H__
 #define __BX_SPSCQUEUE_H__
 #define __BX_SPSCQUEUE_H__
 
 
-#include <list>
-
 #include "bx.h"
 #include "bx.h"
 #include "cpu.h"
 #include "cpu.h"
 #include "mutex.h"
 #include "mutex.h"
 #include "uint32_t.h"
 #include "uint32_t.h"
 
 
+#include <list>
+
 namespace bx
 namespace bx
 {
 {
 	// http://drdobbs.com/article/print?articleId=210604448&siteSectionName=
 	// http://drdobbs.com/article/print?articleId=210604448&siteSectionName=

+ 35 - 2
premake/toolchain.lua

@@ -15,6 +15,7 @@ function toolchain(_buildDir, _libDir)
 			{ "android-arm", "Android - ARM" },
 			{ "android-arm", "Android - ARM" },
 --			{ "emscripten-experimental", "Emscripten" },
 --			{ "emscripten-experimental", "Emscripten" },
 			{ "linux", "Linux" },
 			{ "linux", "Linux" },
+			{ "linux-clang", "Linux (Clang compiler)" },
 			{ "mingw", "MinGW" },
 			{ "mingw", "MinGW" },
 			{ "nacl", "Native Client" },
 			{ "nacl", "Native Client" },
 			{ "nacl-arm", "Native Client - ARM" },
 			{ "nacl-arm", "Native Client - ARM" },
@@ -74,6 +75,13 @@ function toolchain(_buildDir, _libDir)
 			location (_buildDir .. "projects/" .. _ACTION .. "-linux")
 			location (_buildDir .. "projects/" .. _ACTION .. "-linux")
 		end
 		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
 		if "mingw" == _OPTIONS["gcc"] then
 			premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc"
 			premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc"
 			premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++"
 			premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++"
@@ -242,12 +250,21 @@ function toolchain(_buildDir, _libDir)
 		}
 		}
 		buildoptions { "-m64" }
 		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 {
 		buildoptions {
 			"-std=c++0x",
 			"-std=c++0x",
 			"-U__STRICT_ANSI__",
 			"-U__STRICT_ANSI__",
 			"-Wunused-value",
 			"-Wunused-value",
-			"-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
 			"-msse2",
 			"-msse2",
 		}
 		}
 		links {
 		links {
@@ -273,6 +290,22 @@ function toolchain(_buildDir, _libDir)
 			"-m64",
 			"-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" }
 	configuration { "android-arm" }
 		targetdir (_buildDir .. "android-arm" .. "/bin")
 		targetdir (_buildDir .. "android-arm" .. "/bin")
 		objdir (_buildDir .. "android-arm" .. "/obj")
 		objdir (_buildDir .. "android-arm" .. "/obj")