Hi Andreas,

I spent some time on cross-compilation this morning. 

My findings are that is that CMake is reporting that these functions are available:

-- Looking for setjmp.h
-- Looking for setjmp.h - found

-- Looking for setjmp
-- Looking for setjmp - found
-- Looking for longjmp
-- Looking for longjmp - found
-- Looking for siglongjmp
-- Looking for siglongjmp - found

-- Looking for setjmp
-- Looking for setjmp - found

-- Looking for clock_gettime
-- Looking for clock_gettime - found

But looking through the toolchain headers for the ARM cross compilation configuration, setjmp/longjmp are present but siglongjmp and clock_gettime are NOT available on the platform. This results in a number of compiler errors:

/Users/phillip/src/ea/course-code/src/002-cross-platform-build-system/cmake/011-tooling/buildresults/_deps/cmocka-src/src/cmocka.c:100:33: error: unknown type name 'sigjmp_buf'
  100 | # define cm_jmp_buf             sigjmp_buf
      |                                 ^~~~~~~~~~
/Users/phillip/src/ea/course-code/src/002-cross-platform-build-system/cmake/011-tooling/buildresults/_deps/cmocka-src/src/cmocka.c:282:22: note: in expansion of macro 'cm_jmp_buf'
  282 | static CMOCKA_THREAD cm_jmp_buf global_run_test_env;
      |                      ^~~~~~~~~~
/Users/phillip/src/ea/course-code/src/002-cross-platform-build-system/cmake/011-tooling/buildresults/_deps/cmocka-src/src/cmocka.c: In function 'exit_test':
/Users/phillip/src/ea/course-code/src/002-cross-platform-build-system/cmake/011-tooling/buildresults/_deps/cmocka-src/src/cmocka.c:102:33: warning: implicit declaration of function 'siglongjmp'; did you mean 'longjmp'? [-Wimplicit-function-declaration]
  102 | # define cm_longjmp(env, val)   siglongjmp(env, val)
      |                                 ^~~~~~~~~~
/Users/phillip/src/ea/course-code/src/002-cross-platform-build-system/cmake/011-tooling/buildresults/_deps/cmocka-src/src/cmocka.c:406:9: note: in expansion of macro 'cm_longjmp'
  406 |         cm_longjmp(global_run_test_env, 1);
      |         ^~~~~~~~~~

When I updated the configuration checks to use check_symbol_exists for these items (used elsewhere in that file too), the checks properly noted that these functions weren't found, and compiling the static library for ARM succeeded.

check_symbol_exists(siglongjmp setjmp.h HAVE_SIGLONGJMP)

check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)

-- Looking for siglongjmp
-- Looking for siglongjmp - not found

-- Looking for clock_gettime
-- Looking for clock_gettime - not found

cmocka-build (master) $ ninja
[4/4] Linking C static library src/libcmocka-static.a

I also re-ran this configuration change on OS X, and the functions were properly detected in this configuration:

-- Looking for siglongjmp
-- Looking for siglongjmp - found

-- Looking for clock_gettime
-- Looking for clock_gettime - found

Could you update the configuration check function?

Cheers,

Phillip Johnston
Principal, Firmware & Architecture
Consulting
 | Blog | Newsletter






On Dec 16, 2021, at 03:25, Andreas Schneider <asn@cryptomilk.org> wrote:

On Thursday, December 16, 2021 9:37:27 AM CET Ryan McClue wrote:
Hello, I'm trying to cross compile with arm-none-eabi-gcc on an Ubuntu x64
build machine.

My CMake toolchain file contains the following flags:

mcpu=cortex-m4 -mthumb -mfloat-abi=soft -fdata-sections -ffunction-sections
\ --specs=rdimon.specs -lgcc -lc -lm -lrdimon

This doesn't look like how a toolchain file should look like! Those are just
CFLAGS.

https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html

Example:
https://gitlab.com/cmocka/cmocka/-/blob/master/cmake/Toolchain-Debian-mips.cmake


Best regards


Andreas

--
Andreas Schneider                 asn@cryptomilk.org
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D


_______________________________________________
cmocka-devel mailing list -- cmocka-devel@cmocka.org
To unsubscribe send an email to cmocka-devel-leave@cmocka.org