configure: Try adding -Werror=unknown-warning-option before testing for -Werror=partial-availability

Message ID 20170621193224.21510-1-martin@martin.st
State New
Headers show

Commit Message

Martin Storsjö June 21, 2017, 7:32 p.m.
Using check_cflags with -Werror parameters in clang is normally
futile, since the tests always pass, but add new warnings instead.

Since the check for -Werror=partial-availability is in the OS section
of configure, we need to try adding this option here as well, not
in the section adding other warning flags later.

This fixes warnings about -Werror=partial-availability being unknown
for each compile command, when building with Xcode 6.
---
Or should this be in an OS-independent step before the whole OS handling
block in configure, making sure that cflags checks work as intended for
clang, anywhere in the rest of configure?
---
 configure | 1 +
 1 file changed, 1 insertion(+)

Comments

Luca Barbato June 22, 2017, 8:39 a.m. | #1
On 6/21/17 9:32 PM, Martin Storsjö wrote:
> Using check_cflags with -Werror parameters in clang is normally
> futile, since the tests always pass, but add new warnings instead.
> 
> Since the check for -Werror=partial-availability is in the OS section
> of configure, we need to try adding this option here as well, not
> in the section adding other warning flags later.
> 
> This fixes warnings about -Werror=partial-availability being unknown
> for each compile command, when building with Xcode 6.
> ---
> Or should this be in an OS-independent step before the whole OS handling
> block in configure, making sure that cflags checks work as intended for
> clang, anywhere in the rest of configure?

Probably keeping it clang-global would be nicer.

I'm ok in having the patch as-is if you do not have time to test.

> ---
>  configure | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/configure b/configure
> index bbed2258b9..a4b602d8f2 100755
> --- a/configure
> +++ b/configure
> @@ -3972,6 +3972,7 @@ case $target_os in
>          SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
>          enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
>          add_ldflags -Wl,-dynamic,-search_paths_first
> +        enabled clang && check_cflags -Werror=unknown-warning-option
>          check_cflags -Werror=partial-availability
>          SLIBSUF=".dylib"
>          SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
>
Diego Biurrun June 24, 2017, 8:34 p.m. | #2
On Wed, Jun 21, 2017 at 10:32:24PM +0300, Martin Storsjö wrote:
> Using check_cflags with -Werror parameters in clang is normally
> futile, since the tests always pass, but add new warnings instead.
> 
> Since the check for -Werror=partial-availability is in the OS section
> of configure, we need to try adding this option here as well, not
> in the section adding other warning flags later.
> 
> This fixes warnings about -Werror=partial-availability being unknown
> for each compile command, when building with Xcode 6.
> ---
> Or should this be in an OS-independent step before the whole OS handling
> block in configure, making sure that cflags checks work as intended for
> clang, anywhere in the rest of configure?

Hmmmmmm.....

This touches upon an architectural shortcoming in configure. (Some of) the
toolchain checks are done after library checks and system checks. They
really shouldn't. All checks should be performed with the final toolchain
that will later be used during the actual compilation procedure.

So this seems like a bandaid necessary due to the architectural problem.
Maybe it's time to tackle the underlying problem instead. I've been meaning
to for a long time.

Diego

Patch

diff --git a/configure b/configure
index bbed2258b9..a4b602d8f2 100755
--- a/configure
+++ b/configure
@@ -3972,6 +3972,7 @@  case $target_os in
         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
         add_ldflags -Wl,-dynamic,-search_paths_first
+        enabled clang && check_cflags -Werror=unknown-warning-option
         check_cflags -Werror=partial-availability
         SLIBSUF=".dylib"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'