Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 2660ee33905b12512a15891b19f47af71a4770f1)
+++ uspace/Makefile.common	(revision fec0240ef06fc1a62210bc1e0e106291c3ed64fb)
@@ -205,9 +205,11 @@
 
 # Flags that should always be used, even for third-party software.
+COMMON_CPPFLAGS = \
+	-nostdinc \
+	-D__$(ENDIANESS)__
+
 COMMON_CFLAGS = \
 	-ffreestanding \
-	-nostdlib \
-	-nostdinc \
-	-D__$(ENDIANESS)__
+	-nostdlib
 
 # Flags that are always used for HelenOS code, but not for third-party.
@@ -224,5 +226,5 @@
 # TODO: Use a different name.
 # CFLAGS variable is traditionally used for overridable flags.
-CFLAGS = $(COMMON_CFLAGS) $(HELENOS_CFLAGS) $(DEFAULT_CFLAGS)
+CFLAGS = $(COMMON_CPPFLAGS) $(COMMON_CFLAGS) $(HELENOS_CFLAGS) $(DEFAULT_CFLAGS)
 
 ## Setup platform configuration
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision 2660ee33905b12512a15891b19f47af71a4770f1)
+++ uspace/lib/posix/Makefile	(revision fec0240ef06fc1a62210bc1e0e106291c3ed64fb)
@@ -103,10 +103,11 @@
 EXPORT_LDFLAGS = \
 	-L$$(HELENOS_EXPORT_ROOT)/lib \
-	--whole-archive -lc -lmath --no-whole-archive \
 	-T link.ld
 
+EXPORT_LDLIBS = \
+	-lmath -lc
+
 EXPORT_CFLAGS = \
-	$(EXPORT_CPPFLAGS) \
-	$(addprefix -Xlinker , $(EXPORT_LDFLAGS))
+	-specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs
 
 include $(USPACE_PREFIX)/Makefile.common
@@ -116,7 +117,9 @@
 	echo '+ $(COMMON_CFLAGS)' >> $@.new
 	echo >> $@.new
+	echo '*cpp:' >> $@.new
+	echo '+ $(COMMON_CPPFLAGS)' >> $@.new
+	echo >> $@.new
 	echo '*lib:' >> $@.new
-	echo '--whole-archive -lc -lmath --no-whole-archive' >> $@.new
-	echo >> $@.new
+	echo '$(EXPORT_LDLIBS)' >> $@.new
 	mv $@.new $@
 
@@ -137,8 +140,11 @@
 	echo '# Do not forget to set HELENOS_EXPORT_ROOT.' >> $@.new
 	echo 'HELENOS_CROSS_PATH="$(shell dirname $(CC))"' >> $@.new
+	echo 'HELENOS_ARCH="$(firstword $(subst -, ,$(TARGET)))"' >> $@.new
 	echo 'HELENOS_TARGET="$(TARGET)"' >> $@.new
 	echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
 	echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
+	echo 'HELENOS_CXXFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
 	echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
+	echo 'HELENOS_LDLIBS="$(EXPORT_LDLIBS)"' >> $@.new
 	mv $@.new $@
 
