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

Examples don't get compiled #493

Closed
Plaque-fcc opened this issue Jan 15, 2025 · 7 comments
Closed

Examples don't get compiled #493

Plaque-fcc opened this issue Jan 15, 2025 · 7 comments

Comments

@Plaque-fcc
Copy link

$ cd examples/blink_raw/ && make
riscv64-linux-gnu-gcc -E -P -x c -DTARGET_MCU=CH32V003 -DMCU_PACKAGE= -DTARGET_MCU_LD=0 -DTARGET_MCU_MEMORY_SPLIT= ../../ch32v003fun//ch32v003fun.ld > ../../ch32v003fun//generated_ch32v003.ld
riscv64-linux-gnu-gcc -o blink_raw.elf ../../ch32v003fun//ch32v003fun.c blink_raw.c   -g -Os -flto -ffunction-sections -fdata-sections -fmessage-length=0 -msmall-data-limit=8 -march=rv32ec -mabi=ilp32e -DCH32V003=1 -static-libgcc -I/usr/include/newlib -I../../ch32v003fun//../extralibs -I../../ch32v003fun/ -nostdlib -I. -Wall  -Wl,--print-memory-usage -Wl,-Map=blink_raw.map -L../../ch32v003fun//../misc -lgcc -T ../../ch32v003fun//generated_ch32v003.ld -Wl,--gc-sections
In file included from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/stdio.h:61:40: error: expected declaration specifiers or ‘...’ before numeric constant
   61 |     __builtin___snprintf_chk(str, len, 0, __ssp_bos(str), __VA_ARGS__)
      |                                        ^
../../ch32v003fun//ch32v003fun.c:120:10: note: in expansion of macro ‘snprintf’
  120 | WEAK int snprintf( char * buffer, unsigned int buffer_len, const char* format, ... )
      |          ^~~~~~~~
In file included from /usr/include/newlib/ssp/stdio.h:34,
                 from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/ssp.h:46:24: error: expected declaration specifiers or ‘...’ before ‘__builtin_object_size’
   46 | #define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1)
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/newlib/ssp/stdio.h:61:43: note: in expansion of macro ‘__ssp_bos’
   61 |     __builtin___snprintf_chk(str, len, 0, __ssp_bos(str), __VA_ARGS__)
      |                                           ^~~~~~~~~
../../ch32v003fun//ch32v003fun.c:120:10: note: in expansion of macro ‘snprintf’
  120 | WEAK int snprintf( char * buffer, unsigned int buffer_len, const char* format, ... )
      |          ^~~~~~~~
In file included from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/stdio.h:55:34: error: expected declaration specifiers or ‘...’ before numeric constant
   55 |     __builtin___sprintf_chk(str, 0, __ssp_bos(str), __VA_ARGS__)
      |                                  ^
../../ch32v003fun//ch32v003fun.c:129:10: note: in expansion of macro ‘sprintf’
  129 | WEAK int sprintf( char * buffer, const char * format, ... )
      |          ^~~~~~~
In file included from /usr/include/newlib/ssp/stdio.h:34,
                 from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/ssp.h:46:24: error: expected declaration specifiers or ‘...’ before ‘__builtin_object_size’
   46 | #define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1)
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/newlib/ssp/stdio.h:55:37: note: in expansion of macro ‘__ssp_bos’
   55 |     __builtin___sprintf_chk(str, 0, __ssp_bos(str), __VA_ARGS__)
      |                                     ^~~~~~~~~
../../ch32v003fun//ch32v003fun.c:129:10: note: in expansion of macro ‘sprintf’
  129 | WEAK int sprintf( char * buffer, const char * format, ... )
      |          ^~~~~~~
/usr/include/newlib/ssp/ssp.h:47:52: error: expected declaration specifiers or ‘...’ before numeric constant
   47 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
      |                                                    ^
/usr/include/newlib/ssp/string.h:52:7: note: in expansion of macro ‘__ssp_bos0’
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |       ^~~~~~~~~~
/usr/include/newlib/ssp/string.h:102:31: note: in expansion of macro ‘__ssp_bos_check3’
  102 | #define memset(dst, val, len) __ssp_bos_check3(memset, dst, val, len)
      |                               ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:223:12: note: in expansion of macro ‘memset’
  223 | WEAK void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; for (; n; n--, s++) *s = c; return dest; }
      |            ^~~~~~
In file included from /usr/include/newlib/string.h:180,
                 from ../../ch32v003fun//ch32v003fun.c:85:
/usr/include/newlib/ssp/string.h:52:23: error: expected ‘)’ before ‘!=’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                       ^~
/usr/include/newlib/ssp/string.h:102:31: note: in expansion of macro ‘__ssp_bos_check3’
  102 | #define memset(dst, val, len) __ssp_bos_check3(memset, dst, val, len)
      |                               ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:223:12: note: in expansion of macro ‘memset’
  223 | WEAK void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; for (; n; n--, s++) *s = c; return dest; }
      |            ^~~~~~
/usr/include/newlib/ssp/string.h:52:38: error: expected ‘)’ before ‘?’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                                      ^
/usr/include/newlib/ssp/string.h:102:31: note: in expansion of macro ‘__ssp_bos_check3’
  102 | #define memset(dst, val, len) __ssp_bos_check3(memset, dst, val, len)
      |                               ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:223:12: note: in expansion of macro ‘memset’
  223 | WEAK void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; for (; n; n--, s++) *s = c; return dest; }
      |            ^~~~~~
In file included from /usr/include/newlib/ssp/stdio.h:34,
                 from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/ssp.h:47:52: error: expected declaration specifiers or ‘...’ before numeric constant
   47 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
      |                                                    ^
/usr/include/newlib/ssp/string.h:57:7: note: in expansion of macro ‘__ssp_bos0’
   57 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |       ^~~~~~~~~~
/usr/include/newlib/ssp/string.h:109:26: note: in expansion of macro ‘__ssp_bos_check2’
  109 | #define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src)
      |                          ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:224:12: note: in expansion of macro ‘strcpy’
  224 | WEAK char *strcpy(char *d, const char *s)
      |            ^~~~~~
In file included from /usr/include/newlib/string.h:180,
                 from ../../ch32v003fun//ch32v003fun.c:85:
/usr/include/newlib/ssp/string.h:57:23: error: expected ‘)’ before ‘!=’ token
   57 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                       ^~
/usr/include/newlib/ssp/string.h:109:26: note: in expansion of macro ‘__ssp_bos_check2’
  109 | #define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src)
      |                          ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:224:12: note: in expansion of macro ‘strcpy’
  224 | WEAK char *strcpy(char *d, const char *s)
      |            ^~~~~~
/usr/include/newlib/ssp/string.h:57:38: error: expected ‘)’ before ‘?’ token
   57 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                                      ^
/usr/include/newlib/ssp/string.h:109:26: note: in expansion of macro ‘__ssp_bos_check2’
  109 | #define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src)
      |                          ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:224:12: note: in expansion of macro ‘strcpy’
  224 | WEAK char *strcpy(char *d, const char *s)
      |            ^~~~~~
In file included from /usr/include/newlib/ssp/stdio.h:34,
                 from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/ssp.h:47:52: error: expected declaration specifiers or ‘...’ before numeric constant
   47 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
      |                                                    ^
/usr/include/newlib/ssp/string.h:52:7: note: in expansion of macro ‘__ssp_bos0’
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |       ^~~~~~~~~~
/usr/include/newlib/ssp/string.h:111:32: note: in expansion of macro ‘__ssp_bos_check3’
  111 | #define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len)
      |                                ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:229:12: note: in expansion of macro ‘strncpy’
  229 | WEAK char *strncpy(char *d, const char *s, size_t n)
      |            ^~~~~~~
In file included from /usr/include/newlib/string.h:180,
                 from ../../ch32v003fun//ch32v003fun.c:85:
/usr/include/newlib/ssp/string.h:52:23: error: expected ‘)’ before ‘!=’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                       ^~
/usr/include/newlib/ssp/string.h:111:32: note: in expansion of macro ‘__ssp_bos_check3’
  111 | #define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len)
      |                                ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:229:12: note: in expansion of macro ‘strncpy’
  229 | WEAK char *strncpy(char *d, const char *s, size_t n)
      |            ^~~~~~~
/usr/include/newlib/ssp/string.h:52:38: error: expected ‘)’ before ‘?’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                                      ^
/usr/include/newlib/ssp/string.h:111:32: note: in expansion of macro ‘__ssp_bos_check3’
  111 | #define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len)
      |                                ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:229:12: note: in expansion of macro ‘strncpy’
  229 | WEAK char *strncpy(char *d, const char *s, size_t n)
      |            ^~~~~~~
In file included from /usr/include/newlib/ssp/stdio.h:34,
                 from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/ssp.h:47:52: error: expected declaration specifiers or ‘...’ before numeric constant
   47 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
      |                                                    ^
/usr/include/newlib/ssp/string.h:52:7: note: in expansion of macro ‘__ssp_bos0’
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |       ^~~~~~~~~~
/usr/include/newlib/ssp/string.h:97:31: note: in expansion of macro ‘__ssp_bos_check3’
   97 | #define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
      |                               ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:421:12: note: in expansion of macro ‘memcpy’
  421 | WEAK void *memcpy(void *dest, const void *src, size_t n)
      |            ^~~~~~
In file included from /usr/include/newlib/string.h:180,
                 from ../../ch32v003fun//ch32v003fun.c:85:
/usr/include/newlib/ssp/string.h:52:23: error: expected ‘)’ before ‘!=’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                       ^~
/usr/include/newlib/ssp/string.h:97:31: note: in expansion of macro ‘__ssp_bos_check3’
   97 | #define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
      |                               ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:421:12: note: in expansion of macro ‘memcpy’
  421 | WEAK void *memcpy(void *dest, const void *src, size_t n)
      |            ^~~~~~
/usr/include/newlib/ssp/string.h:52:38: error: expected ‘)’ before ‘?’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                                      ^
/usr/include/newlib/ssp/string.h:97:31: note: in expansion of macro ‘__ssp_bos_check3’
   97 | #define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
      |                               ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:421:12: note: in expansion of macro ‘memcpy’
  421 | WEAK void *memcpy(void *dest, const void *src, size_t n)
      |            ^~~~~~
In file included from /usr/include/newlib/ssp/stdio.h:34,
                 from /usr/include/newlib/stdio.h:800,
                 from ../../ch32v003fun//ch32v003fun.c:84:
/usr/include/newlib/ssp/ssp.h:47:52: error: expected declaration specifiers or ‘...’ before numeric constant
   47 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
      |                                                    ^
/usr/include/newlib/ssp/string.h:52:7: note: in expansion of macro ‘__ssp_bos0’
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |       ^~~~~~~~~~
/usr/include/newlib/ssp/string.h:98:32: note: in expansion of macro ‘__ssp_bos_check3’
   98 | #define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len)
      |                                ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:437:12: note: in expansion of macro ‘memmove’
  437 | WEAK void *memmove(void *dest, const void *src, size_t n)
      |            ^~~~~~~
In file included from /usr/include/newlib/string.h:180,
                 from ../../ch32v003fun//ch32v003fun.c:85:
/usr/include/newlib/ssp/string.h:52:23: error: expected ‘)’ before ‘!=’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                       ^~
/usr/include/newlib/ssp/string.h:98:32: note: in expansion of macro ‘__ssp_bos_check3’
   98 | #define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len)
      |                                ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:437:12: note: in expansion of macro ‘memmove’
  437 | WEAK void *memmove(void *dest, const void *src, size_t n)
      |            ^~~~~~~
/usr/include/newlib/ssp/string.h:52:38: error: expected ‘)’ before ‘?’ token
   52 |     ((__ssp_bos0(dst) != (size_t)-1) ? \
      |                                      ^
/usr/include/newlib/ssp/string.h:98:32: note: in expansion of macro ‘__ssp_bos_check3’
   98 | #define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len)
      |                                ^~~~~~~~~~~~~~~~
../../ch32v003fun//ch32v003fun.c:437:12: note: in expansion of macro ‘memmove’
  437 | WEAK void *memmove(void *dest, const void *src, size_t n)
      |            ^~~~~~~
make: *** [../../ch32v003fun/ch32v003fun.mk:233: blink_raw.elf] Error 1
@TommyMurphyTM1234
Copy link
Contributor

Why are you trying to compile the ch32v003fun example using the RISC-V Linux toolchain rather than the RISC-V bare-metal toolchain?

@Plaque-fcc
Copy link
Author

Plaque-fcc commented Jan 15, 2025

Why are you trying to compile the ch32v003fun example using the RISC-V Linux toolchain rather than the RISC-V bare-metal toolchain?

I am new and had no specific intention to prefer one instead of the other. All I did was I followed the instructions provided with the project.

What should I additionally change or set up?

@TommyMurphyTM1234
Copy link
Contributor

You should use the RISC-V bare-metal toolchain:

@Plaque-fcc
Copy link
Author

You should use the RISC-V bare-metal toolchain:

* https://github.com/cnlohr/ch32v003fun?tab=readme-ov-file#getting-started
  
  * https://github.com/cnlohr/ch32v003fun/wiki/Installation

Thanks so much, by bad, I didn't evaluate the situation right. And yes, most of the time environments at least complain when don't find required means. Seems like the compiler in my case totally doesn't do the job.

Building the proper toolchain, expect it to solve this issue.

@TommyMurphyTM1234
Copy link
Contributor

You can probably use the latest xPack binary toolchain to avoid having to build your own...

Note that the xPack toolchain uses the prefix riscv-none-elf- and not the "usual" riscvXX-unknown-elf-.

@Plaque-fcc
Copy link
Author

I managed to build it, and it seems to have resolved my issue. Thank you very much, closing this one.

@TommyMurphyTM1234
Copy link
Contributor

Great, glad it helped! 👍

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