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

Error when cross-compiling using Android NDK toolchain on an x86_64 Linux machine #1767

Closed
d3cxxxx opened this issue Sep 16, 2024 · 6 comments

Comments

@d3cxxxx
Copy link

d3cxxxx commented Sep 16, 2024

  • Version of iperf3:
    3.17.1

  • Operating system (and distribution, if any):
    Ubuntu 24.04.1 LTS

  • Other relevant information (for example, non-default compilers,
    libraries, cross-compiling, etc.):
    Cross compiling for ARM64 (aarch64) using Android prebuilt toolchain r26d

Bug Report

Clean compilation of up to date 3.17.1 branch results in compilation errors when cross-compiling.

  • Expected Behavior
    Compilation completes just like it does for PC (x86_64).

  • Actual Behavior
    make throws the following error:

Making all in src
make[1]: Entering directory '/code/iperf3/build_arm64/src'
make  all-am
make[2]: Entering directory '/code/iperf3/build_arm64/src'
  CC       iperf_api.lo
  CC       iperf_client_api.lo
../../iperf/src/iperf_client_api.c:61:28: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'int' [-Wint-conversion]
    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                           ^~~~~~~~~~~~~~~~~~~~~
../../iperf/src/iperf_pthread.h:13:31: note: expanded from macro 'PTHREAD_CANCEL_ENABLE'
#define PTHREAD_CANCEL_ENABLE NULL
                              ^~~~
/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/include/stddef.h:89:16: note: expanded from macro 'NULL'
#  define NULL ((void*)0)
               ^~~~~~~~~~
../../iperf/src/iperf_pthread.h:16:32: note: passing argument to parameter 'state' here
int pthread_setcancelstate(int state, int *oldstate);
                               ^
1 error generated.
make[2]: *** [Makefile:970: iperf_client_api.lo] Error 1
make[2]: Leaving directory '/code/iperf3/build_arm64/src'
make[1]: *** [Makefile:724: all] Error 2
make[1]: Leaving directory '/code/iperf3/build_arm64/src'
make: *** [Makefile:398: all-recursive] Error 1```

* Steps to Reproduce

* Possible Solution

# Enhancement Request

* Current behavior

* Desired behavior

* Implementation notes

@davidBar-On
Copy link
Contributor

../../iperf/src/iperf_pthread.h:13:31: note: expanded from macro 'PTHREAD_CANCEL_ENABLE'
#define PTHREAD_CANCEL_ENABLE NULL

Line 13 in iperf_pthread.h is: #define PTHREAD_CANCEL_ENABLE 0. It is not clear why the error message shows that the defined value as NULL. Can it be that your process includes preprocessing that converts 0 to NULL?

@d3cxxxx
Copy link
Author

d3cxxxx commented Sep 18, 2024

Here's the env:

/code/iperf3/iperf$ git status
HEAD detached at 3.17.1
nothing to commit, working tree clean
/code/iperf3/iperf$ 

Here are the steps used for compilation (nothing out of ordinary or preprocessing):

../ipef/configure --host aarch64-linux-android --enable-static-bin LDFLAGS=-static-libstdc++ 
make

@davidBar-On
Copy link
Contributor

I was looking at the master branch and not 3.17.1... This issue was fixed by #1687 (see also issue #1700). It was not released yet, so either change the NULL to 0 manually or use the master branch.

@d3cxxxx
Copy link
Author

d3cxxxx commented Sep 18, 2024

Thank you very much. That took the build further along until it hit another block:

../../iperf/src/iperf_pthread.c:16:19: error: call to undeclared function 'iperf_set_thread_exit_handler'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if ((status = iperf_set_thread_exit_handler()) == 0) {
                  ^
../../iperf/src/iperf_pthread.c:31:5: error: call to undeclared library function 'memset' with type 'void *(void *, int, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    memset(&actions, 0, sizeof(actions)); 
    ^   
../../iperf/src/iperf_pthread.c:31:5: note: include the header <string.h> or explicitly provide a declaration for 'memset'
2 errors generated.
make[2]: *** [Makefile:970: iperf_pthread.lo] Error 1
make[2]: Leaving directory '/code/iperf3/build_arm64/src'
make[1]: *** [Makefile:724: all] Error 2

But I see master already has updates there. Am really thinking 3.17.1 might not be the right version for use icross compiled Android/ARM builds

@davidBar-On
Copy link
Contributor

Sorry, I replied too quickly. Several other changes are required to iperf_pthread.c/h files. See the code changes of PR #1687.

@d3cxxxx
Copy link
Author

d3cxxxx commented Sep 18, 2024

Awesome. Thank you so much for the pointer. That patch did the trick.

@d3cxxxx d3cxxxx closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants