gdb_caching_proc shared_gnat_runtime_has_debug_info {} {
return [gnat_runtime_has_debug_info_1 1]
}
+
+# A helper that writes an Ada source file, then tries to compile it
+# with the given compiler options (a list like one accepted by
+# gdb_compile_ada). Returns 1 if the flags are supported, 0
+# otherwise.
+proc ada_simple_compile {name options} {
+ set src [standard_temp_file $name.adb]
+ set dest [standard_temp_file $name.x]
+ set f [open $src w]
+ puts $f "procedure $name is"
+ puts $f "begin"
+ puts $f " null;"
+ puts $f "end $name;"
+ close $f
+
+ # Note that we create an executable here. For -fvar-tracking, at
+ # least, the option is supported and ignored by llvm-gnatmake --
+ # but then is passed to clang during further compilation, and this
+ # fails. So to detect it we can't just stop with a .o file.
+ set output [gdb_compile_ada_1 $src $dest executable $options]
+ return [expr {[gdb_compile_test_nofail $output] == 1}]
+}
}
}
+# Examine the output of compilation to determine whether compilation
+# failed or not. If it failed determine whether it is due to missing
+# compiler or due to compiler error. Return 1 for pass, 0 for fail,
+# -1 for unsupported (missing compiler), and -2 for unsupported (bad
+# option) -- but do not issue a pass/fail directly.
+
+proc gdb_compile_test_nofail {output} {
+ if { $output == "" } {
+ return 1
+ }
+
+ if { [regexp {^[a-zA-Z_0-9]+: Can't find [^ ]+\.$} $output]
+ || [regexp {.*: command not found[\r|\n]*$} $output]
+ || [regexp {.*: [^\r\n]*compiler not installed[^\r\n]*[\r|\n]*$} $output] } {
+ return -1
+ }
+
+ set gcc_re ".*: error: unrecognized command line option "
+ set clang_re ".*: error: unsupported option "
+ if { [regexp "(?:$gcc_re|$clang_re)(\[^ \t;\r\n\]*)" $output dummy option]
+ && $option != "" } {
+ return -2
+ }
+
+ # Unclassified compilation failure, be more verbose.
+ verbose -log "compilation failed: $output" 2
+ return 0
+}
+
# Examine the output of compilation to determine whether compilation
# failed or not. If it failed determine whether it is due to missing
# compiler or due to compiler error. Report pass, fail or unsupported
proc gdb_compile_test {src output} {
set msg "compilation [file tail $src]"
- if { $output == "" } {
+ set result [gdb_compile_test_nofail $output]
+ if {$result == 1} {
pass $msg
return
}
- if { [regexp {^[a-zA-Z_0-9]+: Can't find [^ ]+\.$} $output]
- || [regexp {.*: command not found[\r|\n]*$} $output]
- || [regexp {.*: [^\r\n]*compiler not installed[^\r\n]*[\r|\n]*$} $output] } {
+ if {$result == -1} {
unsupported "$msg (missing compiler)"
return
}
- set gcc_re ".*: error: unrecognized command line option "
- set clang_re ".*: error: unsupported option "
- if { [regexp "(?:$gcc_re|$clang_re)(\[^ \t;\r\n\]*)" $output dummy option]
- && $option != "" } {
+ if {$result == -2} {
unsupported "$msg (unsupported option $option)"
return
}
- # Unclassified compilation failure, be more verbose.
- verbose -log "compilation failed: $output" 2
- fail "$msg"
+ fail $msg
}
# Return a 1 for configurations for which we want to try to test C++.