Skip to content
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

Error building libc for Cross ARM Cortex-M4F #194

Open
tdyjv opened this issue May 21, 2024 · 7 comments
Open

Error building libc for Cross ARM Cortex-M4F #194

tdyjv opened this issue May 21, 2024 · 7 comments

Comments

@tdyjv
Copy link

tdyjv commented May 21, 2024

I'm attempting to compile libc for an STM32L4R5 (Cortex-M4F) on a Linux system running kubuntu 22.04
I cloned the latest libc from the GitHub repo.
I am completely new to using the meson build system, but am willing to learn.
Any help would be appreciated.

After cloning the libc repo...

$ make distclean
$ make default CROSS=arm:cortex-m4_hardfloat

It seems to fail trying to compile cmocka for the ARM STM32 complaining about a missing setjmp.h which I assume should be provided by the local libc headers not the system. setjmp.h is in the libc/include directory.
The compiler invocation to compile cmocka.c does not include any reference to the local header files.
Is there a simple way to add the local libc headers to the cmocka.c build command ljne ?
The complete meson-log.txt file is attached here, but I don't see any reference to cmocka.c there so I'm not sure how helpful that will be.

Here is the final line of output from the build attempt

...
Embedded Artistry libc 1.0

  Subprojects
    cmocka     : YES

  User defined options
    Cross files: meson/cross/arm.txt
                 meson/cross/cortex-m4_hardfloat.txt

Found ninja-1.10.1 at /usr/bin/ninja
ninja: Entering directory `buildresults'                                                                                                                                                    
[1/543] Compiling C object subprojects/cmocka-1.1.5/src/libcmocka.so.0.5.0.p/cmocka.c.o
FAILED: subprojects/cmocka-1.1.5/src/libcmocka.so.0.5.0.p/cmocka.c.o 
arm-none-eabi-gcc -Isubprojects/cmocka-1.1.5/src/libcmocka.so.0.5.0.p -Isubprojects/cmocka-1.1.5/src -I../subprojects/cmocka-1.1.5/src -I../subprojects/cmocka-1.1.5/include -Isubprojects/cmocka-1.1.5/private -I../subprojects/cmocka-1.1.5/private -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=gnu99 -O2 -Wshadow -Wmissing-prototypes -Wcast-align -Werror=address -Werror=strict-prototypes -Werror=write-strings -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=declaration-after-statement -Werror=return-type -Werror=uninitialized -Wimplicit-fallthrough -Werror=strict-overflow -Wstrict-overflow=2 -Wno-format-zero-length -Wformat -fno-common -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mabi=aapcs -mthumb -fPIC -DHAVE_CONFIG_H=1 -MD -MQ subprojects/cmocka-1.1.5/src/libcmocka.so.0.5.0.p/cmocka.c.o -MF subprojects/cmocka-1.1.5/src/libcmocka.so.0.5.0.p/cmocka.c.o.d -o subprojects/cmocka-1.1.5/src/libcmocka.so.0.5.0.p/cmocka.c.o -c ../subprojects/cmocka-1.1.5/src/cmocka.c
../subprojects/cmocka-1.1.5/src/cmocka.c:39:10: fatal error: setjmp.h: No such file or directory
   39 | #include <setjmp.h>
      |          ^~~~~~~~~~
compilation terminated.
[13/543] Compiling C object subprojects/cmocka-1.1.5/src/libcmocka_native.so.0.5.0.p/cmocka.c.o
../subprojects/cmocka-1.1.5/src/cmocka.c: In function ‘cmocka_run_one_test_or_fixture’:
../subprojects/cmocka-1.1.5/src/cmocka.c:2768:9: warning: variable ‘rc’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
 2768 |     int rc = 0;
      |         ^~
[14/543] Compiling C++ object printf_tests.p/printf_test_test_suite.cpp.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:57: default] Error 1

meson-log.txt

@phillipjohnston
Copy link
Member

Looks like a behavioral change in Meson is causing CMocka to fail to cross-compile (previously, it was not being compiled). Working on a fork of the build rules for that project, and then will adjust this repo to use the forked version.

@phillipjohnston
Copy link
Member

mesonbuild/meson#12530

@tdyjv
Copy link
Author

tdyjv commented May 21, 2024

Would there be a quick workaround to disable the cmocka cross build ?

@phillipjohnston
Copy link
Member

Just completed the changes and pushed to the repo if you want to give that a try.

@tdyjv
Copy link
Author

tdyjv commented May 21, 2024

Thanks for the quick response, libc seems to have completed. I will start on the stdc++ libs now.

I had an additional error earlier in test/meson.build at line 156 which I had to change to
"native_map_file.format(meson.current_build_dir()+'/sample_app')," to continue. Not sure if that was the right thing to do or not, but it got me further.

@phillipjohnston
Copy link
Member

Do you recall the error? Was that in the skeleton?

@tdyjv
Copy link
Author

tdyjv commented May 21, 2024

Output from make.....

Dependency cmocka from subproject subprojects/cmocka-1.1.7 found: YES 1.1.7
Program arm-none-eabi-objcopy found: YES (/home/jvolpe/arm-tools/bin/arm-none-eabi-objcopy)
Message: Native objcopy program not available, .hex and .bin conversion targets will be disabled.
Compiler for C supports arguments -nostdinc: YES 
Compiler for C supports arguments -fno-builtin: YES 
Compiler for C supports arguments -nostdinc: YES 
Compiler for C supports arguments -fno-builtin: YES 
Compiler for C supports arguments -nolibc: YES 
Compiler for C supports arguments -nolibc: YES (cached)
Compiler for C supports arguments -nolibc: YES (cached)
Compiler for C supports arguments -nostartfiles: YES 
Compiler for C supports arguments -nolibc: YES (cached)
Compiler for C supports arguments -Wno-unused-parameter: YES 
Compiler for C supports arguments -Wno-stringop-truncation: YES 
Compiler for C supports arguments -Wno-stringop-overflow: YES 
Message: Some tests are disabled when builtins and/or optimizations are enabled.
Program arm-none-eabi-objcopy found: YES (/home/jvolpe/arm-tools/bin/arm-none-eabi-objcopy)

test/meson.build:156:12: ERROR: Unknown method "format" in object <[ArrayHolder] holds [list]: []> of type ArrayHolder.

A full log can be found at /home/jvolpe/Projects/libc/buildresults/meson-logs/meson-log.txt
make: *** [Makefile:80: buildresults/build.ninja] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants