diff mbox

[FFmpeg-devel] configure: make the check for stdatomic.h stricter

Message ID 20161228005542.2596-1-jamrial@gmail.com
State Accepted
Commit 6993bb4eb6c358c390f674a10f8a8ca69d9ee0fe
Headers show

Commit Message

James Almer Dec. 28, 2016, 12:55 a.m. UTC
ICC stdatomic.h implementation seems to be incomplete or broken,
missing the ATOMIC_VAR_INIT() macro.

Should fix ticket #6049

Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Moritz Barsnick Dec. 28, 2016, 11:17 p.m. UTC | #1
On Tue, Dec 27, 2016 at 21:55:42 -0300, James Almer wrote:
> ICC stdatomic.h implementation seems to be incomplete or broken,
> missing the ATOMIC_VAR_INIT() macro.
> 
> Should fix ticket #6049

Your patch works for me with ICC 14.0.3. I'm the reporter of #6049.

But see this:
https://software.intel.com/en-us/articles/c11-support-in-intel-c-compiler

ICC may have the stdatomic.h header and have some of the features, but
doesn't actually advertise them (__STDC_VERSION__) before their
(somewhat) complete implementation in ICC 16. Same situation with gcc
before 4.7, I guess. Perhaps the check for __STDC_VERSION__ == 201112L
would "guarantee" the proper availability of atomics (would need to be
verified on all sorts of compilers), but I guess your check for the
actually used features is more to the point. Is that check complete
though?

Moritz
James Almer Dec. 29, 2016, 2:40 p.m. UTC | #2
On 12/28/2016 8:17 PM, Moritz Barsnick wrote:
> On Tue, Dec 27, 2016 at 21:55:42 -0300, James Almer wrote:
>> ICC stdatomic.h implementation seems to be incomplete or broken,
>> missing the ATOMIC_VAR_INIT() macro.
>>
>> Should fix ticket #6049
> 
> Your patch works for me with ICC 14.0.3. I'm the reporter of #6049.
> 
> But see this:
> https://software.intel.com/en-us/articles/c11-support-in-intel-c-compiler
> 
> ICC may have the stdatomic.h header and have some of the features, but
> doesn't actually advertise them (__STDC_VERSION__) before their
> (somewhat) complete implementation in ICC 16. Same situation with gcc
> before 4.7, I guess. Perhaps the check for __STDC_VERSION__ == 201112L
> would "guarantee" the proper availability of atomics (would need to be
> verified on all sorts of compilers), but I guess your check for the
> actually used features is more to the point. Is that check complete
> though?
> 
> Moritz

Such check already exists, but apparently is not thorough enough.
Could you test Michael's "[PATCH] configure: Check build with some header
not just preprocessing for testing --std=c11" to see if it also fixes
this ticket? If so, this patch can be dropped.
James Almer Dec. 30, 2016, 3:05 a.m. UTC | #3
On 12/27/2016 9:55 PM, James Almer wrote:
> ICC stdatomic.h implementation seems to be incomplete or broken,
> missing the ATOMIC_VAR_INIT() macro.
> 
> Should fix ticket #6049
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Pushed.
diff mbox

Patch

diff --git a/configure b/configure
index d723b8e..56a0b65 100755
--- a/configure
+++ b/configure
@@ -5623,7 +5623,7 @@  check_header asm/types.h
 # it seems there are versions of clang in some distros that try to use the
 # gcc headers, which explodes for stdatomic
 # so we also check that atomics actually work here
-check_builtin stdatomic_h stdatomic.h "atomic_int foo; atomic_store(&foo, 0)"
+check_builtin stdatomic_h stdatomic.h "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0)"
 
 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32