Index: Makefile
===================================================================
--- Makefile	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ Makefile	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -62,4 +62,8 @@
 
 CROSS_PATH = $(shell dirname "$(CC)")
+
+ifeq ($(MACHINE),bmalta)
+	UARCH = mips32eb
+endif
 
 .PHONY: all precheck cscope cscope_parts autotool config_default config distclean clean check releasefile release common export-posix space
Index: kernel/arch/amd64/meson.build
===================================================================
--- kernel/arch/amd64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/amd64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -27,18 +27,4 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-
-# TODO: Red Zone is only a problem if we allow interrupts to land on an active
-#       stack. Using separate stack for interrupts and ensuring that we never
-#       enable interrupts on an interrupt stack would allow us to get rid of
-#       the argument.
-
-kernel_c_args += [ '-mno-sse', '-mno-sse2', '-mcmodel=' + MEMORY_MODEL, '-mno-red-zone', '-fno-unwind-tables', '-fno-omit-frame-pointer' ]
-
-# TODO: fix this
-kernel_link_args += [ '-Wl,--no-gc-sections' ]
-
-if PROCESSOR == 'opteron'
-	kernel_c_args += '-march=opteron'
-endif
 
 arch_src += files(
Index: kernel/arch/arm32/meson.build
===================================================================
--- kernel/arch/arm32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/arm32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -26,15 +26,4 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-
-
-atsign = '%'
-
-kernel_c_args += [ '-fno-omit-frame-pointer', '-mapcs-frame', '-mno-unaligned-access', '-mfpu=vfpv3' ]
-
-if CONFIG_FPU
-	# This is necessary to allow vmsr insn and fpexc manipulation
-	# Use vfp32 to allow context save/restore of d16-d31 regs.
-	kernel_c_args += [ '-mfloat-abi=hard' ]
-endif
 
 arch_src += files(
Index: kernel/arch/arm64/meson.build
===================================================================
--- kernel/arch/arm64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/arm64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -26,6 +26,4 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-
-kernel_c_args += [ '-fno-omit-frame-pointer', '-march=armv8-a+nofp+nosimd', '-mgeneral-regs-only' ]
 
 arch_src += files(
Index: kernel/arch/ia32/meson.build
===================================================================
--- kernel/arch/ia32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/ia32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -26,9 +26,4 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-
-kernel_c_args += [ '-mno-mmx', '-mno-sse', '-mno-sse2', '-mno-sse3', '-mno-3dnow' ]
-
-# TODO: fix this
-kernel_link_args += [ '-Wl,--no-gc-sections' ]
 
 arch_src += files(
Index: kernel/arch/ia64/meson.build
===================================================================
--- kernel/arch/ia64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/ia64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -27,7 +27,4 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-
-kernel_c_args += [ '-mconstant-gp', '-fno-unwind-tables', '-mfixed-range=f32-f127' ]
-kernel_link_args += [ '-Wl,-EL' ]
 
 arch_src += files(
@@ -60,7 +57,4 @@
 endif
 
-if MACHINE == 'i460GX'
-	kernel_c_args += [ '-DI460GX' ]
-endif
 
 _check_headers = [
Index: kernel/arch/mips32/meson.build
===================================================================
--- kernel/arch/mips32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/mips32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -26,14 +26,4 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-
-kernel_c_args += [
-	'-msoft-float',
-	'-mno-abicalls',
-	'-G', '0',
-	'-fno-zero-initialized-in-bss',
-	'-mabi=32',
-]
-
-as_prolog = '.module softfloat;'
 
 arch_src += files(
@@ -71,4 +61,5 @@
 endif
 
+
 _check_headers = [
 	'include/arch/istate_struct.h',
Index: kernel/arch/ppc32/meson.build
===================================================================
--- kernel/arch/ppc32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/ppc32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -27,8 +27,4 @@
 #
 
-# FIXME: enable gc-sections
-kernel_c_args += [ '-msoft-float', '-fno-function-sections' ]
-kernel_link_args += [ '-Wl,--no-check-sections', '-Wl,--no-gc-sections' ]
-
 arch_src += files(
 	'src/context.S',
@@ -54,4 +50,5 @@
 )
 
+
 _check_headers = [
 	'include/arch/istate_struct.h',
Index: kernel/arch/riscv64/meson.build
===================================================================
--- kernel/arch/riscv64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/arch/riscv64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -27,6 +27,4 @@
 #
 
-kernel_c_args += [ '-mcmodel=medany' ]
-
 arch_src += files(
 	'src/boot/boot.S',
@@ -49,4 +47,5 @@
 )
 
+
 _check_headers = [
 	'include/arch/istate_struct.h',
Index: kernel/genarch/meson.build
===================================================================
--- kernel/genarch/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/genarch/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -164,5 +164,4 @@
 
 genarch_src = []
-genarch_check_headers = []
 
 foreach f : _src
Index: kernel/meson.build
===================================================================
--- kernel/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ kernel/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -1,24 +1,15 @@
 
-## The at-sign
-#
-# The `atsign` variable holds the ASCII character representing the at-sign
-# ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
-# don't use '@' for starting a comment, `atsign` is merely '@'. However, on
-# those that do use it for starting a comment (e.g. arm32), `atsign` must be
-# defined as the percentile-sign ('%') in the architecture-dependent files.
-#
-atsign = '@'
-
-## Some architectures need a particular string at the beginning of assembly files.
-as_prolog = ''
-
-kernel_c_args = []
-kernel_link_args = []
-kernel_includes = []
 arch_src = []
 
+# Fills arch_src.
 subdir('arch' / h_arch)
+
+# Defines genarch_src.
 subdir('genarch')
+
+# Defines generic_src, instrumentable_src.
 subdir('generic')
+
+# Defines test_src
 subdir('test')
 
@@ -27,5 +18,5 @@
 symtab_section = '.section symtab.data, "a", ' + atsign + 'progbits;'
 
-kernel_includes += include_directories(
+kernel_include_dirs = include_directories(
 	'generic/include',
 	'genarch/include',
@@ -46,4 +37,5 @@
 ]
 
+# Preprocess linker script using C preprocessor.
 kernel_ldscript = custom_target('_link.ld',
 	input: 'arch' / h_arch / '_link.ld.in',
@@ -63,5 +55,5 @@
 )
 
-kernel_link_args += [
+kernel_link_args = arch_kernel_link_args + [
 	'-Wl,--nmagic',
 	'-T', meson.current_build_dir() / '_link.ld',
@@ -73,5 +65,5 @@
 endif
 
-kernel_c_args += kernel_defs + [
+kernel_c_args = arch_kernel_c_args + kernel_defs + [
 	'-ffreestanding',
 	# TODO: remove this flag
@@ -88,5 +80,5 @@
 
 instrumentables = static_library('instrumentables', instrumentable_src,
-	include_directories: kernel_includes,
+	include_directories: kernel_include_dirs,
 	implicit_include_directories: false,
 	c_args: kernel_c_args + (CONFIG_TRACE ? [ '-finstrument-functions' ] : []),
@@ -95,5 +87,5 @@
 
 noninstrumentables = static_library('noninstrumentables', arch_src, genarch_src, generic_src, test_src,
-	include_directories: kernel_includes,
+	include_directories: kernel_include_dirs,
 	implicit_include_directories: false,
 	c_args: kernel_c_args,
@@ -129,5 +121,5 @@
 	output: 'empty_map.S',
 	capture: true,
-	command: [ 'echo', as_prolog + symtab_section ],
+	command: [ 'echo', kernel_as_prolog + symtab_section ],
 )
 
@@ -139,5 +131,5 @@
 
 	kernel_elf = executable(kernel_name + '.elf', kernel_map_S,
-		include_directories: kernel_includes,
+		include_directories: kernel_include_dirs,
 		implicit_include_directories: false,
 		c_args: kernel_c_args,
@@ -170,5 +162,5 @@
 			output: kernel_map_S_name,
 			capture: true,
-			command: [ 'echo', as_prolog + symtab_section + ' .incbin "@INPUT@"' ],
+			command: [ 'echo', kernel_as_prolog + symtab_section + ' .incbin "@INPUT@"' ],
 		)
 	endif
Index: meson.build
===================================================================
--- meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -173,61 +173,4 @@
 )
 
-if h_arch == 'arm32'
-	add_project_arguments(
-		'-mcpu=' + '-'.join(PROCESSOR.split('_')),
-		CONFIG_FPU ? '-mfloat-abi=hard' : [],
-		language : [ 'c', 'cpp' ],
-	)
-
-	add_project_link_arguments(
-		'-mcpu=' + '-'.join(PROCESSOR.split('_')),
-		CONFIG_FPU ? '-mfloat-abi=hard' : [],
-		language : [ 'c', 'cpp' ],
-	)
-
-elif h_arch == 'ia32'
-# FIXME: enabling -march for uspace makes malloc tests crash. Investigate.
-
-#	if PROCESSOR == 'core'
-#		# FIXME
-#		add_project_arguments('-march=prescott', language : [ 'c', 'cpp' ])
-#		add_project_link_arguments('-march=prescott', language : [ 'c', 'cpp' ])
-#	else
-#		add_project_arguments('-march=' + '-'.join(PROCESSOR.split('_')), language : [ 'c', 'cpp' ])
-#		add_project_link_arguments('-march=' + '-'.join(PROCESSOR.split('_')), language : [ 'c', 'cpp' ])
-#	endif
-
-elif h_arch == 'mips32'
-
-	if MACHINE == 'msim'
-		add_project_arguments('-march=r4000', language : [ 'c', 'cpp' ])
-		add_project_link_arguments('-march=r4000', language : [ 'c', 'cpp' ])
-
-	elif MACHINE == 'bmalta'
-		add_project_arguments('-march=4kc', language : [ 'c', 'cpp' ])
-		add_project_link_arguments('-march=4kc', language : [ 'c', 'cpp' ])
-
-	elif MACHINE == 'lmalta'
-		add_project_arguments('-march=4kc', language : [ 'c', 'cpp' ])
-		add_project_link_arguments('-march=4kc', language : [ 'c', 'cpp' ])
-
-	else
-		error('Unknown machine')
-
-	endif
-
-elif h_arch == 'ppc32'
-
-	if CONFIG_FPU
-		float = '-mhard-float'
-	else
-		float = '-msoft-float'
-	endif
-
-	add_project_arguments(float, language : [ 'c', 'cpp' ])
-	add_project_link_arguments(float, language : [ 'c', 'cpp' ])
-
-endif
-
 # TODO: enable more warnings
 # FIXME: -fno-builtin-strftime works around seemingly spurious format warning.
@@ -310,4 +253,59 @@
 endforeach
 
+# Init binaries.
+rd_init = [
+	'app/init',
+	'srv/bd/rd',
+	'srv/fs/' + RDFMT,
+	'srv/loader',
+	'srv/locsrv',
+	'srv/logger',
+	'srv/ns',
+	'srv/vfs',
+]
+
+# Binaries allowed on the initrd image when CONFIG_BAREBONE is enabled.
+rd_essential = rd_init + [
+	'app/bdsh',
+	'app/getterm',
+	'app/kio',
+
+	'srv/devman',
+	'srv/fs/locfs',
+	'srv/hid/input',
+	'srv/hid/output',
+	'srv/hid/compositor',
+	'srv/hid/console',
+	'srv/klog',
+
+	'drv/root/root',
+	'drv/root/virt',
+	'drv/fb/kfb',
+]
+
+if CONFIG_FB
+	rd_essential += [
+		'app/vlaunch',
+		'app/vterm',
+	]
+endif
+
+
+## The at-sign
+#
+# The `atsign` variable holds the ASCII character representing the at-sign
+# ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
+# don't use '@' for starting a comment, `atsign` is merely '@'. However, on
+# those that do use it for starting a comment (e.g. arm32), `atsign` must be
+# defined as the percentile-sign ('%') in the architecture-dependent files.
+#
+atsign = '@'
+
+## Some architectures need a particular string at the beginning of assembly files.
+kernel_as_prolog = ''
+uspace_as_prolog = ''
+
+subdir('meson' / 'arch' / h_arch)
+
 subdir('kernel')
 subdir('uspace')
@@ -351,6 +349,6 @@
 	'HELENOS_CROSS_PATH' : cc_path,
 	'HELENOS_ARCH' : cc_arch,
-	'HELENOS_CFLAGS' : ' '.join(meson.get_cross_property('c_args')),
-	'HELENOS_CXXFLAGS' : ' '.join(meson.get_cross_property('cpp_args')),
+	'HELENOS_CFLAGS' : ' '.join(arch_uspace_c_args),
+	'HELENOS_CXXFLAGS' : ' '.join(arch_uspace_c_args),
 	'HELENOS_CPPFLAGS' : ' '.join(export_cppflags),
 	'HELENOS_LDFLAGS' : ' '.join(export_ldflags),
Index: meson/arch/amd64/meson.build
===================================================================
--- meson/arch/amd64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/amd64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,46 @@
+# TODO: Red Zone is only a problem if we allow interrupts to land on an active
+#       stack. Using separate stack for interrupts and ensuring that we never
+#       enable interrupts on an interrupt stack would allow us to get rid of
+#       the argument.
+
+arch_uspace_c_args = [
+	'-D__LE__',
+	'-fno-omit-frame-pointer',
+]
+
+arch_kernel_c_args = arch_uspace_c_args + [
+	'-mno-sse',
+	'-mno-sse2',
+	'-mcmodel=' + MEMORY_MODEL,
+	'-mno-red-zone',
+	'-fno-unwind-tables',
+]
+
+if PROCESSOR == 'opteron'
+	arch_kernel_c_args += '-march=opteron'
+endif
+
+
+# TODO: Enable --gc-sections
+arch_kernel_link_args = [ '-Wl,-z,max-page-size=0x1000', '-nostdlib', '-Wl,--no-gc-sections' ]
+arch_uspace_link_args = [ '-Wl,-z,max-page-size=0x1000', '-nostdlib', '-lgcc' ]
+
+
+rd_essential += [
+	'app/edit',
+	'app/mixerctl',
+	'app/wavplay',
+
+	'srv/audio/hound',
+
+	'drv/intctl/apic',
+	'drv/intctl/i8259',
+	'drv/platform/pc',
+	'drv/block/ata_bd',
+	'drv/bus/pci/pciintel',
+	'drv/bus/isa',
+	'drv/audio/sb16',
+	'drv/char/i8042',
+	'drv/hid/ps2mouse',
+	'drv/hid/xtkbd',
+]
Index: meson/arch/arm32/meson.build
===================================================================
--- meson/arch/arm32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/arm32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,57 @@
+atsign = '%'
+
+_cpudef = '-mcpu=' + '-'.join(PROCESSOR.split('_'))
+
+
+arch_uspace_c_args = [
+	_cpudef,
+	'-D__LE__',
+	'-fno-omit-frame-pointer',
+	'-mapcs-frame',
+	'-ffixed-r9',
+	'-mtp=soft',
+]
+
+if CONFIG_FPU
+	# This is necessary for kernel too, to allow vmsr insn and fpexc manipulation.
+	# Use vfp32 to allow context save/restore of d16-d31 regs.
+	arch_uspace_c_args += [ '-mfloat-abi=hard' ]
+endif
+
+arch_kernel_c_args = arch_uspace_c_args + [ '-mno-unaligned-access', '-mfpu=vfpv3' ]
+arch_kernel_link_args = [ '-nostdlib', '-Wl,-z,max-page-size=0x1000' ]
+arch_uspace_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
+
+
+rd_essential += [
+	'drv/bus/usb/ehci',
+	'drv/bus/usb/ohci',
+	'drv/bus/usb/usbdiag',
+	'drv/bus/usb/usbflbk',
+	'drv/bus/usb/usbhub',
+	'drv/bus/usb/usbmid',
+	'drv/block/usbmast',
+	'drv/hid/usbhid',
+]
+
+if MACHINE == 'gta02'
+	rd_essential += [
+		'srv/hid/s3c24xx_ts',
+		'srv/hw/char/s3c24xx_uart',
+	]
+
+elif MACHINE == 'beagleboardxm' or MACHINE == 'beaglebone'
+	rd_essential += [
+		'drv/platform/amdm37x',
+		'drv/fb/amdm37x_dispc',
+	]
+
+elif MACHINE == 'integratorcp'
+	rd_essential += [
+		'drv/char/pl050',
+		'drv/hid/atkbd',
+		'drv/hid/ps2mouse',
+		'drv/intctl/icp-ic',
+		'drv/platform/icp',
+	]
+endif
Index: meson/arch/arm64/meson.build
===================================================================
--- meson/arch/arm64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/arm64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,13 @@
+arch_uspace_c_args = [ '-D__LE__', '-fno-omit-frame-pointer' ]
+arch_kernel_c_args = arch_uspace_c_args + [ '-march=armv8-a+nofp+nosimd', '-mgeneral-regs-only' ]
+arch_kernel_link_args = [ '-nostdlib' ]
+arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
+
+
+if MACHINE == 'virt'
+	rd_essential += [
+		'drv/char/pl011',
+		'drv/intctl/gicv2',
+		'drv/platform/arm64virt',
+	]
+endif
Index: meson/arch/ia32/meson.build
===================================================================
--- meson/arch/ia32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/ia32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,48 @@
+_march = '-march=' + '-'.join(PROCESSOR.split('_'))
+if PROCESSOR == 'core'
+	# FIXME
+	_march = '-march=prescott'
+endif
+
+
+arch_uspace_c_args = [
+	# FIXME: enabling -march for uspace makes malloc tests crash. Investigate.
+	# _march,
+	'-D__LE__',
+	'-mno-tls-direct-seg-refs',
+	'-fno-omit-frame-pointer',
+]
+
+arch_kernel_c_args = arch_uspace_c_args + [
+	_march,
+	'-mno-mmx',
+	'-mno-sse',
+	'-mno-sse2',
+	'-mno-sse3',
+	'-mno-3dnow',
+]
+
+
+# TODO: Enable --gc-sections.
+arch_kernel_link_args = [ '-nostdlib', '-Wl,--no-gc-sections' ]
+arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
+
+
+rd_essential += [
+	'app/edit',
+	'app/mixerctl',
+	'app/wavplay',
+
+	'srv/audio/hound',
+
+	'drv/intctl/apic',
+	'drv/intctl/i8259',
+	'drv/platform/pc',
+	'drv/block/ata_bd',
+	'drv/bus/pci/pciintel',
+	'drv/bus/isa',
+	'drv/audio/sb16',
+	'drv/char/i8042',
+	'drv/hid/ps2mouse',
+	'drv/hid/xtkbd',
+]
Index: meson/arch/ia64/meson.build
===================================================================
--- meson/arch/ia64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/ia64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,27 @@
+arch_uspace_c_args = [ '-D__LE__', '-fno-unwind-tables' ]
+arch_kernel_c_args = arch_uspace_c_args + [ '-mconstant-gp', '-mfixed-range=f32-f127' ]
+if MACHINE == 'i460GX'
+	arch_kernel_c_args += [ '-DI460GX' ]
+endif
+
+
+arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
+arch_kernel_link_args = [ '-nostdlib', '-Wl,-EL' ]
+
+
+if MACHINE == 'i460GX'
+	rd_essential += [
+		'drv/platform/pc',
+		'drv/bus/pci/pciintel',
+		'drv/bus/isa',
+		'drv/char/i8042',
+		'drv/hid/xtkbd',
+	]
+
+elif MACHINE == 'ski'
+	rd_essential += [
+		'drv/char/ski-con',
+		'drv/platform/ski',
+	]
+
+endif
Index: meson/arch/mips32/meson.build
===================================================================
--- meson/arch/mips32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/mips32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,57 @@
+if MACHINE == 'msim'
+	_march = '-march=r4000'
+	_endian = '-D__LE__'
+elif MACHINE == 'lmalta'
+	_march = '-march=4kc'
+	_endian = '-D__LE__'
+elif MACHINE == 'bmalta'
+	_march = '-march=4kc'
+	_endian = '-D__BE__'
+else
+	error('Unknown machine')
+endif
+
+arch_uspace_c_args = [
+	_march,
+	_endian,
+	'-fno-omit-frame-pointer',
+	'-msoft-float',
+	'-mabi=32',
+]
+
+arch_kernel_c_args = arch_uspace_c_args + [
+	'-mno-abicalls',
+	'-G', '0',
+	'-fno-zero-initialized-in-bss',
+]
+
+
+arch_kernel_link_args = [ '-nostdlib' ]
+arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
+
+
+kernel_as_prolog = '.module softfloat;'
+uspace_as_prolog = '.module softfloat;.abicalls;'
+
+
+if MACHINE == 'bmalta' or MACHINE == 'lmalta'
+	rd_essential += [
+		'drv/platform/malta',
+		'drv/intctl/i8259',
+		'drv/block/ata_bd',
+		'drv/bus/pci/pciintel',
+		'drv/bus/isa',
+		'drv/char/i8042',
+		'drv/char/ns8250',
+		'drv/hid/ps2mouse',
+		'drv/hid/xtkbd',
+	]
+
+elif MACHINE == 'msim'
+	rd_essential += [
+		'drv/platform/msim',
+		'drv/block/ddisk',
+		'drv/char/msim-con',
+	]
+
+endif
Index: meson/arch/ppc32/meson.build
===================================================================
--- meson/arch/ppc32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/ppc32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,25 @@
+# FIXME: enable --gc-sections
+
+_common_c_args = [ '-D__BE__', '-fno-omit-frame-pointer', '-m32', '-Wa,-a32', '-mcpu=powerpc' ]
+
+arch_kernel_c_args = _common_c_args + [ '-msoft-float', '-fno-function-sections' ]
+arch_uspace_c_args = _common_c_args + [ CONFIG_FPU ? '-mhard-float' : '-msoft-float' ]
+arch_kernel_link_args = [ '-nostdlib', '-Wl,-z,max-page-size=0x1000', '-Wl,--no-check-sections', '-Wl,--no-gc-sections' ]
+arch_uspace_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
+
+
+rd_essential += [
+	'drv/platform/mac',
+	'drv/bus/adb/cuda_adb',
+	'drv/bus/pci/pciintel',
+	'drv/bus/usb/ohci',
+	'drv/bus/usb/usbdiag',
+	'drv/bus/usb/usbflbk',
+	'drv/bus/usb/usbhub',
+	'drv/bus/usb/usbmid',
+	'drv/bus/usb/vhc',
+	'drv/block/usbmast',
+	'drv/hid/adb-kbd',
+	'drv/hid/adb-mouse',
+	'drv/hid/usbhid',
+]
Index: meson/arch/riscv64/meson.build
===================================================================
--- meson/arch/riscv64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
+++ meson/arch/riscv64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -0,0 +1,7 @@
+arch_uspace_c_args = [ '-D__LE__', '-fno-omit-frame-pointer' ]
+arch_kernel_c_args = arch_uspace_c_args + [ '-mcmodel=medany' ]
+arch_kernel_link_args = [ '-nostdlib' ]
+arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
+
+rd_essential += [
+]
Index: meson/cross/amd64
===================================================================
--- meson/cross/amd64	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/amd64	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__LE__', '-fno-omit-frame-pointer' ]
-cpp_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
 cc_arch = 'amd64'
 h_arch = 'amd64'
Index: meson/cross/amd64_clang
===================================================================
--- meson/cross/amd64_clang	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/amd64_clang	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__LE__', '-fno-omit-frame-pointer' ]
-cpp_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
 cc_arch = 'amd64'
 h_arch = 'amd64'
Index: meson/cross/arm32
===================================================================
--- meson/cross/arm32	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/arm32	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -15,8 +15,5 @@
 has_function_printf = true
 needs_exe_wrapper = true
-c_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-mapcs-frame', '-ffixed-r9', '-mtp=soft' ]
-cpp_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-mapcs-frame', '-ffixed-r9', '-mtp=soft', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000', '-mapcs-frame', '-ffixed-r9', '-mtp=soft' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000', '-mapcs-frame', '-ffixed-r9', '-mtp=soft', '-fno-exceptions' ]
+
 cc_arch = 'arm'
 h_arch = 'arm32'
Index: meson/cross/arm64
===================================================================
--- meson/cross/arm64	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/arm64	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -15,8 +15,5 @@
 has_function_printf = true
 needs_exe_wrapper = true
-c_args = [ '-D__LE__', '-fno-omit-frame-pointer' ]
-cpp_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-fno-exceptions' ]
+
 cc_arch = 'aarch64'
 h_arch = 'arm64'
Index: meson/cross/ia32
===================================================================
--- meson/cross/ia32	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/ia32	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__LE__', '-mno-tls-direct-seg-refs', '-fno-omit-frame-pointer' ]
-cpp_args = [ '-D__LE__', '-mno-tls-direct-seg-refs', '-fno-omit-frame-pointer', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-mno-tls-direct-seg-refs' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-mno-tls-direct-seg-refs' ]
 cc_arch = 'i686'
 h_arch = 'ia32'
Index: meson/cross/ia64
===================================================================
--- meson/cross/ia64	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/ia64	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__LE__', '-fno-unwind-tables' ]
-cpp_args = [ '-D__LE__', '-fno-unwind-tables', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc' ]
-cpp_link_args = [ '-nostdlib', '-lgcc' ]
 cc_arch = 'ia64'
 h_arch = 'ia64'
Index: meson/cross/mips32
===================================================================
--- meson/cross/mips32	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/mips32	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-msoft-float', '-mabi=32' ]
-cpp_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-msoft-float', '-mabi=32', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-msoft-float', '-mabi=32' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-msoft-float', '-mabi=32' ]
 cc_arch = 'mipsel'
 h_arch = 'mips32'
Index: meson/cross/mips32eb
===================================================================
--- meson/cross/mips32eb	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/mips32eb	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__BE__', '-fno-omit-frame-pointer', '-msoft-float', '-mabi=32' ]
-cpp_args = [ '-D__BE__', '-fno-omit-frame-pointer', '-msoft-float', '-mabi=32', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-msoft-float', '-mabi=32' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-msoft-float', '-mabi=32' ]
 cc_arch = 'mips'
 h_arch = 'mips32'
Index: meson/cross/ppc32
===================================================================
--- meson/cross/ppc32	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/ppc32	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__BE__', '-fno-omit-frame-pointer', '-m32', '-Wa,-a32', '-mcpu=powerpc' ]
-cpp_args = [ '-D__BE__', '-fno-omit-frame-pointer', '-m32', '-Wa,-a32', '-mcpu=powerpc', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc', '-m32', '-Wl,-z,max-page-size=0x1000' ]
-cpp_link_args = [ '-nostdlib', '-lgcc', '-m32', '-Wl,-z,max-page-size=0x1000' ]
 cc_arch = 'ppc'
 h_arch = 'ppc32'
Index: meson/cross/riscv64
===================================================================
--- meson/cross/riscv64	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ meson/cross/riscv64	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -16,8 +16,4 @@
 needs_exe_wrapper = true
 
-c_args = [ '-D__LE__', '-fno-omit-frame-pointer' ]
-cpp_args = [ '-D__LE__', '-fno-omit-frame-pointer', '-fno-exceptions' ]
-c_link_args = [ '-nostdlib', '-lgcc' ]
-cpp_link_args = [ '-nostdlib', '-lgcc' ]
 cc_arch = 'riscv64'
 h_arch = 'riscv64'
Index: uspace/app/barber/meson.build
===================================================================
--- uspace/app/barber/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/app/barber/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -37,5 +37,5 @@
 	input : _images,
 	output : [ 'images.zip' ],
-	command : [ mkarray, '@OUTDIR@', 'images', 'image', as_prolog, '.data', '@INPUT@' ],
+	command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
 )
 _imgs_s = custom_target('barber_images.s',
Index: uspace/app/vlaunch/meson.build
===================================================================
--- uspace/app/vlaunch/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/app/vlaunch/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -6,5 +6,5 @@
 	input : _images,
 	output : [ 'images.zip' ],
-	command : [ mkarray, '@OUTDIR@', 'images', 'image', as_prolog, '.data', '@INPUT@' ],
+	command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
 )
 _imgs_s = custom_target('vlaunch_images.s',
Index: uspace/lib/c/arch/amd64/meson.build
===================================================================
--- uspace/lib/c/arch/amd64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/amd64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -14,21 +14,2 @@
 
 arch_start_src = files('src/crt0.S')
-
-rd_essential += [
-	'app/edit',
-	'app/mixerctl',
-	'app/wavplay',
-
-	'srv/audio/hound',
-
-	'drv/intctl/apic',
-	'drv/intctl/i8259',
-	'drv/platform/pc',
-	'drv/block/ata_bd',
-	'drv/bus/pci/pciintel',
-	'drv/bus/isa',
-	'drv/audio/sb16',
-	'drv/char/i8042',
-	'drv/hid/ps2mouse',
-	'drv/hid/xtkbd',
-]
Index: uspace/lib/c/arch/arm32/meson.build
===================================================================
--- uspace/lib/c/arch/arm32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/arm32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -14,35 +14,2 @@
 
 arch_start_src = files('src/crt0.S')
-
-if MACHINE == 'gta02'
-	rd_essential += [
-		'srv/hid/s3c24xx_ts',
-		'srv/hw/char/s3c24xx_uart',
-	]
-
-elif MACHINE == 'beagleboardxm' or MACHINE == 'beaglebone'
-	rd_essential += [
-		'drv/platform/amdm37x',
-		'drv/fb/amdm37x_dispc',
-	]
-
-elif MACHINE == 'integratorcp'
-	rd_essential += [
-		'drv/char/pl050',
-		'drv/hid/atkbd',
-		'drv/hid/ps2mouse',
-		'drv/intctl/icp-ic',
-		'drv/platform/icp',
-	]
-endif
-
-rd_essential += [
-	'drv/bus/usb/ehci',
-	'drv/bus/usb/ohci',
-	'drv/bus/usb/usbdiag',
-	'drv/bus/usb/usbflbk',
-	'drv/bus/usb/usbhub',
-	'drv/bus/usb/usbmid',
-	'drv/block/usbmast',
-	'drv/hid/usbhid',
-]
Index: uspace/lib/c/arch/arm64/meson.build
===================================================================
--- uspace/lib/c/arch/arm64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/arm64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -12,10 +12,2 @@
 
 arch_start_src = files('src/crt0.S')
-
-if MACHINE == 'virt'
-	rd_essential += [
-		'drv/char/pl011',
-		'drv/intctl/gicv2',
-		'drv/platform/arm64virt',
-	]
-endif
Index: uspace/lib/c/arch/ia32/meson.build
===================================================================
--- uspace/lib/c/arch/ia32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/ia32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -14,24 +14,2 @@
 
 arch_start_src = files('src/crt0.S')
-
-if MACHINE == 'bmalta' or MACHINE == 'lmalta'
-	rd_essential += [
-		'drv/platform/malta',
-		'drv/intctl/i8259',
-		'drv/block/ata_bd',
-		'drv/bus/pci/pciintel',
-		'drv/bus/isa',
-		'drv/char/i8042',
-		'drv/char/ns8250',
-		'drv/hid/ps2mouse',
-		'drv/hid/xtkbd',
-	]
-
-elif MACHINE == 'msim'
-	rd_essential += [
-		'drv/platform/msim',
-		'drv/block/ddisk',
-		'drv/char/msim-con',
-	]
-
-endif
Index: uspace/lib/c/arch/ia64/meson.build
===================================================================
--- uspace/lib/c/arch/ia64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/ia64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -15,19 +15,2 @@
 
 arch_start_src = files('src/crt0.S')
-
-if MACHINE == 'i460GX'
-	rd_essential += [
-		'drv/platform/pc',
-		'drv/bus/pci/pciintel',
-		'drv/bus/isa',
-		'drv/char/i8042',
-		'drv/hid/xtkbd',
-	]
-
-elif MACHINE == 'ski'
-	rd_essential += [
-		'drv/char/ski-con',
-		'drv/platform/ski',
-	]
-
-endif
Index: uspace/lib/c/arch/mips32/meson.build
===================================================================
--- uspace/lib/c/arch/mips32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/mips32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -11,27 +11,3 @@
 )
 
-as_prolog = '.module softfloat;.abicalls;'
-
 arch_start_src = files('src/crt0.S')
-
-if MACHINE == 'bmalta' or MACHINE == 'lmalta'
-	rd_essential += [
-		'drv/platform/malta',
-		'drv/intctl/i8259',
-		'drv/block/ata_bd',
-		'drv/bus/pci/pciintel',
-		'drv/bus/isa',
-		'drv/char/i8042',
-		'drv/char/ns8250',
-		'drv/hid/ps2mouse',
-		'drv/hid/xtkbd',
-	]
-
-elif MACHINE == 'msim'
-	rd_essential += [
-		'drv/platform/msim',
-		'drv/block/ddisk',
-		'drv/char/msim-con',
-	]
-
-endif
Index: uspace/lib/c/arch/ppc32/meson.build
===================================================================
--- uspace/lib/c/arch/ppc32/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/ppc32/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -14,18 +14,2 @@
 
 arch_start_src = files('src/crt0.S')
-
-rd_essential += [
-	'drv/platform/mac',
-	'drv/bus/adb/cuda_adb',
-	'drv/bus/pci/pciintel',
-	'drv/bus/usb/ohci',
-	'drv/bus/usb/usbdiag',
-	'drv/bus/usb/usbflbk',
-	'drv/bus/usb/usbhub',
-	'drv/bus/usb/usbmid',
-	'drv/bus/usb/vhc',
-	'drv/block/usbmast',
-	'drv/hid/adb-kbd',
-	'drv/hid/adb-mouse',
-	'drv/hid/usbhid',
-]
Index: uspace/lib/c/arch/riscv64/meson.build
===================================================================
--- uspace/lib/c/arch/riscv64/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/arch/riscv64/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -11,5 +11,2 @@
 
 arch_start_src = files('src/crt0.c')
-
-rd_essential += [
-]
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/c/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -211,5 +211,5 @@
 libstartfiles = static_library('startfiles', start_src,
 	include_directories: includes,
-	c_args: c_args,
+	c_args: arch_uspace_c_args + c_args,
 	install: CONFIG_DEVEL_FILES,
 	install_dir: 'lib',
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/lib/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -1,7 +1,3 @@
 always_static = (get_option('default_library') == 'static')
-
-# Redefined in libarch, if necessary.
-# Used in a few places where we generate custom assembly.
-as_prolog = ''
 
 # Which libraries are installed when CONFIG_DEVEL_FILES is enabled
@@ -173,6 +169,7 @@
 				include_directories: [ private_includes, includes ],
 				dependencies: _shared_deps,
-				c_args: c_args,
-				link_args: link_args,
+				c_args: arch_uspace_c_args + c_args,
+				cpp_args: arch_uspace_c_args + c_args,
+				link_args: arch_uspace_c_args + arch_uspace_link_args + link_args,
 				version: version,
 				build_by_default: true,
@@ -207,6 +204,6 @@
 			include_directories: [ private_includes, includes ],
 			dependencies: _include_deps,
-			c_args: c_args,
-			link_args: link_args,
+			c_args: arch_uspace_c_args + c_args,
+			cpp_args: arch_uspace_c_args + c_args,
 			install: install_static_lib,
 			install_dir: 'lib',
@@ -295,5 +292,7 @@
 		install: true,
 		install_dir: 'test',
-		link_args: _ldargs,
+		c_args: arch_uspace_c_args,
+		cpp_args: arch_uspace_c_args,
+		link_args: arch_uspace_c_args + arch_uspace_link_args + _ldargs,
 	)
 
Index: uspace/meson.build
===================================================================
--- uspace/meson.build	(revision 2c38a55b26e626af124660c860fe4f936f614b31)
+++ uspace/meson.build	(revision 63660a336967f7913b801317917bd93b4fb20796)
@@ -7,48 +7,8 @@
 install_debug_files = false
 
-rd_essential = []
-
 subdir('lib')
 subdir('app')
 subdir('srv')
 subdir('drv')
-
-init = [
-	'app/init',
-	'srv/bd/rd',
-	'srv/fs/' + RDFMT,
-	'srv/loader',
-	'srv/locsrv',
-	'srv/logger',
-	'srv/ns',
-	'srv/vfs',
-]
-
-rd_essential += init
-
-rd_essential += [
-	'app/bdsh',
-	'app/getterm',
-	'app/kio',
-
-	'srv/devman',
-	'srv/fs/locfs',
-	'srv/hid/input',
-	'srv/hid/output',
-	'srv/hid/compositor',
-	'srv/hid/console',
-	'srv/klog',
-
-	'drv/root/root',
-	'drv/root/virt',
-	'drv/fb/kfb',
-]
-
-if CONFIG_FB
-	rd_essential += [
-		'app/vlaunch',
-		'app/vterm',
-	]
-endif
 
 dirs = []
@@ -115,5 +75,5 @@
 
 	# Init binaries need to always be linked statically.
-	static_build = (not CONFIG_USE_SHARED_LIBS) or init.contains(dir)
+	static_build = (not CONFIG_USE_SHARED_LIBS) or rd_init.contains(dir)
 
 	# Add the corresponding standard libraries to dependencies.
@@ -202,6 +162,7 @@
 		dependencies: tst.get('dependencies'),
 		objects: startfiles,
-		c_args: tst.get('c_args'),
-		link_args: _ldargs,
+		c_args: arch_uspace_c_args + tst.get('c_args'),
+		cpp_args: arch_uspace_c_args + tst.get('c_args'),
+		link_args: arch_uspace_c_args + arch_uspace_link_args + _ldargs,
 		implicit_include_directories: false,
 		install: false,
