diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 8f6df5ba7b6..6203bcf606f 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1912,8 +1912,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
 	$(patsubst %.c,%.o,$(COMMON_SFILES)) \
 	$(SUBDIR_CLI_OBS) \
 	$(SUBDIR_MI_OBS) \
-	$(SUBDIR_TARGET_OBS) \
-	$(SUBDIR_GCC_COMPILE_OBS)
+	$(SUBDIR_TARGET_OBS)
 
 SUBDIRS = doc @subdirs@ data-directory
 CLEANDIRS = $(SUBDIRS)
diff --git a/gdb/NEWS b/gdb/NEWS
index 2fdb849a81b..40b0bcf7248 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -108,6 +108,10 @@ qXfer:threads:read
 * Support for stabs debugging format and the a.out/dbx object format is
   deprecated, and will be removed in GDB 18.
 
+* A new configure option was added, allowing support for the compile
+  subsystem to be disabled at configure time, in the form of
+  --disable-gdb-compile.
+
 *** Changes in GDB 16
 
 * Support for Nios II targets has been removed as this architecture
diff --git a/gdb/README b/gdb/README
index b6eb3f12c56..8836120d7ca 100644
--- a/gdb/README
+++ b/gdb/README
@@ -442,6 +442,9 @@ more obscure GDB `configure' options are not listed here.
      Requires a curses library (ncurses and cursesX are also
      supported).
 
+`--disable-gdb-compile'
+    Build GDB without support for the 'compile' command.
+
 `--with-curses'
      Use the curses library instead of the termcap library, for
      text-mode terminal operations.
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 5decf3b9d5c..c14480f84ed 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -660,9 +660,13 @@ execute_control_command_1 (struct command_line *cmd, int from_tty)
       }
 
     case compile_control:
+#if defined(HAVE_COMPILE)
       eval_compile_command (cmd, NULL, cmd->control_u.compile.scope,
 			    cmd->control_u.compile.scope_data);
       ret = simple_control;
+#else
+      error (_("compile support has not been compiled into gdb"));
+#endif
       break;
 
     case define_control:
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 43987f9b2b7..01f43ad103d 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -46,16 +46,17 @@
 #include "gdbsupport/scoped_ignore_signal.h"
 #include "gdbsupport/buildargv.h"
 
+/* Hold "compile" commands.  */
+
+static struct cmd_list_element *compile_command_list;
+
 
+#ifdef HAVE_COMPILE
 
 /* Initial filename for temporary files.  */
 
 #define TMP_PREFIX "/tmp/gdbobj-"
 
-/* Hold "compile" commands.  */
-
-static struct cmd_list_element *compile_command_list;
-
 /* Debug flag for "compile" commands.  */
 
 bool compile_debug;
@@ -852,6 +853,18 @@ compile_instance::compile (const char *filename, int verbose_level)
 
 #undef FORWARD
 
+#else /* HAVE_COMPILE */
+
+/* The "compile" prefix command, when support was disabled.  */
+
+static void
+compile_command (const char *args, int from_tty)
+{
+  error (_("This command is not supported."));
+}
+
+#endif /* HAVE_COMPILE */
+
 /* See compile.h.  */
 cmd_list_element *compile_cmd_element = nullptr;
 
@@ -859,14 +872,25 @@ void _initialize_compile ();
 void
 _initialize_compile ()
 {
-  struct cmd_list_element *c = NULL;
-
   compile_cmd_element = add_prefix_cmd ("compile", class_obscure,
-					compile_command, _("\
+					compile_command,
+#ifdef HAVE_COMPILE
+					_("\
 Command to compile source code and inject it into the inferior."),
+#else /* HAVE_COMPILE */
+					_("\
+Command to compile source code and inject it into the inferior.\n\
+\n\
+Code compilation and injection is not supported in this copy of GDB.\n\
+This command is only a placeholder."),
+#endif /* HAVE_COMPILE */
 		  &compile_command_list, 1, &cmdlist);
   add_com_alias ("expression", compile_cmd_element, class_obscure, 0);
 
+#ifdef HAVE_COMPILE
+
+  struct cmd_list_element *c = NULL;
+
   const auto compile_opts = make_compile_options_def_group (nullptr);
 
   static const std::string compile_code_help
@@ -973,4 +997,5 @@ It should be absolute filename of the gcc executable.\n\
 If empty the default target triplet will be searched in $PATH."),
 				     NULL, show_compile_gcc, &setlist,
 				     &showlist);
+#endif /* HAVE_COMPILE */
 }
diff --git a/gdb/config.in b/gdb/config.in
index db63aeaec75..86ff67d2898 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -104,6 +104,9 @@
    the CoreFoundation framework. */
 #undef HAVE_CFPREFERENCESCOPYAPPVALUE
 
+/* Define if compiling support to gdb compile. */
+#undef HAVE_COMPILE
+
 /* Define to 1 if you have the <cursesX.h> header file. */
 #undef HAVE_CURSESX_H
 
diff --git a/gdb/configure b/gdb/configure
index 3080413fdc9..e8a649f2ef0 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -956,6 +956,7 @@ with_libexpat_type
 with_python
 with_python_libdir
 with_guile
+enable_gdb_compile
 enable_source_highlight
 with_sysroot
 with_system_gdbinit
@@ -1650,6 +1651,8 @@ Optional Features:
   --enable-gdbtk          enable gdbtk graphical user interface (GUI)
   --enable-profiling      enable profiling of GDB
   --enable-codesign=CERT  sign gdb with 'codesign -s CERT'
+  --enable-gdb-compile    enable support for the compile subsystem, default
+                          'yes'
   --enable-source-highlight
                           enable source-highlight for source listings
   --enable-werror         treat compile warnings as errors
@@ -11500,7 +11503,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11503 "configure"
+#line 11506 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11606,7 +11609,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11609 "configure"
+#line 11612 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -28968,6 +28971,38 @@ else
 fi
 
 
+# ---------------------------- #
+# Check for compile support.   #
+# ---------------------------- #
+
+# Check whether --enable-gdb-compile was given.
+if test "${enable_gdb_compile+set}" = set; then :
+  enableval=$enable_gdb_compile;
+	   case $enableval in
+	     yes | no)
+	       ;;
+	     *)
+	       as_fn_error $? "bad value $enableval for --enable-gdb-compile" "$LINENO" 5
+	       ;;
+	   esac
+
+else
+  enable_gdb_compile=yes
+fi
+
+
+if test "${enable_gdb_compile}" == yes; then
+
+$as_echo "#define HAVE_COMPILE 1" >>confdefs.h
+
+    CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_GCC_COMPILE_OBS)"
+else
+    # Even if compile support is not enabled, we need this file to define
+    # the "compile" command.
+    CONFIG_OBS="$CONFIG_OBS compile/compile.o"
+    CONFIG_SRCS="$CONFIG_SRCS compile/compile.c"
+fi
+
 # ---------------------------- #
 # Check for source highlight.  #
 # ---------------------------- #
diff --git a/gdb/configure.ac b/gdb/configure.ac
index eafbf5ac358..2411b10ca40 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1221,6 +1221,26 @@ AC_SUBST(GUILE_CPPFLAGS)
 AC_SUBST(GUILE_LIBS)
 AM_CONDITIONAL(HAVE_GUILE, test "${have_libguile}" != no)
 
+# ---------------------------- #
+# Check for compile support.   #
+# ---------------------------- #
+
+AC_ARG_ENABLE([gdb-compile],
+    AS_HELP_STRING([--enable-gdb-compile],
+	      [enable support for the compile subsystem, default 'yes']),
+	      [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdb-compile])],
+	      [enable_gdb_compile=yes])
+
+if test "${enable_gdb_compile}" == yes; then
+    AC_DEFINE(HAVE_COMPILE, 1, [Define if compiling support to gdb compile.])
+    CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_GCC_COMPILE_OBS)"
+else
+    # Even if compile support is not enabled, we need this file to define
+    # the "compile" command.
+    CONFIG_OBS="$CONFIG_OBS compile/compile.o"
+    CONFIG_SRCS="$CONFIG_SRCS compile/compile.c"
+fi
+
 # ---------------------------- #
 # Check for source highlight.  #
 # ---------------------------- #
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 7c12c0d4d4d..8f666945122 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1784,6 +1784,7 @@ dwarf2_compile_property_to_c (string_file *stream,
 			      CORE_ADDR pc,
 			      struct symbol *sym)
 {
+#if defined (HAVE_COMPILE)
   const dwarf2_property_baton *baton = prop->baton ();
   const gdb_byte *data;
   size_t size;
@@ -1810,6 +1811,9 @@ dwarf2_compile_property_to_c (string_file *stream,
 			     gdbarch, registers_used,
 			     per_cu->addr_size (),
 			     data, data + size, per_cu, per_objfile);
+#else
+  gdb_assert_not_reached ("Compile support was disabled");
+#endif
 }
 
 /* Compute the correct symbol_needs_kind value for the location
@@ -3852,6 +3856,7 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream,
 			     std::vector<bool> &registers_used,
 			     CORE_ADDR pc, const char *result_name)
 {
+#if defined (HAVE_COMPILE)
   struct dwarf2_locexpr_baton *dlbaton
     = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (sym);
   unsigned int addr_size = dlbaton->per_cu->addr_size ();
@@ -3863,6 +3868,9 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream,
 			   sym, pc, gdbarch, registers_used, addr_size,
 			   dlbaton->data, dlbaton->data + dlbaton->size,
 			   dlbaton->per_cu, dlbaton->per_objfile);
+#else
+  gdb_assert_not_reached ("Compile support was disabled");
+#endif
 }
 
 /* The set of location functions used with the DWARF-2 expression
@@ -4088,6 +4096,7 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream,
 			     std::vector<bool> &registers_used,
 			     CORE_ADDR pc, const char *result_name)
 {
+#if defined (HAVE_COMPILE)
   struct dwarf2_loclist_baton *dlbaton
     = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (sym);
   unsigned int addr_size = dlbaton->per_cu->addr_size ();
@@ -4103,6 +4112,9 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream,
 			   data, data + size,
 			   dlbaton->per_cu,
 			   dlbaton->per_objfile);
+#else
+  gdb_assert_not_reached ("Compile support was disabled");
+#endif
 }
 
 /* The set of location functions used with the DWARF-2 expression
diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp
index 03ead592f0b..a1dd9746c20 100644
--- a/gdb/testsuite/gdb.base/filename-completion.exp
+++ b/gdb/testsuite/gdb.base/filename-completion.exp
@@ -381,11 +381,15 @@ proc run_mid_line_completion_tests { root cmd } {
 proc run_quoting_and_escaping_tests { root } {
     # Test all the commands which allow quoting of filenames, and
     # which require whitespace to be escaped in unquoted filenames.
-    foreach_with_prefix cmd { file exec-file symbol-file add-symbol-file \
-				  remove-symbol-file \
-				  "target core" "target exec" "target tfile" \
-				  "maint print c-tdesc" "compile file" \
-				  "save gdb-index" "save gdb-index -dwarf-5" } {
+    set all_cmds { file exec-file symbol-file add-symbol-file \
+		      remove-symbol-file \
+		      "target core" "target exec" "target tfile" \
+		      "maint print c-tdesc" "save gdb-index"
+		      "save gdb-index -dwarf-5" }
+    if { [allow_compile_tests] } {
+	lappend all_cmds "compile file"
+    }
+    foreach_with_prefix cmd $all_cmds {
 	# Try each test placing the filename as the first argument
 	# then again with a quoted string immediately after the
 	# command.  This works because the filename completer will
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp b/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp
index 3e76d38dc10..ddad6281ebf 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp b/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp
index 505a4e12eb3..c7d15ce0913 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++ additional_flags=-std=c++11}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp b/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp
index 1a5f60a75dc..9ef1e832f3d 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-member.exp b/gdb/testsuite/gdb.compile/compile-cplus-member.exp
index 5ffbb30df82..ac9111c83e4 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-member.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-member.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-method.exp b/gdb/testsuite/gdb.compile/compile-cplus-method.exp
index 0a0e0fa18a3..bcbfbb05e4b 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-method.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-method.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp b/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp
index 3ab8ece4bf1..2abc3663d1c 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-nested.exp b/gdb/testsuite/gdb.compile/compile-cplus-nested.exp
index 19efd4f7506..247d270a231 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-nested.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-nested.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-print.exp b/gdb/testsuite/gdb.compile/compile-cplus-print.exp
index 594f94a6ac9..e4413f01d0e 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-print.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-print.exp
@@ -19,6 +19,8 @@ standard_testfile
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 set options {}
 if [test_compiler_info gcc*] {
     lappend options additional_flags=-g3
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp b/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp
index 8761df56db5..a7702084133 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp
@@ -23,6 +23,8 @@ require allow_cplus_tests
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[prepare_for_testing $testfile $testfile $srcfile \
 	 {debug nowarnings c++}]} {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp
index 711f299574d..35ae692acc7 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus.exp
@@ -19,6 +19,8 @@ standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 set options {}
 if { [test_compiler_info gcc*] || [test_compiler_info clang*] } {
     lappend options additional_flags=-g3
diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gdb.compile/compile-ifunc.exp
index b004bd7bb61..e490890c5d6 100644
--- a/gdb/testsuite/gdb.compile/compile-ifunc.exp
+++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp
@@ -17,6 +17,8 @@ load_lib compile-support.exp
 
 require allow_ifunc_tests
 
+require allow_compile_tests
+
 standard_testfile
 
 require is_c_compiler_gcc
diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.compile/compile-ops.exp
index f75e02cedf3..cfbe2b0356c 100644
--- a/gdb/testsuite/gdb.compile/compile-ops.exp
+++ b/gdb/testsuite/gdb.compile/compile-ops.exp
@@ -22,6 +22,8 @@ load_lib dwarf.exp
 # This test can only be run on targets which support DWARF-2 and use gas.
 require dwarf2_support
 
+require allow_compile_tests
+
 require is_c_compiler_gcc
 
 standard_testfile .c -dbg.S
diff --git a/gdb/testsuite/gdb.compile/compile-print.exp b/gdb/testsuite/gdb.compile/compile-print.exp
index f8f22973e3e..61ce7501df7 100644
--- a/gdb/testsuite/gdb.compile/compile-print.exp
+++ b/gdb/testsuite/gdb.compile/compile-print.exp
@@ -19,6 +19,8 @@ standard_testfile
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if { [prepare_for_testing "failed to prepare" "$testfile"] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.compile/compile-setjmp.exp b/gdb/testsuite/gdb.compile/compile-setjmp.exp
index f387a054ea9..ad8732b773d 100644
--- a/gdb/testsuite/gdb.compile/compile-setjmp.exp
+++ b/gdb/testsuite/gdb.compile/compile-setjmp.exp
@@ -19,6 +19,8 @@ standard_testfile .c compile-setjmp-mod.c
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if { [prepare_for_testing "failed to prepare" $testfile] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.compile/compile-tls.exp b/gdb/testsuite/gdb.compile/compile-tls.exp
index 2f8dc5ade2c..45e290e808e 100644
--- a/gdb/testsuite/gdb.compile/compile-tls.exp
+++ b/gdb/testsuite/gdb.compile/compile-tls.exp
@@ -19,6 +19,8 @@ standard_testfile .c
 
 require is_c_compiler_gcc
 
+require allow_compile_tests
+
 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 	 executable {debug}] != "" } {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index 2c2e3217b19..5128dc62444 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -15,6 +15,8 @@
 
 load_lib compile-support.exp
 
+require allow_compile_tests
+
 standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c
 
 require is_c_compiler_gcc
diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/compile-support.exp
index aa8aaf3b7e3..6d7a4ce13ef 100644
--- a/gdb/testsuite/lib/compile-support.exp
+++ b/gdb/testsuite/lib/compile-support.exp
@@ -45,6 +45,9 @@ proc _do_check_compile {expr} {
 	    # This appears to be a bug in the compiler plugin.
 	    set result "apparent compiler plugin bug"
 	}
+	-re "This command is not supported." {
+	    set result "compiler disabled at configure time"
+	}
 	-re "\r\n$gdb_prompt $" {
 	}
     }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3349da7a263..8486ff05e57 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2799,6 +2799,12 @@ gdb_caching_proc allow_python_tests {} {
     return [expr {[string first "--with-python" $output] != -1}]
 }
 
+# Return a 1 if GDB was configured to support compile commands.
+gdb_caching_proc allow_compile_tests {} {
+    set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS -ex \"compile int x = 1\" -batch"]
+    return [expr {[string first "The program must be running" $output] != -1}]
+}
+
 # Return a 1 for configurations that use system readline rather than the
 # in-repo copy.
 
