-
Notifications
You must be signed in to change notification settings - Fork 188
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
Fix cmake crosscompiling #60
Conversation
…statically to avoid anoying library search paths then use the crosscompiling emulator to run it to generate container_node_sizes_impl during the build.
So the MacOS build does not seem to work because of the -static, the windows build seems to break because it can't find the nodesize_dbg executable. I propose you fix MacOS by adding -static only if cross compiling, I don't know how to fix Windows. |
@wtsnyder What if we only add |
when not cross compiling
Removed '-static' option from non cross compile builds. The windows issues seemed to be that nodesize_dbg executable is put in '${CMAKE_BINARY_DIR}\tool\Debug\nodesize_dbg' instead of '${CMAKE_BINARY_DIR}\tool\nodesize_dbg'. Must be an MSVC thing. Was able to fix it using a generator expression to get the actual path to the executable for that build. |
+1 |
Thank you very much! |
Android NDK cross-compile still not work for me, my commands: Is there anything wrong? |
plus, I'm compliling Ros2 foxy |
Sorry, I don't know anything about cross compiling. What is your error? |
to cross compile for QNX and generate the header file manually this process can be done as following:
|
One more thing I would like to add specifically for QNX is that after comparing the header file generated on my linux laptop and the one generated on a QNX system they turn out to be identical. So it can be compiled natively on linux without having to cross compile |
Doesn't it work out of the box with the changes from this PR? |
This PR solved cross compiling for linux but not for QNX as it relies on running qemu with an image of the target OS. I do actually have a qemu image for QNX but it seems that for linux qemu is started with nodesize_dbg as an argument which I could not get it to work in the same way for QNX. After Investigation on the output it seems the header file is exactly the same as the one generated on a linux laptop (host). I remodifed memory/src/CMakeLists.txt to make it more simple like so:
No need to cross compile and generate the header file on target or emulator, it can be generated natively on Linux. I assume results will be the same on any POSIX OS. |
This fix allows foonathan/memory to build correctly with all nodesize features when crosscompiling. It builds the nodesize_dbg tool and links it statically to avoid anoying library search paths. Then it uses the crosscompiling emulator provided by the toolchain file to run nodesize_dbg and generate container_node_sizes_impl.hpp during the build.
For this to work the toolchain file must provide the emulator executable
Example aarch64-linux-gnu.cmake toolchain file