diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh
index d1e163fd68973032ccd1e9b3e4e7ed95bdf0dbab..3ebaa214879e248facf5b69ac75497b51580a5f5 100755
--- a/scripts/ext-toolchain.sh
+++ b/scripts/ext-toolchain.sh
@@ -356,6 +356,10 @@ print_config() {
 	echo "CONFIG_TOOLCHAIN_PREFIX=\"$prefix\"" >> "$config"
 	echo "CONFIG_TARGET_NAME=\"$target\"" >> "$config"
 
+	if [ "$LIBC_TYPE" != glibc ]; then
+		echo "CONFIG_TOOLCHAIN_LIBC=\"$LIBC_TYPE\"" >> "$config"
+	fi
+
 	local lib
 	for lib in C RT PTHREAD GCC STDCPP SSP GFORTRAN; do
 		local file
diff --git a/toolchain/Config.in b/toolchain/Config.in
index 32de4b16473aa494cf9102eb251e8a0ddf18d720..8677b87e7effffda266e8166086dbfea293580db 100644
--- a/toolchain/Config.in
+++ b/toolchain/Config.in
@@ -50,6 +50,17 @@ menuconfig EXTERNAL_TOOLCHAIN
 		default "/opt/cross/powerpc-unknown-linux-gnu"  if powerpc
 		default "/opt/cross/x86_64-unknown-linux-gnu"   if x86_64
 
+	config TOOLCHAIN_LIBC
+		string
+		prompt "Toolchain libc"  if DEVEL
+		depends EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+		default "uclibc"
+		help
+		  Specify the libc type used by the external toolchain. The given value us passed as -m
+		  flag to all gcc and g++ invocations. This is mainly intended for multilib toolchains
+		  which support glibc and uclibc at the same time. If no value is specified, no -m flag
+		  is passed.
+
 	config TOOLCHAIN_BIN_PATH
 		string
 		prompt "Toolchain program path"  if DEVEL
diff --git a/toolchain/wrapper/Makefile b/toolchain/wrapper/Makefile
index 417ed8cd3756178ef04b9c977f48c791a27b72d5..3398e407c9f2b2042ee55390caeba374e73d53e6 100644
--- a/toolchain/wrapper/Makefile
+++ b/toolchain/wrapper/Makefile
@@ -17,7 +17,7 @@ include $(INCLUDE_DIR)/toolchain-build.mk
 define toolchain_util
 $(strip $(SCRIPT_DIR)/ext-toolchain.sh --toolchain $(CONFIG_TOOLCHAIN_ROOT) \
 	--cflags $(CONFIG_TARGET_OPTIMIZATION) \
-	--cflags "-muclibc $(if $(CONFIG_SOFT_FLOAT),-msoft-float)" \
+	--cflags "$(if $(call qstrip,$(CONFIG_TOOLCHAIN_LIBC)),-m$(call qstrip,$(CONFIG_TOOLCHAIN_LIBC))) $(if $(CONFIG_SOFT_FLOAT),-msoft-float)" \
 	--cflags "$(patsubst ./%,-I$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))" \
 	--cflags "$(patsubst ./%,-L$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))" \
 	$(1))