diff mbox

[FFmpeg-devel] configure: Check build with some header not just preprocessing for testing --std=c11

Message ID 20161228224129.2827-1-michael@niedermayer.cc
State Accepted
Headers show

Commit Message

Michael Niedermayer Dec. 28, 2016, 10:41 p.m. UTC
Fixes build failure on FreeBSD with gcc 4.7

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 configure | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

James Almer Dec. 29, 2016, 3:12 a.m. UTC | #1
On 12/28/2016 7:41 PM, Michael Niedermayer wrote:
> Fixes build failure on FreeBSD with gcc 4.7

Does this also fix ticket #6049? If so, please mention it.

> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  configure | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/configure b/configure
> index d723b8e2a6..706346abc9 100755
> --- a/configure
> +++ b/configure
> @@ -1201,13 +1201,14 @@ check_cpp_condition(){
>  EOF
>  }
>  
> -test_cflags_cpp(){
> -    log test_cflags_cpp "$@"
> +test_cflags_cc(){
> +    log test_cflags_cc "$@"
>      flags=$1
>      condition=$2
>      shift 2
>      set -- $($cflags_filter "$flags")
> -    check_cpp "$@" <<EOF
> +    check_cc "$@" <<EOF
> +#include <ctype.h>
>  #if !($condition)
>  #error "unsatisfied condition: $condition"
>  #endif
> @@ -4625,7 +4626,7 @@ add_cxxflags -std=c++98
>  
>  # some compilers silently accept -std=c11, so we also need to check that the
>  # version macro is defined properly
> -if test_cflags_cpp -std=c11 "__STDC_VERSION__ >= 201112L"; then
> +if test_cflags_cc -std=c11 "__STDC_VERSION__ >= 201112L"; then
>      add_cflags -std=c11
>  else
>      check_cflags -std=c99
>
Michael Niedermayer Dec. 29, 2016, 10:06 a.m. UTC | #2
On Thu, Dec 29, 2016 at 12:12:13AM -0300, James Almer wrote:
> On 12/28/2016 7:41 PM, Michael Niedermayer wrote:
> > Fixes build failure on FreeBSD with gcc 4.7
> 
> Does this also fix ticket #6049? If so, please mention it.

I dont have ICC, so i dont know

[...]
Moritz Barsnick Dec. 30, 2016, 1:15 a.m. UTC | #3
On Thu, Dec 29, 2016 at 11:06:12 +0100, Michael Niedermayer wrote:
> On Thu, Dec 29, 2016 at 12:12:13AM -0300, James Almer wrote:
> > On 12/28/2016 7:41 PM, Michael Niedermayer wrote:
> > > Fixes build failure on FreeBSD with gcc 4.7
> > 
> > Does this also fix ticket #6049? If so, please mention it.
> 
> I dont have ICC, so i dont know

I checked, it does not fix that.

ICC fails the C11 test (fine, as it should, I believe):

--snip--
test_cflags_cc -std=c11 __STDC_VERSION__ >= 201112L
check_cc -std=c11
BEGIN /tmp/ffconf.6i1t5Drn.c
    1   #include <ctype.h>
    2   #if !(__STDC_VERSION__ >= 201112L)
    3   #error "unsatisfied condition: __STDC_VERSION__ >= 201112L"
    4   #endif
END /tmp/ffconf.6i1t5Drn.c
icc -D_ISOC99_SOURCE -std=c11 -c -o /tmp/ffconf.YqpQplj6.o /tmp/ffconf.6i1t5Drn.c
/tmp/ffconf.6i1t5Drn.c(3): catastrophic error: #error directive: "unsatisfied condition: __STDC_VERSION__ >= 201112L"
  #error "unsatisfied condition: __STDC_VERSION__ >= 201112L"
   ^

compilation aborted for /tmp/ffconf.6i1t5Drn.c (code 4)
--snip--

but still passes the builtin-stdatomic test:

--snip--
check_builtin stdatomic_h stdatomic.h atomic_int foo; atomic_store(&foo, 0)
check_code ld stdatomic.h atomic_int foo; atomic_store(&foo, 0) cc
check_ld cc
check_cc
BEGIN /tmp/ffconf.6i1t5Drn.c
    1   #include <stdatomic.h>
    2   int main(void) { atomic_int foo; atomic_store(&foo, 0); return 0; }
END /tmp/ffconf.6i1t5Drn.c
icc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -std=c99 -fomit-frame-pointer -c -o /tmp/ffconf.YqpQplj6.o /tmp/ffconf.6i1t5Drn.c
icc -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.VfzybuCl /tmp/ffconf.YqpQplj6.o -lrt
--snip--

which causes the macro still not to be defined:

--snip--
icc -I. -I./ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DOPJ_STATIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -std=c99 -fomit-frame-pointer -pthread  -I/usr/include/fribidi -I/usr/include/freetype2  -I/usr/include/freetype2 -I/usr/kerberos/include  -I/usr/include/tesseract -I/usr/include/leptonica       -I/usr/new/tools/video/install/x264/20160703/include  -D_REENTRANT -I/usr/include/SDL2  -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -O3 -fno-math-errno -fno-signed-zeros -w1 -wd144,167,188,556,1292,1419,10006,10148,10156,13200,13203 -falign-stack=maintain-16-byte  -MMD -c -o libavutil/cpu.o libavutil/cpu.c
libavutil/cpu.c(48): error: identifier "ATOMIC_VAR_INIT" is undefined
  static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
                                ^

libavutil/cpu.c(48): error: function call is not allowed in a constant expression
  static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
                                ^

compilation aborted for libavutil/cpu.c (code 2)
make: *** [libavutil/cpu.o] Error 2
--snip--

Moritz
James Almer Dec. 30, 2016, 3:03 a.m. UTC | #4
On 12/29/2016 10:15 PM, Moritz Barsnick wrote:
> On Thu, Dec 29, 2016 at 11:06:12 +0100, Michael Niedermayer wrote:
>> On Thu, Dec 29, 2016 at 12:12:13AM -0300, James Almer wrote:
>>> On 12/28/2016 7:41 PM, Michael Niedermayer wrote:
>>>> Fixes build failure on FreeBSD with gcc 4.7
>>>
>>> Does this also fix ticket #6049? If so, please mention it.
>>
>> I dont have ICC, so i dont know
> 
> I checked, it does not fix that.

Ok, pushing my patch then.

A better, more thorough fix/check for this header is welcome, assuming
it's necessary.
James Almer Dec. 30, 2016, 5:31 p.m. UTC | #5
On 12/28/2016 7:41 PM, Michael Niedermayer wrote:
> Fixes build failure on FreeBSD with gcc 4.7
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  configure | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/configure b/configure
> index d723b8e2a6..706346abc9 100755
> --- a/configure
> +++ b/configure
> @@ -1201,13 +1201,14 @@ check_cpp_condition(){
>  EOF
>  }
>  
> -test_cflags_cpp(){
> -    log test_cflags_cpp "$@"
> +test_cflags_cc(){
> +    log test_cflags_cc "$@"
>      flags=$1
>      condition=$2
>      shift 2
>      set -- $($cflags_filter "$flags")
> -    check_cpp "$@" <<EOF
> +    check_cc "$@" <<EOF
> +#include <ctype.h>

Maybe make the header an argument instead of hardcoding it, same as
check_cpp_condition().

LGTM in any case.

>  #if !($condition)
>  #error "unsatisfied condition: $condition"
>  #endif
> @@ -4625,7 +4626,7 @@ add_cxxflags -std=c++98
>  
>  # some compilers silently accept -std=c11, so we also need to check that the
>  # version macro is defined properly
> -if test_cflags_cpp -std=c11 "__STDC_VERSION__ >= 201112L"; then
> +if test_cflags_cc -std=c11 "__STDC_VERSION__ >= 201112L"; then
>      add_cflags -std=c11
>  else
>      check_cflags -std=c99
>
Michael Niedermayer Dec. 31, 2016, 12:12 p.m. UTC | #6
On Fri, Dec 30, 2016 at 02:31:14PM -0300, James Almer wrote:
> On 12/28/2016 7:41 PM, Michael Niedermayer wrote:
> > Fixes build failure on FreeBSD with gcc 4.7
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  configure | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/configure b/configure
> > index d723b8e2a6..706346abc9 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1201,13 +1201,14 @@ check_cpp_condition(){
> >  EOF
> >  }
> >  
> > -test_cflags_cpp(){
> > -    log test_cflags_cpp "$@"
> > +test_cflags_cc(){
> > +    log test_cflags_cc "$@"
> >      flags=$1
> >      condition=$2
> >      shift 2
> >      set -- $($cflags_filter "$flags")
> > -    check_cpp "$@" <<EOF
> > +    check_cc "$@" <<EOF
> > +#include <ctype.h>
> 
> Maybe make the header an argument instead of hardcoding it, same as
> check_cpp_condition().

changed


> 
> LGTM in any case.

applied

thx

[...]
diff mbox

Patch

diff --git a/configure b/configure
index d723b8e2a6..706346abc9 100755
--- a/configure
+++ b/configure
@@ -1201,13 +1201,14 @@  check_cpp_condition(){
 EOF
 }
 
-test_cflags_cpp(){
-    log test_cflags_cpp "$@"
+test_cflags_cc(){
+    log test_cflags_cc "$@"
     flags=$1
     condition=$2
     shift 2
     set -- $($cflags_filter "$flags")
-    check_cpp "$@" <<EOF
+    check_cc "$@" <<EOF
+#include <ctype.h>
 #if !($condition)
 #error "unsatisfied condition: $condition"
 #endif
@@ -4625,7 +4626,7 @@  add_cxxflags -std=c++98
 
 # some compilers silently accept -std=c11, so we also need to check that the
 # version macro is defined properly
-if test_cflags_cpp -std=c11 "__STDC_VERSION__ >= 201112L"; then
+if test_cflags_cc -std=c11 "__STDC_VERSION__ >= 201112L"; then
     add_cflags -std=c11
 else
     check_cflags -std=c99