Navigation Menu

Skip to content

Commit

Permalink
CONFIGURE: Deduplicate simple compiler flag support tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orgads authored and bluegr committed Jun 18, 2022
1 parent a3f83e0 commit 9e5ef28
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions configure
Expand Up @@ -191,9 +191,6 @@ _enable_prof=no
_enable_asan=no
_enable_tsan=no
_enable_ubsan=no
_global_constructors=no
_no_undefined_var_template=no
_no_pragma_pack=no
_bink=yes
_cloud=auto
_pandoc=no
Expand Down Expand Up @@ -2279,49 +2276,38 @@ if test "$_release_build" = yes; then
append_var DEFINES "-DRELEASE_BUILD"
fi

# If possible, we want to use -Wglobal-constructors
# However, not all compilers support that, so check whether the active one does.
echocheck "whether C++ compiler accepts -Wglobal-constructors"
cat > $TMPC << EOF
int main() { return 0; }
set_flag_if_supported() {
echocheck "whether C++ compiler accepts $1"
cat > $TMPC << EOF
int main() { return 0; }
EOF
cc_check -Wglobal-constructors -Werror && _global_constructors=yes
# Note: we check for -Wxxx instead of -Wno-xxx as not all compilers error
# out on unknown -Wno-xxx flags.
if cc_check $(echo $1 | sed 's/-Wno-/-W/') -Werror; then
append_var CXXFLAGS "$1"
echo yes
else
echo no
fi
}

if test "$_global_constructors" = yes; then
append_var CXXFLAGS "-Wglobal-constructors"
fi
echo $_global_constructors
set_flag_if_supported -Wglobal-constructors

# If the compiler supports the -Wundefined-var-template flag, silence that warning.
# We get this warning a lot with regard to the Singleton class as we explicitly
# instantiate each specialisation. An alternate way to deal with it would be to
# change the way we instantiate the singleton classes as done in PR #967.
# Note: we check the -Wundefined-var-template as gcc does not error out on unknown
# -Wno-xxx flags.
echocheck "whether C++ compiler accepts -Wno-undefined-var-template"
cat > $TMPC << EOF
int main() { return 0; }
EOF
cc_check -Wundefined-var-template -Werror && _no_undefined_var_template=yes

if test "$_no_undefined_var_template" = yes; then
append_var CXXFLAGS "-Wno-undefined-var-template"
fi
echo $_no_undefined_var_template
set_flag_if_supported -Wno-undefined-var-template

# Vanilla clang 6 enables the new -Wpragma-pack which warns when leaving an
# included file which changes the current alignment.
# As our common/pack-{start,end}.h trigger this we disable this warning.
# Because there is no correlation between the version reported by Apple Xcode
# clang and vanilla clang we cannot rely on the __clang_major__/clang_minor__
# macros.
# Note: as above, we check for -Wpragma-pack as not all compilers error out on
# unknown -Wno-xxx flags.
echocheck "whether C++ compiler accepts -Wno-pragma-pack"
echo "int main() { return 0; }" >$TMPC
cc_check -Wpragma-pack -Werror && _no_pragma_pack=yes
test "$_no_pragma_pack" = yes && append_var CXXFLAGS "-Wno-pragma-pack"
echo $_no_pragma_pack
set_flag_if_supported -Wno-pragma-pack

if test -n "$STRINGS"; then
_strings=$STRINGS
Expand Down

0 comments on commit 9e5ef28

Please sign in to comment.