diff --git a/config/llvm.m4 b/config/llvm.m4 index 5d4f14cb900..496fd8f72a4 100644 --- a/config/llvm.m4 +++ b/config/llvm.m4 @@ -46,10 +46,13 @@ AC_DEFUN([PGAC_LLVM_SUPPORT], # clear what the minimum version is. # Collect compiler flags necessary to build the LLVM dependent - # shared library. + # shared library. The include directories are added with -isystem + # rather than -I, so that warnings from LLVM's own headers are not + # reported under the warning options we select for our own code. for pgac_option in `$LLVM_CONFIG --cppflags`; do case $pgac_option in - -I*|-D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";; + -I*) LLVM_CPPFLAGS="-isystem ${pgac_option#-I} $LLVM_CPPFLAGS";; + -D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";; esac done diff --git a/configure b/configure index d42a7a794ff..002e31bf695 100755 --- a/configure +++ b/configure @@ -5105,10 +5105,13 @@ fi # clear what the minimum version is. # Collect compiler flags necessary to build the LLVM dependent - # shared library. + # shared library. The include directories are added with -isystem + # rather than -I, so that warnings from LLVM's own headers are not + # reported under the warning options we select for our own code. for pgac_option in `$LLVM_CONFIG --cppflags`; do case $pgac_option in - -I*|-D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";; + -I*) LLVM_CPPFLAGS="-isystem ${pgac_option#-I} $LLVM_CPPFLAGS";; + -D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";; esac done diff --git a/meson.build b/meson.build index f4cde249242..52d6bc37dd9 100644 --- a/meson.build +++ b/meson.build @@ -924,7 +924,10 @@ endif llvmopt = get_option('llvm') llvm = not_found_dep if have_cxx - llvm = dependency('llvm', version: '>=14', method: 'config-tool', required: llvmopt) + # Use include_type 'system' so that warnings from LLVM's own headers are + # not reported under the warning options we select for our own code. + llvm = dependency('llvm', version: '>=14', method: 'config-tool', + include_type: 'system', required: llvmopt) if llvm.found()