mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Use -isystem for LLVM include directories
LLVM's headers produce warnings under some of the warning options we might like to use. For example, -Wshadow=local reports several warnings from LLVM's headers when compiling llvmjit_inline.cpp. To work around that, add the include directories reported by llvm-config with -isystem rather than -I, which makes the compiler treat them as system headers and not report warnings from them. In meson, this is a built-in facility of the dependency() function, in configure we implement it ourselves. An alternative solution would have been to use "#pragma GCC system_header", as is already done elsewhere in the tree. But that seems less elegant here. Either, we would have to potentially create a separate wrapper for each LLVM header, or we would have to route all LLVM includes through a common header, which would break modularity. Reviewed-by: Peter Geoghegan <pg@bowt.ie> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/84b6f128-91f5-480e-8a9e-7d0e8f538cea%40eisentraut.org
This commit is contained in:
@@ -46,10 +46,13 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
|
|||||||
# clear what the minimum version is.
|
# clear what the minimum version is.
|
||||||
|
|
||||||
# Collect compiler flags necessary to build the LLVM dependent
|
# 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
|
for pgac_option in `$LLVM_CONFIG --cppflags`; do
|
||||||
case $pgac_option in
|
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
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
7
configure
vendored
7
configure
vendored
@@ -5105,10 +5105,13 @@ fi
|
|||||||
# clear what the minimum version is.
|
# clear what the minimum version is.
|
||||||
|
|
||||||
# Collect compiler flags necessary to build the LLVM dependent
|
# 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
|
for pgac_option in `$LLVM_CONFIG --cppflags`; do
|
||||||
case $pgac_option in
|
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
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -924,7 +924,10 @@ endif
|
|||||||
llvmopt = get_option('llvm')
|
llvmopt = get_option('llvm')
|
||||||
llvm = not_found_dep
|
llvm = not_found_dep
|
||||||
if have_cxx
|
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()
|
if llvm.found()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user