# Build program with address signing forced on.
standard_testfile
set compile_flags {debug}
-lappend compile_flags "additional_flags=-msign-return-address=all"
lappend compile_flags "additional_flags=-fno-inline"
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${compile_flags}] } {
+
+# Records whether the compilation was successful or not.
+set compilation_ok 0
+
+# We need to try a couple compilation flags here because -msign-return-address
+# was dropped at some point, but could still be supported.
+foreach pauth_flag "-mbranch-protection=pac-ret+leaf -msign-return-address=all" {
+ set flags $compile_flags
+ lappend flags "additional_flags=$pauth_flag"
+
+ if {!$compilation_ok && ![prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${flags}] } {
+ set compilation_ok 1
+ }
+}
+
+# If we couldn't compile, just bail out.
+if {!$compilation_ok} {
return -1
}