Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision d242cb6a311e633e1cf8c95117046ea51295d4c7)
+++ kernel/Makefile	(revision 94dfb921f6c450a02fb6df6e504c66a95d6ae95c)
@@ -100,10 +100,13 @@
 	-Werror-implicit-function-declaration -wd170
 
+# clang does not support following options but I am not sure whether
+# something won't break because of that:
+# -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) -finput-charset=UTF-8
 CLANG_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
-	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
-	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
+	-ffreestanding -fno-builtin -nostdlib -nostdinc \
 	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
 	-Werror-implicit-function-declaration -Wwrite-strings \
-	-pipe -arch $(CLANG_ARCH)
+	-integrated-as \
+	-pipe -target $(CLANG_TARGET)
 
 ifeq ($(CONFIG_DEBUG),y)
@@ -387,5 +390,5 @@
 
 $(LINK): $(LINK).in $(DEPEND)
-	$(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
+	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
 
 %.o: %.S $(DEPEND)
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision d242cb6a311e633e1cf8c95117046ea51295d4c7)
+++ kernel/arch/amd64/Makefile.inc	(revision 94dfb921f6c450a02fb6df6e504c66a95d6ae95c)
@@ -31,4 +31,5 @@
 BFD = binary
 CLANG_ARCH = x86_64
+CLANG_TARGET = x86_64-unknown-linux
 
 FPU_NO_CFLAGS = -mno-sse -mno-sse2
@@ -36,4 +37,5 @@
 GCC_CFLAGS += $(CMN1)
 ICC_CFLAGS += $(CMN1)
+CLANG_CFLAGS += $(CMN1)
 
 BITS = 64
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision d242cb6a311e633e1cf8c95117046ea51295d4c7)
+++ kernel/arch/ia32/Makefile.inc	(revision 94dfb921f6c450a02fb6df6e504c66a95d6ae95c)
@@ -31,4 +31,5 @@
 BFD = binary
 CLANG_ARCH = i386
+CLANG_TARGET = i386-unknown-linux
 
 BITS = 32
Index: kernel/generic/include/debug.h
===================================================================
--- kernel/generic/include/debug.h	(revision d242cb6a311e633e1cf8c95117046ea51295d4c7)
+++ kernel/generic/include/debug.h	(revision 94dfb921f6c450a02fb6df6e504c66a95d6ae95c)
@@ -77,8 +77,20 @@
 	} while (0)
 
+/** Static assert macro
+ *
+ */
+#define STATIC_ASSERT(expr) \
+	_Static_assert(expr, "")
+
+#define STATIC_ASSERT_VERBOSE(expr, msg) \
+	_Static_assert(expr, msg)
+
+
 #else /* CONFIG_DEBUG */
 
 #define ASSERT(expr)
 #define ASSERT_VERBOSE(expr, msg)
+#define STATIC_ASSERT(expr)
+#define STATIC_ASSERT_VERBOSE(expr, msg)
 
 #endif /* CONFIG_DEBUG */
Index: kernel/generic/include/printf/verify.h
===================================================================
--- kernel/generic/include/printf/verify.h	(revision d242cb6a311e633e1cf8c95117046ea51295d4c7)
+++ kernel/generic/include/printf/verify.h	(revision 94dfb921f6c450a02fb6df6e504c66a95d6ae95c)
@@ -38,6 +38,12 @@
 #ifndef NVERIFY_PRINTF
 
+#ifdef __clang__
+#define PRINTF_ATTRIBUTE(start, end) \
+	__attribute__((format(__printf__, start, end)))
+#else
 #define PRINTF_ATTRIBUTE(start, end) \
 	__attribute__((format(gnu_printf, start, end)))
+#endif
+
 
 #else /* NVERIFY_PRINTF */
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision d242cb6a311e633e1cf8c95117046ea51295d4c7)
+++ kernel/generic/src/main/main.c	(revision 94dfb921f6c450a02fb6df6e504c66a95d6ae95c)
@@ -89,4 +89,23 @@
 #include <lib/ra.h>
 
+/* Ensure [u]int*_t types are of correct size.
+ *
+ * Probably, this is not the best place for such tests
+ * but this file is compiled on all architectures.
+ */
+#define CHECK_INT_TYPE_(signness, size) \
+	STATIC_ASSERT_VERBOSE(sizeof(signness##size##_t) * 8 == size, \
+	    #signness #size "_t does not have " #size " bits");
+#define CHECK_INT_TYPE(size) \
+	CHECK_INT_TYPE_(int, size); CHECK_INT_TYPE_(uint, size)
+
+CHECK_INT_TYPE(8);
+CHECK_INT_TYPE(16);
+CHECK_INT_TYPE(32);
+CHECK_INT_TYPE(64);
+
+
+
+
 /** Global configuration structure. */
 config_t config = {
