xkaraman left a comment (kamailio/kamailio#4403)
Hey @sergey-safarov,
Yeah it seems `cmake` has this limitation about idenityfing OS arch instead of
processor arch. (See https://gitlab.kitware.com/cmake/cmake/-/issues/21577
which is still open though)
There are a couple of solutions to this:
1. If you know, you are compiling for a 32bit on a natively 64bit, you can just
provide the `-m32` compile option at the configuration option.
This has to be done the first time `cmake` is running for a build, beacuse
these flags are cached. Otherwise you can you the `cmake --fresh` switch, if
you have a recent enough `cmake`.
`CFLAGS=-m32 CXXFLAGS=-m32 cmake ...` (see
https://cmake.org/pipermail/cmake/2013-February/053595.html)
Although this is one simple way, in our `CMakeLists.txt`, we are using
`CMAKE_SYSTEM_PROCESSOR` to detect various things. Therefore option 1 would not
be the best, that brings us option 2.
2. Use a toolchain file to define the variables. This is mainly used for
cross-compilation scenarios, and we can say that this case is in nature just
different bitness instead of arch. (See
https://cmake.org/pipermail/cmake/2013-February/053619.html and
https://stackoverflow.com/a/28047073
So, we will have to create a new file in our `cmake/` folder named
`x86_toolchain.cmake` setting up the various information that need for 32 bit
build.
The important would be `CMAKE_SYSTEM_NAME `, `CMAKE_SYSTEM_PROCESSOR` and
hopefully the rest of the option will be found from the rest of our cmake files
like `defs.cmake` and `compiler-specific.cmake`.
For `CMAKE_SYSTEM_PROCESSOR` any value of `i386|i486|i586|i686` would be
suffice, and for `CMAKE_SYSTEM_NAME` probably `Linux` is a good one.
Regarding `set(CMAKE_FIND_ROOT_PATH /usr/i486-linux-gnu)` line, i am not
sure if we need this, probably need to do some testing. You can fine the docs
[here](https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_ROOT_PATH.html).
It's for setting where to search for libraries and executables for the specific
arch. But since we can mostly build 32 bit binaries from the native 64bit host
with just -m32 flag, this seems to me unnessecary. Good to know though if
something goes off!
So after creating the toolchain, we can just cmake with the toolchain provided
like
`cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake /path/to/source`
I would go with option 2. it requires a bit extra work, but i think it better
with a centralised toolchain that we can also provided the user with for easier
32bit building if need.
You can try it and and if you need me to create or adopt anything let me know!
Best regards,
Xenofon
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4403#issuecomment-3323254188
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4403/[email protected]>_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!