diff --git a/Documentation/kbuild/kconfig-macro-language.rst b/Documentation/kbuild/kconfig-macro-language.rst
index 6163467f6ae4..8eca2c5f1a00 100644
--- a/Documentation/kbuild/kconfig-macro-language.rst
+++ b/Documentation/kbuild/kconfig-macro-language.rst
@@ -120,8 +120,7 @@ Kconfig currently supports the following built-in functions.
  - $(warning-if,condition,text)
 
   The "warning-if" function takes two arguments. If the condition part is "y",
-  the text part is sent to stderr. The text is prefixed with the name of the
-  current Kconfig file and the current line number.
+  the text part is sent to stderr.
 
  - $(error-if,condition,text)
 
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index a5fe72c504ff..de8dcffc60c1 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -11,6 +11,10 @@ dollar      := $
 right_paren := )
 left_paren  := (
 
+# works like 'error-if', but prefix the file name and the line number to
+# the message.
+error-loc-if = $(error-if,$(1),$(filename):$(lineno): $(2))
+
 # $(if-success,<command>,<then>,<else>)
 # Return <then> if <command> exits with 0, <else> otherwise.
 if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
@@ -36,11 +40,11 @@ ld-option = $(success,$(LD) -v $(1))
 as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -)
 
 # check if $(CC) and $(LD) exist
-$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
-$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
+$(error-loc-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
+$(error-loc-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
 
 # Fail if the linker is gold as it's not capable of linking the kernel proper
-$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
+$(error-loc-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
 
 # machine bit flags
 #  $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 0590f86df6e4..974929b0918b 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -111,8 +111,10 @@ struct function {
 
 static char *do_error_if(int argc, char *argv[])
 {
-	if (!strcmp(argv[0], "y"))
-		pperror("%s", argv[1]);
+	if (!strcmp(argv[0], "y")) {
+		fprintf(stderr, "%s\n", argv[1]);
+		exit(1);
+	}
 
 	return xstrdup("");
 }
@@ -181,8 +183,7 @@ static char *do_shell(int argc, char *argv[])
 static char *do_warning_if(int argc, char *argv[])
 {
 	if (!strcmp(argv[0], "y"))
-		fprintf(stderr, "%s:%d: %s\n",
-			current_file->name, yylineno, argv[1]);
+		fprintf(stderr, "%s\n", argv[1]);
 
 	return xstrdup("");
 }
diff --git a/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr b/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr
index 33ea9ca38400..112d94043b41 100644
--- a/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr
+++ b/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr
@@ -1,5 +1,5 @@
-Kconfig:8: hello world 1
-Kconfig:18: hello world 3
-Kconfig:22: hello world  4
-Kconfig:26: filename=Kconfig
-Kconfig:27: lineno=27
+hello world 1
+hello world 3
+hello world  4
+filename=Kconfig
+lineno=27
diff --git a/scripts/kconfig/tests/preprocess/escape/expected_stderr b/scripts/kconfig/tests/preprocess/escape/expected_stderr
index 1c00957ddaa9..1768112277b2 100644
--- a/scripts/kconfig/tests/preprocess/escape/expected_stderr
+++ b/scripts/kconfig/tests/preprocess/escape/expected_stderr
@@ -1,10 +1,10 @@
-Kconfig:9: hello, world
-Kconfig:13:   ' " '"   ' ''' "'"
-Kconfig:17: $
-Kconfig:18: $$
-Kconfig:20: 1
-Kconfig:25: $(X)
-Kconfig:30: (
-Kconfig:35: $(X)
-Kconfig:39: $(X)
-Kconfig:44: $(
+hello, world
+  ' " '"   ' ''' "'"
+$
+$$
+1
+$(X)
+(
+$(X)
+$(X)
+$(
diff --git a/scripts/kconfig/tests/preprocess/variable/expected_stderr b/scripts/kconfig/tests/preprocess/variable/expected_stderr
index a4841c3fdff5..5903a7732008 100644
--- a/scripts/kconfig/tests/preprocess/variable/expected_stderr
+++ b/scripts/kconfig/tests/preprocess/variable/expected_stderr
@@ -1,9 +1,9 @@
-Kconfig:10: SIMPLE = 1
-Kconfig:16: RECURSIVE = 2
-Kconfig:22: SIMPLE = 1 3
-Kconfig:28: RECURSIVE = 2 4
-Kconfig:35: UNDEFINED_VARIABLE = 4
-Kconfig:41: AB = 5
-Kconfig:45: Hello, my name is John.
-Kconfig:50: Hello, my name is .
-Kconfig:53: Hello, my name is John.
+SIMPLE = 1
+RECURSIVE = 2
+SIMPLE = 1 3
+RECURSIVE = 2 4
+UNDEFINED_VARIABLE = 4
+AB = 5
+Hello, my name is John.
+Hello, my name is .
+Hello, my name is John.
