Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ HelenOS.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -300,18 +300,5 @@
 @ "icc" Intel C Compiler
 @ "gcc_native" GNU C Compiler (native)
-! [PLATFORM=amd64|PLATFORM=ia32] COMPILER (choice)
-
-% Compiler
-@ "gcc_cross" GNU C Compiler (cross-compiler)
-@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
-@ "icc" Intel C Compiler
-@ "gcc_native" GNU C Compiler (native)
-! [PLATFORM=ia64] COMPILER (choice)
-
-% Compiler
-@ "gcc_cross" GNU C Compiler (cross-compiler)
-@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
-@ "gcc_native" GNU C Compiler (native)
-! [PLATFORM=riscv64] COMPILER (choice)
+! [PLATFORM=amd64|PLATFORM=ia32|PLATFORM=ia64] COMPILER (choice)
 
 % Compiler
@@ -320,6 +307,11 @@
 @ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
 @ "gcc_native" GNU C Compiler (native)
-! [PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=sparc64] COMPILER (choice)
-
+! [PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=sparc64|PLATFORM=riscv64] COMPILER (choice)
+
+% Clang Integrated Assembler
+@ "default" Use architecture default.
+@ "yes" Use integrated assembler.
+@ "no" Use GNU Assembler.
+! [COMPILER=clang] INTEGRATED_AS (choice)
 
 ## Cross-compiler target for abstract architecture
Index: boot/Makefile.build
===================================================================
--- boot/Makefile.build	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ boot/Makefile.build	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -36,47 +36,46 @@
 DEFS = -DBOOT -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
 
+AFLAGS =
 LFLAGS = --fatal-warnings
 
-GCC_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
-	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
-	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
+# FIXME: This condition is a workaround for issue #693.
+ifneq ($(BARCH),mips32)
+	AFLAGS += --fatal-warnings
+endif
+
+COMMON_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
+	-ffreestanding -fno-builtin -nostdlib -nostdinc \
+	-fexec-charset=UTF-8 -finput-charset=UTF-8
+
+GCC_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
 	-std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
 	-pipe
 
-ICC_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
-	-ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -wd170
+ICC_CFLAGS = -Wall -Wmissing-prototypes -Werror-implicit-function-declaration -wd170
 
-CLANG_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
-	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
-	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
+CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
 	-Werror-implicit-function-declaration -Wwrite-strings \
-	-pipe
+	-pipe  -fno-stack-protector -fno-PIC
 
 ifeq ($(CONFIG_DEBUG),y)
-	GCC_CFLAGS += -Werror
-	ICC_CFLAGS += -Werror
+	COMMON_CFLAGS += -Werror
 endif
 
 ifeq ($(CONFIG_LINE_DEBUG),y)
-	GCC_CFLAGS += -g
-	ICC_CFLAGS += -g
-	CLANG_CFLAGS += -g
+	COMMON_CFLAGS += -g
 endif
 
 ifeq ($(COMPILER),gcc_native)
-	CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),gcc_cross)
-	CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),gcc_helenos)
-	CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
@@ -84,10 +83,10 @@
 
 ifeq ($(COMPILER),icc)
-	CFLAGS = $(ICC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(ICC_CFLAGS) $(EXTRA_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),clang)
-	CFLAGS = $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
@@ -105,4 +104,6 @@
 endif
 
+AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
+
 $(BOOT_OUTPUT): $(RAW)
 	$(OBJCOPY) -O $(BFD_OUTPUT) $< $@
@@ -112,8 +113,8 @@
 
 $(LINK): $(DEPEND)
-	$(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
+	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
 
 %.o: %.S $(DEPEND)
-	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
+	$(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
@@ -127,5 +128,5 @@
 
 %.o: %.s $(DEPEND)
-	$(AS) $(AFLAGS) -o $@ $<
+	$(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm
Index: defaults/amd64/Makefile.config
===================================================================
--- defaults/amd64/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/amd64/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -10,4 +10,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Debug build
Index: defaults/arm32/Makefile.config
===================================================================
--- defaults/arm32/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/arm32/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -7,4 +7,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Debug build
Index: defaults/ia32/Makefile.config
===================================================================
--- defaults/ia32/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/ia32/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -10,4 +10,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Debug build
Index: defaults/ia64/Makefile.config
===================================================================
--- defaults/ia64/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/ia64/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -7,4 +7,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Debug build
Index: defaults/mips32/Makefile.config
===================================================================
--- defaults/mips32/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/mips32/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -7,4 +7,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Debug build
Index: defaults/ppc32/Makefile.config
===================================================================
--- defaults/ppc32/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/ppc32/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -7,4 +7,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Lazy FPU context switching
Index: defaults/sparc64/Makefile.config
===================================================================
--- defaults/sparc64/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/sparc64/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -7,4 +7,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Support for SMP
Index: defaults/special/Makefile.config
===================================================================
--- defaults/special/Makefile.config	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ defaults/special/Makefile.config	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -4,4 +4,7 @@
 # Compiler
 COMPILER = gcc_cross
+
+# In case compiler is clang, whether or not to use its integrated assembler.
+INTEGRATED_AS = default
 
 # Support for SMP
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/Makefile	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -84,37 +84,29 @@
 DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
 
-GCC_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 \
-	-std=gnu99 -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-pipe
-
-ICC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
-	-ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
+COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
+	-ffreestanding -fno-builtin -nostdlib -nostdinc \
+	-fexec-charset=UTF-8 -finput-charset=UTF-8
+
+GCC_CFLAGS = -std=gnu99 -Wall -Wextra -Wno-unused-parameter \
+	-Wmissing-prototypes -Werror-implicit-function-declaration \
+	-Wwrite-strings -pipe
+
+ICC_CFLAGS = -Wall -Wmissing-prototypes \
 	-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) \
-	-ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-std=gnu99 -Wall -Werror -Wextra -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-integrated-as -pipe -target $(CLANG_TARGET)
+CLANG_CFLAGS = -std=gnu99 -Wall -Wextra -Wno-unused-parameter \
+	-Wmissing-prototypes -Werror-implicit-function-declaration \
+	-Wwrite-strings -pipe -fno-stack-protector -fno-PIC
 
 ifeq ($(CONFIG_DEBUG),y)
-	GCC_CFLAGS += -Werror
-	ICC_CFLAGS += -Werror
+	COMMON_CFLAGS += -Werror
 endif
 
 ifeq ($(CONFIG_LTO),y)
-	GCC_CFLAGS += -flto
+	COMMON_CFLAGS += -flto
 endif
 
 ifeq ($(CONFIG_LINE_DEBUG),y)
-	GCC_CFLAGS += -g
-	ICC_CFLAGS += -g
-	CLANG_CFLAGS += -g
+	COMMON_CFLAGS += -g
 endif
 
@@ -123,6 +115,13 @@
 # AFLAGS and LFLAGS must be initialized before the inclusion.
 #
-AFLAGS = --fatal-warnings
+AFLAGS =
 LFLAGS = -n -T $(LINK) -M --fatal-warnings
+
+# FIXME: This condition is a workaround for issues #693 and #694.
+ifneq ($(KARCH),sparc64)
+ifneq ($(KARCH),mips32)
+	AFLAGS += --fatal-warnings
+endif
+endif
 
 #
@@ -156,5 +155,5 @@
 
 ifeq ($(COMPILER),gcc_native)
-	CFLAGS = $(GCC_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 	INSTRUMENTATION = -finstrument-functions
@@ -162,5 +161,5 @@
 
 ifeq ($(COMPILER),gcc_cross)
-	CFLAGS = $(GCC_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 	INSTRUMENTATION = -finstrument-functions
@@ -168,5 +167,5 @@
 
 ifeq ($(COMPILER),gcc_helenos)
-	CFLAGS = $(GCC_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 	INSTRUMENTATION = -finstrument-functions
@@ -174,5 +173,5 @@
 
 ifeq ($(COMPILER),icc)
-	CFLAGS = $(ICC_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(ICC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 	INSTRUMENTATION =
@@ -180,7 +179,7 @@
 
 ifeq ($(COMPILER),clang)
-	CFLAGS = $(CLANG_CFLAGS)
+	CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
-	INSTRUMENTATION =
+	INSTRUMENTATION = -finstrument-functions
 endif
 
@@ -384,5 +383,10 @@
 AUTOGENS_AG := $(ARCH_AUTOGENS_AG) $(GENARCH_AUTOGENS_AG)
 
-LFLAGS_LTO := $(addprefix -Xlinker ,$(LFLAGS))
+AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
+LD_CFLAGS := $(addprefix -Xlinker ,$(LFLAGS))
+
+ifeq ($(COMPILER),clang)
+	AS_CFLAGS += -mllvm -asm-macro-max-nesting-depth=1000
+endif
 
 ifeq ($(CONFIG_SYMTAB),y)
@@ -404,5 +408,5 @@
 $(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
 ifeq ($(CONFIG_LTO),y)
-	$(GCC) $(LFLAGS_LTO) -Xlinker -Map -Xlinker $(MAP) $(DEFS) $(GCC_CFLAGS) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS)
+	$(CC) $(DEFS) $(CFLAGS) $(LD_CFLAGS) -Xlinker -Map -Xlinker $(MAP) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS)
 else
 	$(LD) $(LFLAGS) -Map $(MAP) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS)
@@ -417,15 +421,15 @@
 %.h: %.ag
 	$(AUTOGEN) probe $< >$<.probe.c
-	$(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
+	$(CC_AUTOGEN) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
 	$(AUTOGEN) generate $< <$<.probe.s >$@   
 
 %.o: %.S $(DEPEND)
-	$(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c -o $@ $<
+	$(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c -o $@ $<
 ifeq ($(PRECHECK),y)
-	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(GCC_CFLAGS) -D__ASM__
+	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
 endif
 
 %.o: %.s $(DEPEND)
-	$(AS) $(AFLAGS) -o $@ $<
+	$(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c -o $@ $<
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
@@ -439,10 +443,10 @@
 
 $(REAL_MAP).o: $(REAL_MAP).bin
-	echo "$(AS_PROLOG)""$(SYMTAB_SECTION)"" .incbin \"$<\"" | $(AS) $(AFLAGS) -o $@
+	echo "$(AS_PROLOG)""$(SYMTAB_SECTION)"" .incbin \"$<\"" | $(CC) $(CFLAGS) $(AS_CFLAGS) -x assembler -c -o $@ -
 
 $(REAL_MAP).bin: $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
-	echo "$(AS_PROLOG)""$(SYMTAB_SECTION)" | $(AS) $(AFLAGS) -o $(EMPTY_MAP)
+	echo "$(AS_PROLOG)""$(SYMTAB_SECTION)" | $(CC) $(CFLAGS) $(AS_CFLAGS) -x assembler -c -o $(EMPTY_MAP) -
 ifeq ($(CONFIG_LTO),y)
-	$(GCC) $(LFLAGS_LTO) -Xlinker -Map -Xlinker $(MAP_PREV) $(DEFS) $(GCC_CFLAGS) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP)
+	$(CC) $(DEFS) $(CFLAGS) $(LD_CFLAGS) -Xlinker -Map -Xlinker $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP)
 else
 	$(LD) $(LFLAGS) -Map $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP)
@@ -454,7 +458,7 @@
 	# on architectures that have bss after symtab
 	
-	echo "$(AS_PROLOG)""$(SYMTAB_SECTION)"" .incbin \"$@\"" | $(AS) $(AFLAGS) -o $(SIZEOK_MAP)
+	echo "$(AS_PROLOG)""$(SYMTAB_SECTION)"" .incbin \"$@\"" | $(CC) $(CFLAGS) $(AS_CFLAGS) -x assembler -c -o $(SIZEOK_MAP) -
 ifeq ($(CONFIG_LTO),y)
-	$(GCC) $(LFLAGS_LTO) -Xlinker -Map -Xlinker $(MAP_PREV) $(DEFS) $(GCC_CFLAGS) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP)
+	$(CC) $(DEFS) $(CFLAGS) $(LD_CFLAGS) -Xlinker -Map -Xlinker $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP)
 else
 	$(LD) $(LFLAGS) -Map $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP)
Index: kernel/arch/abs32le/Makefile.inc
===================================================================
--- kernel/arch/abs32le/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/abs32le/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -35,5 +35,5 @@
 	
 	ifeq ($(CROSS_TARGET),mips32)
-		GCC_CFLAGS += -mno-abicalls
+		COMMON_CFLAGS += -mno-abicalls
 	endif
 endif
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/amd64/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -32,8 +32,5 @@
 
 FPU_NO_CFLAGS = -mno-sse -mno-sse2
-CMN1 = -m64 -mcmodel=$(MEMORY_MODEL) -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
-GCC_CFLAGS += $(CMN1)
-ICC_CFLAGS += $(CMN1)
-CLANG_CFLAGS += $(CMN1)
+COMMON_CFLAGS += -m64 -mcmodel=$(MEMORY_MODEL) -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
 
 BITS = 64
@@ -44,7 +41,5 @@
 
 ifeq ($(PROCESSOR),opteron)
-	CMN2 := -march=opteron
-	GCC_CFLAGS += $(CMN2)
-	ICC_CFLAGS += $(CMN2)
+	COMMON_CFLAGS += -march=opteron
 endif
 
Index: kernel/arch/arm32/Makefile.inc
===================================================================
--- kernel/arch/arm32/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/arm32/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -33,5 +33,5 @@
 ATSIGN = %
 
-GCC_CFLAGS += -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR_ARCH)) -mno-unaligned-access -mfpu=vfpv3
+COMMON_CFLAGS += -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR_ARCH)) -mno-unaligned-access -mfpu=vfpv3
 
 ifeq ($(CONFIG_FPU),y)
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/ia32/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -34,8 +34,5 @@
 ENDIANESS = LE
 
-CMN1 = -m32 -fno-omit-frame-pointer
-GCC_CFLAGS += $(CMN1)
-ICC_CFLAGS += $(CMN1)
-CLANG_CFLAGS += $(CMN1)
+COMMON_CFLAGS += -m32 -fno-omit-frame-pointer
 
 ## Accepted CPUs
@@ -43,31 +40,28 @@
 
 ifeq ($(PROCESSOR),i486)
-	CMN2 = -march=i486
+	COMMON_CFLAGS += -march=i486
 endif
 
 ifeq ($(PROCESSOR),athlon_xp)
-	CMN2 = -march=athlon-xp
+	COMMON_CFLAGS += -march=athlon-xp
 endif
 
 ifeq ($(PROCESSOR),athlon_mp)
-	CMN2 = -march=athlon-mp
+	COMMON_CFLAGS += -march=athlon-mp
 endif
 
 ifeq ($(PROCESSOR),pentium3)
-	CMN2 = -march=pentium3
+	COMMON_CFLAGS += -march=pentium3
 endif
 
 ifeq ($(PROCESSOR),pentium4)
-	CMN2 = -march=pentium4
+	COMMON_CFLAGS += -march=pentium4
 endif
 
 ifeq ($(PROCESSOR),core)
-	CMN2 = -march=prescott
+	COMMON_CFLAGS += -march=prescott
 endif
 
 FPU_NO_CFLAGS = -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow
-GCC_CFLAGS += $(CMN2)
-ICC_CFLAGS += $(CMN2)
-CLANG_CFLAGS += $(CMN2)
 
 ARCH_SOURCES = \
Index: kernel/arch/ia64/Makefile.inc
===================================================================
--- kernel/arch/ia64/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/ia64/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -30,7 +30,5 @@
 BFD_ARCH = ia64-elf64
 
-CMN1 = -mconstant-gp -fno-unwind-tables -mfixed-range=f32-f127
-GCC_CFLAGS += $(CMN1)
-ICC_CFLAGS += $(CMN1)
+COMMON_CFLAGS += -mconstant-gp -fno-unwind-tables -mfixed-range=f32-f127
 
 AFLAGS += -mconstant-gp
Index: kernel/arch/mips32/Makefile.inc
===================================================================
--- kernel/arch/mips32/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/mips32/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -29,5 +29,5 @@
 BFD_ARCH = mips
 BFD = binary
-GCC_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mabi=32
+COMMON_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mabi=32
 AS_PROLOG = .module softfloat;
 
@@ -40,15 +40,15 @@
 	BFD_NAME = elf32-tradlittlemips
 	ENDIANESS = LE
-	GCC_CFLAGS += -march=r4000
+	COMMON_CFLAGS += -march=r4000
 endif
 ifeq ($(MACHINE),bmalta)
 	BFD_NAME = elf32-tradbigmips
 	ENDIANESS = BE
-	GCC_CFLAGS += -D__BE__ -march=4kc
+	COMMON_CFLAGS += -D__BE__ -march=4kc
 endif
 ifeq ($(MACHINE),lmalta)
 	BFD_NAME = elf32-tradlittlemips
 	ENDIANESS = LE
-	GCC_CFLAGS += -march=4kc
+	COMMON_CFLAGS += -march=4kc
 endif
 
Index: kernel/arch/ppc32/Makefile.inc
===================================================================
--- kernel/arch/ppc32/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/ppc32/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -31,5 +31,5 @@
 BFD = binary
 
-GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
+COMMON_CFLAGS += -mcpu=powerpc -msoft-float -m32
 AFLAGS += -a32
 LFLAGS += -no-check-sections
Index: kernel/arch/riscv64/Makefile.inc
===================================================================
--- kernel/arch/riscv64/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/riscv64/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -31,5 +31,5 @@
 BFD = binary
 
-GCC_CFLAGS += -mcmodel=medany
+COMMON_CFLAGS += -mcmodel=medany
 
 BITS = 64
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ kernel/arch/sparc64/Makefile.inc	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -31,5 +31,5 @@
 BFD = binary
 
-GCC_CFLAGS += -m64 -mcpu=ultrasparc -mcmodel=medlow -mno-fpu
+COMMON_CFLAGS += -m64 -mcpu=ultrasparc -mcmodel=medlow -mno-fpu
 
 LFLAGS += -no-check-sections
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ tools/autotool.py	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -210,5 +210,4 @@
 	target = None
 	gnu_target = None
-	clang_target = None
 	helenos_target = None
 	cc_args = []
@@ -220,10 +219,8 @@
 		if (config['CROSS_TARGET'] == "arm32"):
 			gnu_target = "arm-linux-gnueabi"
-			clang_target = "arm-unknown-none"
 			helenos_target = "arm-helenos-gnueabi"
 		
 		if (config['CROSS_TARGET'] == "ia32"):
 			gnu_target = "i686-pc-linux-gnu"
-			clang_target = "i686-unknown-none"
 			helenos_target = "i686-pc-helenos"
 		
@@ -231,5 +228,4 @@
 			cc_args.append("-mabi=32")
 			gnu_target = "mipsel-linux-gnu"
-			clang_target = "mipsel-unknown-none"
 			helenos_target = "mipsel-helenos"
 	
@@ -237,5 +233,4 @@
 		target = config['PLATFORM']
 		gnu_target = "amd64-linux-gnu"
-		clang_target = "x86_64-unknown-none"
 		helenos_target = "amd64-helenos"
 	
@@ -243,5 +238,4 @@
 		target = config['PLATFORM']
 		gnu_target = "arm-linux-gnueabi"
-		clang_target = "arm-unknown-none-eabi"
 		helenos_target = "arm-helenos-gnueabi"
 	
@@ -249,5 +243,4 @@
 		target = config['PLATFORM']
 		gnu_target = "i686-pc-linux-gnu"
-		clang_target = "i686-unknown-none"
 		helenos_target = "i686-pc-helenos"
 	
@@ -264,5 +257,4 @@
 			target = config['PLATFORM']
 			gnu_target = "mipsel-linux-gnu"
-			clang_target = "mipsel-unknown-none"
 			helenos_target = "mipsel-helenos"
 		
@@ -270,5 +262,4 @@
 			target = "mips32eb"
 			gnu_target = "mips-linux-gnu"
-			clang_target = "mips-unknown-none"
 			helenos_target = "mips-helenos"
 	
@@ -280,5 +271,4 @@
 			target = config['PLATFORM']
 			gnu_target = "mips64el-linux-gnu"
-			clang_target = "mips64el-unknown-none"
 			helenos_target = "mips64el-helenos"
 	
@@ -286,5 +276,4 @@
 		target = config['PLATFORM']
 		gnu_target = "ppc-linux-gnu"
-		clang_target = "ppc-unknown-none"
 		helenos_target = "ppc-helenos"
 	
@@ -292,5 +281,4 @@
 		target = config['PLATFORM']
 		gnu_target = "riscv64-unknown-linux-gnu"
-		clang_target = "riscv-unknown-none"
 		helenos_target = "riscv64-helenos"
 	
@@ -298,8 +286,7 @@
 		target = config['PLATFORM']
 		gnu_target = "sparc64-linux-gnu"
-		clang_target = "sparc-unknown-none"
 		helenos_target = "sparc64-helenos"
 	
-	return (target, cc_args, gnu_target, clang_target, helenos_target)
+	return (target, cc_args, gnu_target, helenos_target)
 
 def check_app(args, name, details):
@@ -351,4 +338,14 @@
 	return found
 
+def check_clang(path, prefix, common, details):
+	"Check for clang"
+	
+	common['CLANG'] = "%sclang" % prefix
+	
+	if (not path is None):
+		common['CLANG'] = "%s/%s" % (path, common['CLANG'])
+	
+	check_app([common['CLANG'], "--version"], "clang", details)
+
 def check_gcc(path, prefix, common, details):
 	"Check for GCC"
@@ -427,6 +424,5 @@
 	outf.close()
 	
-	args = [common['CC']]
-	args.extend(common['CC_ARGS'])
+	args = common['CC_AUTOGEN'].split(' ')
 	args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
 	
@@ -547,6 +543,5 @@
 	outf.close()
 	
-	args = [common['CC']]
-	args.extend(common['CC_ARGS'])
+	args = common['CC_AUTOGEN'].split(' ')
 	args.extend(["-S", "-o", PROBE_INT128_OUTPUT, PROBE_INT128_SOURCE])
 	
@@ -852,7 +847,6 @@
 		
 		# Compiler
-		common['CC_ARGS'] = []
 		if (config['COMPILER'] == "gcc_cross"):
-			target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
+			target, cc_args, gnu_target, helenos_target = get_target(config)
 			
 			if (target is None) or (gnu_target is None):
@@ -867,9 +861,9 @@
 			
 			check_common(common, "GCC")
-			common['CC'] = common['GCC']
-			common['CC_ARGS'].extend(cc_args)
+			common['CC'] = " ".join([common['GCC']] + cc_args)
+			common['CC_AUTOGEN'] = common['CC']
 		
 		if (config['COMPILER'] == "gcc_helenos"):
-			target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
+			target, cc_args, gnu_target, helenos_target = get_target(config)
 			
 			if (target is None) or (helenos_target is None):
@@ -884,6 +878,6 @@
 			
 			check_common(common, "GCC")
-			common['CC'] = common['GCC']
-			common['CC_ARGS'].extend(cc_args)
+			common['CC'] = " ".join([common['GCC']] + cc_args)
+			common['CC_AUTOGEN'] = common['CC']
 		
 		if (config['COMPILER'] == "gcc_native"):
@@ -893,4 +887,5 @@
 			check_common(common, "GCC")
 			common['CC'] = common['GCC']
+			common['CC_AUTOGEN'] = common['CC']
 		
 		if (config['COMPILER'] == "icc"):
@@ -900,10 +895,11 @@
 			
 			common['CC'] = "icc"
+			common['CC_AUTOGEN'] = common['CC']
 		
 		if (config['COMPILER'] == "clang"):
-			target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
-			
-			if (target is None) or (gnu_target is None) or (clang_target is None):
-				print_error(["Unsupported compiler target for clang.",
+			target, cc_args, gnu_target, helenos_target = get_target(config)
+			
+			if (target is None) or (gnu_target is None):
+				print_error(["Unsupported compiler target.",
 				             "Please contact the developers of HelenOS."])
 			
@@ -911,14 +907,18 @@
 			prefix = "%s-" % gnu_target
 			
-			check_app(["clang", "--version"], "clang compiler", "preferably version 1.0 or newer")
+			check_clang(path, prefix, common, "")
 			check_gcc(path, prefix, common, PACKAGE_GCC)
 			check_binutils(path, prefix, common, PACKAGE_BINUTILS)
 			
 			check_common(common, "GCC")
-			common['CC'] = "clang"
-			common['CC_ARGS'].extend(cc_args)
-			common['CC_ARGS'].append("-target")
-			common['CC_ARGS'].append(clang_target)
-			common['CLANG_TARGET'] = clang_target
+			check_common(common, "CLANG")
+			common['CC'] = " ".join([common['CLANG']] + cc_args)
+			common['CC_AUTOGEN'] = common['CC'] + " -no-integrated-as"
+			
+			if (config['INTEGRATED_AS'] == "yes"):
+				common['CC'] += " -integrated-as"
+			
+			if (config['INTEGRATED_AS'] == "no"):
+				common['CC'] += " -no-integrated-as"
 		
 		check_python()
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -160,6 +160,13 @@
 LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl
 
-AFLAGS = --fatal-warnings
+AFLAGS =
 LFLAGS = --fatal-warnings
+
+# FIXME: This condition is a workaround for issues #692 and #693.
+ifneq ($(KARCH),ia64)
+ifneq ($(KARCH),mips32)
+	AFLAGS += --fatal-warnings
+endif
+endif
 
 ifeq ($(STATIC_NEEDED),y)
@@ -228,33 +235,23 @@
 	find . -name '*.lo' -follow -exec rm \{\} \;
 
-GCC_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 -ffunction-sections \
-	-nostdlib -nostdinc -Wall -Wextra -Wno-clobbered -Wno-unused-parameter \
-	-Wmissing-prototypes -std=gnu99 -Werror-implicit-function-declaration \
-	-Wwrite-strings -pipe -ggdb -D__$(ENDIANESS)__
-
-ICC_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 \
-	-Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-pipe -g -D__$(ENDIANESS)__
-
-# 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) \
-	-ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
+COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
+	-ffreestanding -fno-builtin -nostdlib -nostdinc -fexec-charset=UTF-8 \
+	-finput-charset=UTF-8 -D__$(ENDIANESS)__
+
+GCC_CFLAGS = -ffunction-sections -Wall -Wextra -Wno-clobbered \
+	-Wno-unused-parameter -Wmissing-prototypes -std=gnu99 \
+	-Werror-implicit-function-declaration \
+	-Wwrite-strings -pipe
+
+ICC_CFLAGS = -Wall -Wextra -Wno-clobbered -Wno-unused-parameter \
+	-Wmissing-prototypes -Werror-implicit-function-declaration \
+	-Wwrite-strings -pipe
+
+CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
 	-std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
-	-integrated-as -pipe -g -target $(CLANG_TARGET) -D__$(ENDIANESS)__
-
-LIB_CFLAGS = $(CFLAGS) -fPIC
-LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
+	-pipe -fno-stack-protector -fno-PIC
 
 ifeq ($(CONFIG_DEBUG),y)
-	GCC_CFLAGS += -Werror
-	ICC_CFLAGS += -Werror
+	COMMON_CFLAGS += -Werror
 endif
 
@@ -267,5 +264,5 @@
 # Prepare for POSIX before including platform specific stuff
 ifeq ($(POSIX_COMPAT),y)
-	CFLAGS = -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
+	CFLAGS += -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
 	BASE_LIBS = $(LIBPOSIX_PREFIX)/libposixaslibc.a $(LIBPOSIX_PREFIX)/libc4posix.a $(LIBSOFTINT_PREFIX)/libsoftint.a
 endif
@@ -282,31 +279,37 @@
 
 ifeq ($(COMPILER),gcc_cross)
-	CFLAGS += $(GCC_CFLAGS)
+	CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),gcc_helenos)
-	CFLAGS += $(GCC_CFLAGS)
+	CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),gcc_native)
-	CFLAGS += $(GCC_CFLAGS)
+	CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),icc)
-	CFLAGS += $(ICC_CFLAGS)
+	CFLAGS += $(COMMON_CFLAGS) $(ICC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),clang)
-	CFLAGS += $(CLANG_CFLAGS)
+	CFLAGS += $(COMMON_CFLAGS) $(CLANG_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
+
+LIB_CFLAGS = $(CFLAGS) -fPIC
+LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
 
 ifneq ($(MAKECMDGOALS),clean)
 -include $(DEPEND)
 endif
+
+AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
+LD_CFLAGS := $(addprefix -Xlinker ,$(LFLAGS))
 
 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
@@ -372,5 +375,5 @@
 
 %.o: %.S $(DEPEND)
-	$(GCC) $(DEFS) $(GCC_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
+	$(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
@@ -378,5 +381,5 @@
 
 %.o: %.s $(DEPEND)
-	$(AS) $(AFLAGS) -o $@ $<
+	$(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm
@@ -396,5 +399,5 @@
 
 %.lo: %.S $(DEPEND)
-	$(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
+	$(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
@@ -402,5 +405,5 @@
 
 %.lo: %.s $(DEPEND)
-	$(AS) $(AFLAGS) -o $@ $<
+	$(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/Makefile	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -194,5 +194,5 @@
 %.h: %.ag
 	$(AUTOGEN) probe $< >$<.probe.c
-	$(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
+	$(CC_AUTOGEN) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
 	$(AUTOGEN) generate $< <$<.probe.s >$@   
 
Index: uspace/lib/c/arch/amd64/Makefile.common
===================================================================
--- uspace/lib/c/arch/amd64/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/amd64/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -27,6 +27,5 @@
 #
 
-GCC_CFLAGS += -mno-tls-direct-seg-refs -fno-omit-frame-pointer
-CLANG_CFLAGS += -fno-omit-frame-pointer
+COMMON_CFLAGS += -mno-tls-direct-seg-refs -fno-omit-frame-pointer
 LFLAGS += --gc-sections
 
Index: uspace/lib/c/arch/arm32/Makefile.common
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/arm32/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -28,5 +28,5 @@
 #
 
-GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -mapcs-frame \
+COMMON_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -mapcs-frame \
 	-march=$(subst _,-,$(PROCESSOR_ARCH))
 
@@ -34,5 +34,5 @@
 
 ifeq ($(CONFIG_FPU),y)
-	GCC_CFLAGS += -mfloat-abi=hard
+	COMMON_CFLAGS += -mfloat-abi=hard
 else
 	BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
Index: uspace/lib/c/arch/ia32/Makefile.common
===================================================================
--- uspace/lib/c/arch/ia32/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/ia32/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -28,11 +28,10 @@
 
 ifeq ($(PROCESSOR),i486)
-	GCC_CFLAGS += -march=i486 
+	COMMON_CFLAGS += -march=i486
 else
-	GCC_CFLAGS += -march=pentium
+	COMMON_CFLAGS += -march=pentium
 endif
 
-GCC_CFLAGS += -mno-tls-direct-seg-refs -fno-omit-frame-pointer
-CLANG_CFLAGS += -fno-omit-frame-pointer
+COMMON_CFLAGS += -mno-tls-direct-seg-refs -fno-omit-frame-pointer
 LFLAGS += --gc-sections
 
Index: uspace/lib/c/arch/mips32/Makefile.common
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/mips32/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -27,5 +27,5 @@
 #
 
-GCC_CFLAGS += -msoft-float -mabi=32
+COMMON_CFLAGS += -msoft-float -mabi=32
 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
 AS_PROLOG = .module softfloat;.abicalls;
@@ -38,9 +38,9 @@
 
 ifeq ($(MACHINE),msim)
-	GCC_CFLAGS += -march=r4000 
+	COMMON_CFLAGS += -march=r4000
 endif
 
 ifeq ($(MACHINE),lmalta)
-	GCC_CFLAGS += -march=4kc
+	COMMON_CFLAGS += -march=4kc
 endif
 
Index: uspace/lib/c/arch/mips32eb/Makefile.common
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/mips32eb/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -27,5 +27,5 @@
 #
 
-GCC_CFLAGS += -msoft-float -mabi=32
+COMMON_CFLAGS += -msoft-float -mabi=32
 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
 AS_PROLOG = .module softfloat;.abicalls;
@@ -38,5 +38,5 @@
 
 ifeq ($(MACHINE),bmalta)
-	GCC_CFLAGS += -march=4kc
+	COMMON_CFLAGS += -march=4kc
 endif
 
Index: uspace/lib/c/arch/ppc32/Makefile.common
===================================================================
--- uspace/lib/c/arch/ppc32/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/ppc32/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -33,5 +33,5 @@
 endif
 
-GCC_CFLAGS += -mcpu=powerpc -m$(FLOATS)-float -m32
+COMMON_CFLAGS += -mcpu=powerpc -m$(FLOATS)-float -m32
 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
 AFLAGS += -a32
Index: uspace/lib/c/arch/sparc64/Makefile.common
===================================================================
--- uspace/lib/c/arch/sparc64/Makefile.common	(revision 0f283873f379e5b806282e95319c9af0c414f872)
+++ uspace/lib/c/arch/sparc64/Makefile.common	(revision a0a273e83bf1cedff09f94c8181d7f89a6c637a6)
@@ -28,10 +28,10 @@
 
 ifeq ($(PROCESSOR),sun4v)
-GCC_CFLAGS += -mcpu=niagara -mno-vis
+COMMON_CFLAGS += -mcpu=niagara -mno-vis
 else
-GCC_CFLAGS += -mcpu=ultrasparc
+COMMON_CFLAGS += -mcpu=ultrasparc
 endif
 
-GCC_CFLAGS += -m64 -mcmodel=medlow
+COMMON_CFLAGS += -m64 -mcmodel=medlow
 
 LFLAGS += -no-check-sections --gc-sections
