diff --git a/gcc/testsuite/lib/gfortran.exp b/gcc/testsuite/lib/gfortran.exp
index 43f4d4eda17..50c095cddd2 100644
--- a/gcc/testsuite/lib/gfortran.exp
+++ b/gcc/testsuite/lib/gfortran.exp
@@ -236,6 +236,7 @@ proc gfortran_init { args } {
 #
 
 proc gfortran_target_compile { source dest type options } {
+    global srcdir
     global tmpdir
     global gluefile wrap_flags
     global ALWAYS_GFORTRANFLAGS
@@ -269,6 +270,7 @@ proc gfortran_target_compile { source dest type options } {
     lappend options "compiler=$GFORTRAN_UNDER_TEST"
     lappend options "timeout=[timeout_value]"
 
+    set options [concat "{additional_flags=-I$srcdir/../../libquadmath}" $options]
     set options [concat "$ALWAYS_GFORTRANFLAGS" $options]
     set options [dg-additional-files-options $options $source]
     set return_val [target_compile $source $dest $type $options]
