diff --git a/init/Kconfig b/init/Kconfig
index 8f08f49a7c39..380798f86aae 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -81,6 +81,7 @@ config LOCALVERSION
 config LOCALVERSION_AUTO
 	bool "Automatically append version information to the version string"
 	default y
+	depends on !COMPILE_TEST
 	help
 	  This will try to automatically determine if the current tree is a
 	  release tree by looking for git tags that belong to the current