diff --git a/src/common/file_utils.c b/src/common/file_utils.c
index 7584c1f2fb..a2faafdf13 100644
--- a/src/common/file_utils.c
+++ b/src/common/file_utils.c
@@ -12,6 +12,11 @@
  *
  *-------------------------------------------------------------------------
  */
+
+#ifndef FRONTEND
+#error "This file is not expected to be compiled for backend code"
+#endif
+
 #include "postgres_fe.h"
 
 #include <dirent.h>
diff --git a/src/common/logging.c b/src/common/logging.c
index f3fc0b8262..6a3a437a34 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -7,6 +7,11 @@
  *
  *-------------------------------------------------------------------------
  */
+
+#ifndef FRONTEND
+#error "This file is not expected to be compiled for backend code"
+#endif
+
 #include "postgres_fe.h"
 
 #include <unistd.h>
