axel-download-accelerator / axel

Lightweight CLI download accelerator
GNU General Public License v2.0
2.84k stars 258 forks source link

2.17.12 build failure #424

Closed chenrui333 closed 3 months ago

chenrui333 commented 3 months ago

👋 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

Biswa96 commented 3 months ago

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;
chenrui333 commented 3 months ago

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

chenrui333 commented 3 months ago

yeah, the patch works for me. 👍

Biswa96 commented 3 months ago

I am not sure if the patch is correct or not. axel maintainer told that the patch is not appropriate https://github.com/termux/termux-packages/issues/19093