sergey-safarov created an issue (kamailio/kamailio#4333)
### Description
I want to compile Kamailio sources on `ppc64le` arch. During compilation, I see an error
```sh [ 0%] Building C object src/CMakeFiles/kamailio.dir/main.c.o In file included from /tmp/kamailio/src/core/parser/../mem/../lock_ops.h:92, from /tmp/kamailio/src/core/parser/../mem/shm.h:44, from /tmp/kamailio/src/core/parser/../mem/shm_mem.h:32, from /tmp/kamailio/src/core/parser/../ut.h:46, from /tmp/kamailio/src/core/parser/../ip_addr.h:41, from /tmp/kamailio/src/core/parser/msg_parser.h:39, from /tmp/kamailio/src/core/select.h:36, from /tmp/kamailio/src/core/route_struct.h:35, from /tmp/kamailio/src/core/route.h:39, from /tmp/kamailio/src/main.c:79: /tmp/kamailio/src/core/parser/../mem/../fastlock.h:130:2: error: #error "unknown architecture" 130 | #error "unknown architecture" | ^~~~~ /tmp/kamailio/src/core/parser/../mem/../fastlock.h: In function ‘tsl’: /tmp/kamailio/src/core/parser/../mem/../fastlock.h:294:2: error: #error "unknown architecture" 294 | #error "unknown architecture" | ^~~~~ /tmp/kamailio/src/core/parser/../mem/../fastlock.h: In function ‘get_lock’: /tmp/kamailio/src/core/parser/../mem/../fastlock.h:317:9: error: implicit declaration of function ‘membar_getlock’ [-Wimplicit-function-declaration] 317 | membar_getlock(); | ^~~~~~~~~~~~~~ /tmp/kamailio/src/core/parser/../mem/../fastlock.h: In function ‘release_lock’: /tmp/kamailio/src/core/parser/../mem/../fastlock.h:436:2: error: #error "unknown architecture" 436 | #error "unknown architecture" | ^~~~~ In file included from /tmp/kamailio/src/core/atomic_ops.h:180, from /tmp/kamailio/src/core/locking.h:74, from /tmp/kamailio/src/core/rpc.h:36, from /tmp/kamailio/src/core/sr_module.h:38, from /tmp/kamailio/src/main.c:85: /tmp/kamailio/src/core/atomic/atomic_unknown.h: At top level: /tmp/kamailio/src/core/atomic/atomic_unknown.h:53:2: warning: #warning no native memory barrier implementations, falling back to slow lock based workaround [-Wcpp] 53 | #warning no native memory barrier implementations, falling back to slow lock \ | ^~~~~~~ gmake[2]: *** [src/CMakeFiles/kamailio.dir/build.make:76: src/CMakeFiles/kamailio.dir/main.c.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:3359: src/CMakeFiles/kamailio.dir/all] Error 2 gmake: *** [Makefile:156: all] Error 2 ```
### Expected behavior Sources compiled without error messages.
#### Actual observed behavior Build failed be error described above.
### Reproduction ```sh git clone https://github.com/kamailio/kamailio.git docker run -it \ --platform linux/ppc64le \ -v ./kamailio:/usr/src/kamailio \ ghcr.io/sergey-safarov/kamailio-builder:centos-10 cd /usr/src/kamailio cmake -S . -B build cmake --build build ```
sergey-safarov left a comment (kamailio/kamailio#4333)
Could you also check this archs support ``` s390x arm/v7 arm/v6 riscv64 386 ```
xkaraman left a comment (kamailio/kamailio#4333)
Hey @sergey-safarov,
You can see the available archs for atomics in https://github.com/kamailio/kamailio/blob/master/src/core/atomic/atomic_nati....
Therefore, for `s390x` and `riscv64`, there is nothing on cmake side that can fix that. It needs to be implement in kamailio source.
Now, for `ppc` there is support, but i imagine that your platform OS is define as `ppc64le`. Can you confirm this by looking at `cmake` config stage and the ouput of `Target Processor: xxxx` line? I have a fix already (https://github.com/xkaraman/kamailio/blob/a4fe1b9d9c82705ec060284f04f7f0d840...) by aliasing it to `ppc64` where it's an acceptable value. If you can confirm it as well it would be great.
`arm` is also supported. the source requires though `Target Processor` to be `arm`,`arm6` or `arm7`. If it's anything else we might need to alias is to one of them. There is a long list of what `CMAKE_SYSTEM_PROCESSOR` values can be, look at https://stackoverflow.com/questions/45125516/possible-values-for-uname-m/451... for possible values
If `386` is the same as `i386`, then it should be already supported. can you verify them as well?
sergey-safarov left a comment (kamailio/kamailio#4333)
I don't know what the correct answer is here. Could you check the Kamailio sources build logs for Alpine dists https://github.com/kamailio/kamailio/actions/runs/16435139788 Here used the old build approach ``` make cfg make ``` Sources compiled for 8 arch.
xkaraman left a comment (kamailio/kamailio#4333)
Hey @sergey-safarov ,
You were right. the error was on `USE_FAST_LOCK` conditions, where for uknonwn archs it was set to `YES` instead of `NO`. After 5e022e6722cfd626fb1a320240a73ad7e0cfe54c they should be now compiling, unless the `taget arch` needs to be aliased to known value found in https://github.com/kamailio/kamailio/blob/master/src/core/atomic/atomic_nati...
sergey-safarov left a comment (kamailio/kamailio#4333)
I have tried ```diff --- a/cmake/defs.cmake +++ b/cmake/defs.cmake @@ -25,6 +25,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i486|i586|i686") set(TARGET_ARCH "i386") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64") set(TARGET_ARCH "x86_64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") + set(TARGET_ARCH "ppc64") else() set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}") endif() ``` Yes, this build sources, but I think `ppc64` is not equal to `ppc64le`. More details at https://codeyarns.com/tech/2020-08-17-difference-between-ppc64-and-ppc64le.h...
Also, I see cmake detect architecture ``` -- OS: Linux -- OS version: 6.14.9-300.fc42.x86_64 -- Host Processor: ppc64le -- Target Processor: ppc64le -- Target Processor Alias: ppc64le -- Fast lock available: YES -- Configuring for Linux -- Cross compile: FALSE ```
Other arch can be tested ```sh git clone https://github.com/kamailio/kamailio.git docker run -it \ --user root \ --platform linux/riscv64 \ -v ./kamailio:/usr/src/kamailio \ ghcr.io/sergey-safarov/kamailio-builder:alpine-latest apk add cmake ``` For this command cmake output will be ``` -- Host Processor: riscv64 -- Target Processor: riscv64 -- Target Processor Alias: riscv64
```
xkaraman left a comment (kamailio/kamailio#4333)
Yes, this build sources, but I think `ppc64` is not equal to `ppc64le`. More details at https://codeyarns.com/tech/2020-08-17-difference-between-ppc64-and-ppc64le.h...
Yes feels to me also that they are not the same. I wll remove that commit.
Therefore `ppc64` should have `USE_FAST_LOCK=ON` but `ppc64le` to `OFF`. Due to https://github.com/kamailio/kamailio/blob/5ac0428c2228bc8be70104fe8ff14fd1ac... and the fact that this does a regex match both are picked to yes wrongly.
I will rearrange the conditions to match our expectations and get back to you.
xkaraman left a comment (kamailio/kamailio#4333)
@sergey-safarov
https://github.com/xkaraman/kamailio/tree/cmake should now build correctly.
But some remarks:
On old makefiles builds on https://github.com/kamailio/kamailio/actions/runs/16435139788/job/4644366774... i see this warning: ` #warning powerpc64 atomic code was not tested, please report problems to \ sr-dev@lists.kamailio.org ` which comes from ``` #ifdef __CPU_ppc64 #warning powerpc64 atomic code was not tested, please report problems to \ sr-dev@lists.kamailio.org #endif ```
This means that old makefiles are detecting the platform as `ppc64` and not `ppc64le`. How do you think we should handle this?
sergey-safarov left a comment (kamailio/kamailio#4333)
@henningw, could you guide us with the question in the message above?
For it is a notification, and can be left for this archs ``` ppc64le s390x arm/v7 arm/v6 riscv64 ```
xkaraman left a comment (kamailio/kamailio#4333)
@sergey-safarov i dont meant for the actual warning per se but that the old makefiles seems to NOT differintiate `ppc64` from `ppc64le` since this warning is emmited for `__CPU_ppc64`