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

panic.c not building if PICO_PANIC_FUNCTION defined #1790

Closed
Memotech-Bill opened this issue Aug 9, 2024 · 4 comments
Closed

panic.c not building if PICO_PANIC_FUNCTION defined #1790

Memotech-Bill opened this issue Aug 9, 2024 · 4 comments
Assignees
Milestone

Comments

@Memotech-Bill
Copy link

Memotech-Bill commented Aug 9, 2024

My build defines PICO_PANIC_FUNCTION=sys_panic. With that definition, building panic.c fails.

[ 27%] Building C object CMakeFiles/bbcbasic.dir/home/pi/pico/pico-sdk/src/rp2_common/pico_platform_panic/panic.c.obj
/home/pi/pico/pico-sdk/src/rp2_common/pico_platform_panic/panic.c: In function 'panic':
/home/pi/pico/pico-sdk/src/rp2_common/pico_platform_panic/panic.c:34:5: warning: implicit declaration of function 'pico_default_asm' [-Wimplicit-function-declaration]
     pico_default_asm (
     ^~~~~~~~~~~~~~~~
/home/pi/pico/pico-sdk/src/rp2_common/pico_platform_panic/panic.c:45:26: error: expected ')' before ':' token
             "push {lr}\n"
                          ^
                          )
/home/pi/pico/pico-sdk/src/rp2_common/pico_platform_panic/panic.c:53:9:
         :
         ~                 
make[3]: *** [CMakeFiles/bbcbasic.dir/build.make:399: CMakeFiles/bbcbasic.dir/home/pi/pico/pico-sdk/src/rp2_common/pico_platform_panic/panic.c.obj] Error 1

This is on a fully updated copy of Bullseye. Compiler version:

pi@raspberrypi:~/pico/PicoBB/console/pico_w/build $ /usr/bin/arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/8.3.1/lto-wrapper
Target: arm-none-eabi
Configured with: ../configure --build=arm-linux-gnueabihf --prefix=/usr --includedir='/usr/lib/include' --mandir='/usr/lib/share/man' --infodir='/usr/lib/share/info' --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir='/usr/lib/lib/arm-linux-gnueabihf' --libexecdir='/usr/lib/lib/arm-linux-gnueabihf' --disable-maintainer-mode --disable-dependency-tracking --mandir=/usr/share/man --enable-languages=c,c++,lto --enable-multilib --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --enable-tls --build=arm-linux-gnueabihf --target=arm-none-eabi --with-system-zlib --with-gnu-as --with-gnu-ld --with-pkgversion=15:8-2019-q3-1+b1 --without-included-gettext --prefix=/usr/lib --infodir=/usr/share/doc/gcc-arm-none-eabi/info --htmldir=/usr/share/doc/gcc-arm-none-eabi/html --pdfdir=/usr/share/doc/gcc-arm-none-eabi/pdf --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --disable-libstdc++-v3 --host=arm-linux-gnueabihf --with-headers=no --without-newlib --with-multilib-list=rmprofile CFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' CXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' FCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' FFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' GCJFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' LDFLAGS=-Wl,-z,relro OBJCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' OBJCXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-arm-none-eabi-3BFy9A/gcc-arm-none-eabi-8-2019-q3=. -fstack-protector-strong' INHIBIT_LIBC_CFLAGS=-DUSE_TM_CLONE_REGISTRY=0 AR_FOR_TARGET=arm-none-eabi-ar AS_FOR_TARGET=arm-none-eabi-as LD_FOR_TARGET=arm-none-eabi-ld NM_FOR_TARGET=arm-none-eabi-nm OBJDUMP_FOR_TARGET=arm-none-eabi-objdump RANLIB_FOR_TARGET=arm-none-eabi-ranlib READELF_FOR_TARGET=arm-none-eabi-readelf STRIP_FOR_TARGET=arm-none-eabi-strip
Thread model: single
gcc version 8.3.1 20190703 (release) [gcc-8-branch revision 273027] (15:8-2019-q3-1+b1) 
@Memotech-Bill
Copy link
Author

Found the problem.

The source file panic.c is missing:

#include "pico/platform/compiler.h"

As a result, the following definition is missing:

#define pico_default_asm(...) __asm (".syntax unified\n" __VA_ARGS__)

So the compiler thinks pico_default_asm() is a standard C function call, and the colons are a syntax error.

I just need work out how to fix that in my build until the SDK gets fixed.

@Memotech-Bill
Copy link
Author

Messy, but adding the following line to my CMakeLists.txt file works around the issue for now:

  target_compile_options(${PROJECT_NAME} PUBLIC -include pico/platform/compiler.h)

@Memotech-Bill Memotech-Bill changed the title panic.c not building on bullseye panic.c not building if PICO_PANIC_FUNCTION defined Aug 9, 2024
@kilograham
Copy link
Contributor

Ah, good spot, only happens with PICO_PANIC_FUNCTION defined which is how we missed it

@kilograham
Copy link
Contributor

this (header issue) was already fixed by an earlier commit, so closing. Note i did make some changes in passing (#2062)

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