memory: cross compiling for QNX segfaults

When cross compile master on QNX, I get a segmentation fault from container_node_sizes_impl.hpp

CMake command with toolchain: qnx_toolchain.zip

cmake .. -DCMAKE_TOOLCHAIN_FILE=~/Downloads/qnx_toolchain.cmake -DCMAKE_INSTALL_PREFIX=/home/brian/qnx700/target/qnx7/x86/usr/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF -DFOONATHAN_MEMORY_BUILD_TESTS=OFF -DFOONATHAN_MEMORY_BUILD_TOOLS=ON

Output: [ 13%] Generating container_node_sizes_impl.hpp cd /home/brian/Downloads/foonathan_memory/build/src && ../tool/nodesize_dbg --code --alignof "FOONATHAN_ALIGNOF(T)" /home/brian/Downloads/foonathan_memory/build/src/container_node_sizes_impl.hpp Segmentation fault (core dumped) src/CMakeFiles/foonathan_memory.dir/build.make:64: recipe for target 'src/container_node_sizes_impl.hpp' failed make[2]: *** [src/container_node_sizes_impl.hpp] Error 139 make[2]: Leaving directory '/home/brian/Downloads/foonathan_memory/build' CMakeFiles/Makefile2:88: recipe for target 'src/CMakeFiles/foonathan_memory.dir/all' failed make[1]: *** [src/CMakeFiles/foonathan_memory.dir/all] Error 2 make[1]: Leaving directory '/home/brian/Downloads/foonathan_memory/build' Makefile:132: recipe for target 'all' failed make: *** [all] Error 2 build_output.txt

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (17 by maintainers)

Commits related to this issue

Most upvoted comments

in case anybody else stumbles across this issue in future with the same problem:

let’s look at the build as a 3-step process.

  1. it first builds tool/nodesize_dbg,
  2. then runs nodesize_dbg to determine some properties of the system and generate the include/foonathan/memory/detail/container_node_sizes_impl.hpp headerfile,
  3. and finally compiles the rest of the library now that all headers are present.

when cross-compiling, step 2 will fail, as it is attempting to run the nodesize_dbg binary (built for the target system) on the host system rather than the target.

the simplest workaround for this is the following:

  1. run the build (it will fail, as seen at the top of this thread)
  2. when the build fails, copy the nodesize_dbg binary from the host’s build directory to the target, then run it with the appropriate arguments to generate the necessary header file (you can find the correct invocation in the build log output or the cmake files)
  3. copy the generated headerfile back from the target to the correct location in the project directory on the host
  4. comment out the cmake line that runs nodesize_dbg
  5. rerun the build

(i’m sure there’s a cleaner way to do it, but this approach works well enough for a one-off build)

(p.s.: if you instead changed up the cmake files to build nodesize_dbg for the host, allowing it to run successfully, the information it would gather from the host system is likely significantly different from the target environment. this would cause the build to succeed but likely lead to runtime errors in any applications linked against the library, so we don’t want to do this.)