Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: 'stdatomic.h' file not found #9059

Closed
ryandesign opened this issue Jun 28, 2022 · 9 comments
Closed

fatal error: 'stdatomic.h' file not found #9059

ryandesign opened this issue Jun 28, 2022 · 9 comments
Labels

Comments

@ryandesign
Copy link
Contributor

@ryandesign ryandesign commented Jun 28, 2022

I did this

Compile curl

I expected the following

Successful compile

curl/libcurl version

7.84.0

operating system

OS X 10.8
Xcode 5.1.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)

OS X 10.9
Xcode 6.2
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)

checking if _Atomic is available... yes
In file included from easy.c:89:
../lib/easy_lock.h:38:10: fatal error: 'stdatomic.h' file not found
#include <stdatomic.h>
         ^

https://build.macports.org/builders/ports-10.8_x86_64-builder/builds/95200/steps/install-port/logs/stdio
https://build.macports.org/builders/ports-10.9_x86_64-builder/builds/193386/steps/install-port/logs/stdio

So the problem seems to be that it checks if _Atomic is available, and, if so, it assumes stdatomic.h is available, which is evidently not the case on all systems.

On Mac OS X 10.7 there is no problem because checking if _Atomic is available... no

On OS X 10.10 this problem doesn't occur because stdatomic.h exists (but a different problem occurs; see #9058)

@jay jay added the build label Jun 28, 2022
@bagder
Copy link
Member

@bagder bagder commented Jun 28, 2022

For the case where there is no stdatomic.h header but Atomic works, does it still build fine without including the header?

@bagder
Copy link
Member

@bagder bagder commented Jun 28, 2022

If so, then we could just do this:

diff --git a/lib/easy_lock.h b/lib/easy_lock.h
index 07c85c5ff..174c0222c 100644
--- a/lib/easy_lock.h
+++ b/lib/easy_lock.h
@@ -33,11 +33,13 @@
 
 #define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m)
 #define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m)
 
 #elif defined (HAVE_ATOMIC)
+#ifdef HAVE_STDATOMIC_H
 #include <stdatomic.h>
+#endif
 #if defined(HAVE_SCHED_YIELD)
 #include <sched.h>
 #endif
 
 #define curl_simple_lock atomic_bool
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
index ec406f56a..80bc4ca3c 100644
--- a/m4/curl-functions.m4
+++ b/m4/curl-functions.m4
@@ -6584,10 +6584,11 @@ AC_DEFUN([CURL_ATOMIC],[
   ],[
     AC_MSG_RESULT([yes])
     AC_DEFINE_UNQUOTED(HAVE_ATOMIC, 1,
       [Define to 1 if you have _Atomic support.])
     tst_atomic="yes"
+    AC_CHECK_HEADERS(stdatomic.h)
   ],[
     AC_MSG_RESULT([no])
     tst_atomic="no"
   ])
 ])

@bagder
Copy link
Member

@bagder bagder commented Jun 28, 2022

I suppose it's not likely to work without the header since we use atomic_bool in the code but check for _Atomic in configure... Let me do a proper PR instead.

bagder added a commit that referenced this issue Jun 28, 2022
... and only set HAVE_ATOMIC if that exists

Reported-by: Ryan Schmidt
Fixes #9059
@jmroot
Copy link

@jmroot jmroot commented Jun 28, 2022

Yeah, _Atomic is a language keyword and so its existence is just dependent on the compiler, whereas the typedefs for atomic_bool etc. are in stdatomic.h.

@bagder
Copy link
Member

@bagder bagder commented Jun 28, 2022

yeah, I figured that out as well, so in the #9060 PR, configure will only set HAVE_ATOMIC if both the header is present and the type check works.

@bagder bagder closed this as completed in a68074b Jun 28, 2022
@Vibhanshu09
Copy link

@Vibhanshu09 Vibhanshu09 commented Jul 20, 2022

I have tried building libCurl 7.84.0 in AIX 7.2 using XLC 16.1.0 , but we facing issue, while running gmake:

In file included from easy.c:89:
../lib/easy_lock.h:38:10: fatal error: 'stdatomic.h' file not found

while in configure step we saw: checking if _Atomic is available... yes

I tried with the fix provided in #9060
But that is also not working.

@bagder
Copy link
Member

@bagder bagder commented Jul 20, 2022

@Vibhanshu09 can you please try the current git master, and if that still doesn't work file a new issue for your case?

@Vibhanshu09
Copy link

@Vibhanshu09 Vibhanshu09 commented Jul 22, 2022

Thank you for the help. I tried with latest main branch, which is working fine. Can you please provide me Estimated date for official release of 7.85.0.

@dfandrich
Copy link
Collaborator

@dfandrich dfandrich commented Jul 22, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants