axel-download-accelerator/axel

2.17.12 build failure

chenrui333 opened this issue ยท 4 comments

๐Ÿ‘‹ trying to build the latest release, but run into some build issue. The error log is as below:

error build log
  src/random.c:13:8: error: address argument to atomic operation must be a pointer to _Atomic type ('int *' invalid)
                  if (!atomic_compare_exchange_strong(&fd, &expect, tmp))
                       ^                              ~~~
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/stdatomic.h:139:67: note: expanded from macro 'atomic_compare_exchange_strong'
  #define atomic_compare_exchange_strong(object, expected, desired) __c11_atomic_compare_exchange_strong(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
                                                                    ^                                    ~~~~~~
  1 error generated.

full build log, https://github.com/Homebrew/homebrew-core/actions/runs/7704615760/job/20997343259?pr=161270
relates to Homebrew/homebrew-core#161270

The same error also happen with Android NDK (clang cross compiler). The following patch may work.

--- a/src/random.c
+++ b/src/random.c
@@ -6,7 +6,7 @@
 ssize_t
 axel_rand64(uint64_t *out)
 {
-	static int fd = -1;
+	static _Atomic int fd = -1;
 	if (fd == -1) {
 		int tmp = open("/dev/random", O_RDONLY);
 		int expect = -1;

@Biswa96 thanks for the pointer, going to try it now.

yeah, the patch works for me. ๐Ÿ‘

I am not sure if the patch is correct or not. axel maintainer told that the patch is not appropriate termux/termux-packages#19093