fast_io icon indicating copy to clipboard operation
fast_io copied to clipboard

Configure for use in embedded systems (esp32 using xtensa gcc)?

Open MartyMcFlyInTheSky opened this issue 3 years ago • 24 comments

I'm working on an esp32 microcontroller. stdin and stdout are streamlined through UART I think. I don't know if the native libraries expose a posix API but I doubt it. In any case, how can I make it work? I don't actually need the stdin and stdout capabilities, they might as well be short circuited. I'm using fast_io mainly for scan to iterator or print to iterator.

Here are some of the errors I get when compiling without change (same compiles fine with msys mingw64 x86):

In file included from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native_base.h:23,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native.h:2,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted.h:56,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io.h:9,
                 from C:/dev/aurora-light-controller/main/app_main.cpp:14:
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h: In function 'std::size_t fast_io::details::posix_scatter_pread_size_impl(int, fast_io::io_scatters_t, intmax_t)':
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1791:70: error: 'len' was not declared in this scope
 1791 |         if(static_cast<std::size_t>(std::numeric_limits<int>::max())<len)
      |                                                                      ^~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:35: error: 'iovec_may_alias' does not name a type
 1793 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                   ^~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:51: error: expected '>' before 'const'
 1793 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                   ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:51: error: expected '(' before 'const'
 1793 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                   ^~~~~
      |                                                   (
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:51: error: expected primary-expression before 'const'
 1793 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                   ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:50: error: expected ')' before 'const'
 1793 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                  ^~~~~~
      |                                                  )
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:51: error: expected '}' before 'const'
 1793 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                 ~                                 ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1793:51: error: expected ',' or ';' before 'const'
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h: At global scope:
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1794:44: error: '::preadv' has not been declared; did you mean 'readv'?
 1794 |         std::ptrdiff_t val{noexcept_call(::preadv,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                            ^~~~~~
      |                                            readv
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1794:51: error: 'fd' was not declared in this scope
 1794 |         std::ptrdiff_t val{noexcept_call(::preadv,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                   ^~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1794:54: error: 'ptr' was not declared in this scope
 1794 |         std::ptrdiff_t val{noexcept_call(::preadv,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                      ^~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1794:75: error: 'sz' was not declared in this scope
 1794 |         std::ptrdiff_t val{noexcept_call(::preadv,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                                           ^~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1794:98: error: 'offset' was not declared in this scope; did you mean 'off_t'?       
 1794 |         std::ptrdiff_t val{noexcept_call(::preadv,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                                                                  ^~~~~~
      |                                                                                                  off_t
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1795:9: error: expected unqualified-id before 'if'
 1795 |         if(val<0)
      |         ^~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1797:9: error: expected unqualified-id before 'return'
 1797 |         return static_cast<std::size_t>(val);
      |         ^~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h: In function 'std::size_t fast_io::posix_scatter_pwrite_size_impl(int, fast_io::io_scatters_t, intmax_t)':
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:35: error: 'iovec_may_alias' does not name a type
 1817 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                   ^~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:51: error: expected '>' before 'const'
 1817 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                   ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:51: error: expected '(' before 'const'
 1817 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                   ^~~~~
      |                                                   (
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:51: error: expected primary-expression before 'const'
 1817 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                   ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:50: error: expected ')' before 'const'
 1817 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                                                  ^~~~~~
      |                                                  )
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:51: error: expected '}' before 'const'
 1817 |         auto ptr{reinterpret_cast<iovec_may_alias const*>(sp.base)};
      |                 ~                                 ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1817:51: error: expected ',' or ';' before 'const'
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h: At global scope:
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1818:44: error: '::pwritev' has not been declared; did you mean 'writev'?
 1818 |         std::ptrdiff_t val{noexcept_call(::pwritev,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                            ^~~~~~~
      |                                            writev
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1818:52: error: 'fd' was not declared in this scope
 1818 |         std::ptrdiff_t val{noexcept_call(::pwritev,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                    ^~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1818:55: error: 'ptr' was not declared in this scope
 1818 |         std::ptrdiff_t val{noexcept_call(::pwritev,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                       ^~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1818:76: error: 'sz' was not declared in this scope
 1818 |         std::ptrdiff_t val{noexcept_call(::pwritev,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                                            ^~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1818:99: error: 'offset' was not declared in this scope; did you mean 'off_t'?       
 1818 |         std::ptrdiff_t val{noexcept_call(::pwritev,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                                                                                   ^~~~~~
      |                                                                                                   off_t
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1819:9: error: expected unqualified-id before 'if'
 1819 |         if(val<0)
      |         ^~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1821:9: error: expected unqualified-id before 'return'
 1821 |         return static_cast<std::size_t>(val);
      |         ^~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1825:8: error: 'io_scatter_status_t' does not name a type
 1825 | inline io_scatter_status_t posix_scatter_pwrite_impl(int fd,io_scatters_t sp,std::intmax_t offset)
      |        ^~~~~~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1830:22: error: 'io_scatter_status_t' does not name a type
 1830 | [[nodiscard]] inline io_scatter_status_t posix_scatter_pread_impl(int fd,io_scatters_t sp,std::intmax_t offset)
      |                      ^~~~~~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1834:1: error: expected declaration before '}' token
 1834 | }
      | ^
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:29: error: 'template<class char_type, class Iter>  requires (integral<char_type>) && (contiguous_iterator<Iter>) constexpr const Iter pread' redeclared as different kind of entity
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                             ^~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/dev/esp/esp-idf/components/newlib/platform_include/sys/unistd.h:11,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\unistd.h:4,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\pthread.h:25,
                 from C:/dev/esp/esp-idf/components/newlib/platform_include/pthread.h:13,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\xtensa-esp32-elf\no-rtti\bits\gthr-default.h:35,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\xtensa-esp32-elf\no-rtti\bits\gthr.h:148, 
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\ext\atomicity.h:35,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\bits\basic_string.h:39,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\string:55,
                 from C:/dev/aurora-light-controller/main/app_main.cpp:2:
c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\sys\unistd.h:186:9: note: previous declaration 'ssize_t pread(int, void*, size_t, off_t)'
  186 | ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset);
      |         ^~~~~
In file included from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native_base.h:23,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native.h:2,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted.h:56,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io.h:9,
                 from C:/dev/aurora-light-controller/main/app_main.cpp:14:
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:29: error: 'basic_posix_io_observer' was not declared in this scope; did you mean 'fast_io::basic_posix_io_observer'?
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                             ^~~~~~~~~~~~~~~~~~~~~~~
      |                             fast_io::basic_posix_io_observer
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:371:7: note: 'fast_io::basic_posix_io_observer' declared here
  371 | class basic_posix_io_observer
      |       ^~~~~~~~~~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:62: error: expected primary-expression before '>' token
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                              ^
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:64: error: 'piob' was not declared in this scope
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                ^~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:74: error: expected primary-expression before 'begin'
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                          ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:85: error: expected primary-expression before 'end'
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                                     ^~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1837:103: error: expected primary-expression before 'offset'
 1837 | inline constexpr Iter pread(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                                                       ^~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:30: error: 'template<class char_type, class Iter>  requires (integral<char_type>) && (contiguous_iterator<Iter>) constexpr const Iter pwrite' redeclared as different kind of entity
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                              ^~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/dev/esp/esp-idf/components/newlib/platform_include/sys/unistd.h:11,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\unistd.h:4,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\pthread.h:25,
                 from C:/dev/esp/esp-idf/components/newlib/platform_include/pthread.h:13,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\xtensa-esp32-elf\no-rtti\bits\gthr-default.h:35,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\xtensa-esp32-elf\no-rtti\bits\gthr.h:148, 
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\ext\atomicity.h:35,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\bits\basic_string.h:39,
                 from c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\11.2.0\string:55,
                 from C:/dev/aurora-light-controller/main/app_main.cpp:2:
c:\dev\esp\.espressif\tools\xtensa-esp32-elf\esp-2022r1-rc1-11.2.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\sys\unistd.h:187:9: note: previous declaration 'ssize_t pwrite(int, const void*, size_t, off_t)'
  187 | ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t __offset);
      |         ^~~~~~
In file included from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native_base.h:23,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native.h:2,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted.h:56,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io.h:9,
                 from C:/dev/aurora-light-controller/main/app_main.cpp:14:
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:30: error: 'basic_posix_io_observer' was not declared in this scope; did you mean 'fast_io::basic_posix_io_observer'?
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                              ^~~~~~~~~~~~~~~~~~~~~~~
      |                              fast_io::basic_posix_io_observer
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:371:7: note: 'fast_io::basic_posix_io_observer' declared here
  371 | class basic_posix_io_observer
      |       ^~~~~~~~~~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:63: error: expected primary-expression before '>' token
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                               ^
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:65: error: 'piob' was not declared in this scope
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                 ^~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:75: error: expected primary-expression before 'begin'
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                           ^~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:86: error: expected primary-expression before 'end'
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                                      ^~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1843:104: error: expected primary-expression before 'offset'
 1843 | inline constexpr Iter pwrite(basic_posix_io_observer<char_type> piob,Iter begin,Iter end,std::intmax_t offset)
      |                                                                                                        ^~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1849:22: error: 'io_scatter_status_t' does not name a type
 1849 | [[nodiscard]] inline io_scatter_status_t scatter_pread(basic_posix_io_observer<ch_type> piob,io_scatters_t sp,std::intmax_t offset)
      |                      ^~~~~~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1855:8: error: 'io_scatter_status_t' does not name a type
 1855 | inline io_scatter_status_t scatter_pwrite(basic_posix_io_observer<ch_type> piob,io_scatters_t sp,std::intmax_t offset)
      |        ^~~~~~~~~~~~~~~~~~~
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1862:1: error: expected declaration before '}' token
 1862 | }
      | ^
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the c:\dev\aurora-light-controller\build\log\idf_py_stderr_output_18568 and c:\dev\aurora-light-controller\build\log\idf_py_stdout_output_18568

MartyMcFlyInTheSky avatar Aug 25 '22 06:08 MartyMcFlyInTheSky

can you show me the target of compiler?

trcrsired avatar Aug 25 '22 06:08 trcrsired

xtensa-esp32-elf right?

hmhm. fast_io never supported that before. I will go and see what is going on with a new toolchain

trcrsired avatar Aug 25 '22 06:08 trcrsired

xtensa-esp32-elf yes. I think it's a gcc derivate and uses libstdc++. Current compiler version is 11.2.

EDIT: I think this lib is very interesting for embedded systems as we can't use charconv because of binary bloat and it exposes the RYU floating point interpreter. You should look into that if you have time, I and my fellow developers would love it :)

EDIT2: Find the toolchain here

MartyMcFlyInTheSky avatar Aug 25 '22 06:08 MartyMcFlyInTheSky

I have used the AVR macro to guard against XTENSA. can you have a try to see whether it works?

That is exactly one goal of fast_io. The only problem is the herbception does not exist. Or it should be smaller than printf for embedded systems

trcrsired avatar Aug 25 '22 06:08 trcrsired

can you have a try now to see whether it works? i do not have an xtensa toolchain at all. Cannot test it

trcrsired avatar Aug 25 '22 06:08 trcrsired

If this does not break compilation for fast_io.h any more, i will go on fixing other issues

trcrsired avatar Aug 25 '22 07:08 trcrsired

You can also use -ffreestanding flag to avoid using any hosted features to GCC

trcrsired avatar Aug 25 '22 07:08 trcrsired

Thank you for your urgent action. Unfortunately it doesn't compile. XTENSA however is recognised, so errors changed. Is this intended? :

#if defined(__AVR__) && defined(__XTENSA__)

Or should it mean #if defined(__AVR__) || defined(__XTENSA__)?

This appears in many places

EDIT: My dev framework depends on hosted features it seems, I can't remove it (or i get errors). I've attached the framework for you to my previous post ^^. Installing should be simple, just download git repo and use the install.sh or install.bat command in repo directory to install toolchain.

MartyMcFlyInTheSky avatar Aug 25 '22 09:08 MartyMcFlyInTheSky

Thank you for your urgent action. Unfortunately it doesn't compile. XTENSA however is recognised, so errors changed. Is this intended? :

#if defined(__AVR__) && defined(__XTENSA__)

Or should it mean #if defined(__AVR__) || defined(__XTENSA__)?

This appears in many places

EDIT: My dev framework depends on hosted features it seems, I can't remove it (or i get errors). I've attached the framework for you to my previous post ^^. Installing should be simple, just download git repo and use the install.sh or install.bat command in repo directory to install toolchain.

Fixed with pull request 177

Also no no no. using -ffreestanding does not block the feature for your hosted toolchain. It will only disable hosted features for fast_io since i guard against STDC_HOSTED. Most libraries including C library and C++ standard libraries do not do that.

Also this macro does not seem to be correct either. glibc and many libcs do support xtensa-linux-gnu, xtensa-linux-musl etc. Guard against that will break xtensa linux. I will fix them later by building several cross toolchains.

trcrsired avatar Aug 25 '22 16:08 trcrsired

Looks like it is using newlib.

https://github.com/espressif/xtensa-overlays/blob/master/xtensa_esp32/newlib/newlib/libc/sys/xtensa/include/xtensa/config/core-isa.h

whatever. maybe i'll gonna try later.

Does your toolchain support EH?

trcrsired avatar Aug 25 '22 17:08 trcrsired

newlib like libcs do provide file descriptors. I believe it is just some small issues with guard against newlib. It is not AVR.

trcrsired avatar Aug 25 '22 23:08 trcrsired

I can probably provide a GCC 13 for you.

trcrsired avatar Aug 25 '22 23:08 trcrsired

I do not know. I use your toolchain to get a GCC 13. https://github.com/trcrsired/windows-hosted-xtensa-esp32-elf-cross-toolchain I revert back the changes and no compilation issues are found.

trcrsired avatar Aug 26 '22 00:08 trcrsired

gcc 11? the link you showed me is a gcc 8.4.0. And i use that to get a GCC 13.0.0. Found issues with the new toolchain. Are you sure you give me the right link?

trcrsired avatar Aug 26 '22 00:08 trcrsired

I know what's wrong here.

Your build system defines _POSIX_C_SOURCE, but fast_io's code was wrong with _POSIX_C_SOURCE. It has nothing to do with XTENSA at all. It is a bug in fast_io.

Thank you

trcrsired avatar Aug 26 '22 01:08 trcrsired

Is it working right now?

trcrsired avatar Aug 26 '22 01:08 trcrsired

for micro controller thing. you can just define a driver like this. Then it would work on UART.

https://github.com/cppfastio/fast_io/blob/master/include/fast_io_driver/avr/console.h

trcrsired avatar Aug 26 '22 03:08 trcrsired

  • It's interesting. You're right that stdlibc++ doesn't guard against STDC_HOSTED, but the guard seems to be in the compiler. I get errors for constexpr sqrts: error: call to non-'constexpr' function 'double sqrt(double)'. I don't know what the compiler does behind my back but maybe there's a problem with freestanding and floating point representation, idk. So I would prefer to not use the flag since I'm widely using the standard library, so if the lib authors decides to suddenly actually guard against the flag (which apparently the flag was intended for) it will wreck my code.
  • yes the toolchain optionally supports exception handling (which I have to turn on anyway, otherwise exceptions are just abort stubs). Looking forward :) I'm not using system stdout and stdin with fast_io anyway, so I would already benefit hugely if this was guarded out and other functions (like scan from iterator or print to iterator) are available :)

MartyMcFlyInTheSky avatar Aug 26 '22 07:08 MartyMcFlyInTheSky

Sorry still had this tab open, didn't refresh to see that you answered.

Thank you in any case. It almost compiles. There are still minor bugs:

F esp-idf\main\CMakeFiles\__idf_main.dir\app_main.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/app_main.cpp.obj -c C:/dev/aurora-light-controller/main/app_main.cpp
In file included from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native_base.h:23,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/native.h:2,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted.h:56,
                 from C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io.h:9,
                 from C:/dev/aurora-light-controller/main/app_main.cpp:14:
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h: In function 'std::size_t fast_io::details::posix_scatter_pread_size_impl(int, fast_io::io_scatters_t, intmax_t)':
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1799:44: error: '::preadv' has not been declared; did you mean 'readv'?
 1799 |         std::ptrdiff_t val{noexcept_call(::preadv,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                            ^~~~~~
      |                                            readv
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h: In function 'std::size_t fast_io::details::posix_scatter_pwrite_size_impl(int, fast_io::io_scatters_t, intmax_t)':
C:/dev/aurora-light-controller/components/fast_io/fast_io/include/fast_io_hosted/platforms/posix.h:1828:44: error: '::pwritev' has not been declared; did you mean 'writev'?
 1828 |         std::ptrdiff_t val{noexcept_call(::pwritev,fd,ptr,static_cast<int>(sz),static_cast<off_t>(offset))};
      |                                            ^~~~~~~
      |                                            writev
[828/842] Building CXX object esp-idf/aurora_lights/CMakeFiles/__idf_aurora_lights.dir/aurora_lights.cpp.objninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the c:\dev\aurora-light-controller\build\log\idf_py_stderr_output_42904 and c:\dev\aurora-light-controller\build\log\idf_py_stdout_output_42904

I had a look into unistd.h and prwritev indeed is not defined in there. What is the deal with this function (sorry I have very limited POSIX knowledge). I found this in mingw64 related includes:

/* Define to 1 if you have the `pwritev' function. */
/* #undef HAVE_PWRITEV */

Makes me think that pwritev is not that commen in unistd.h?

You say it compiled with gcc 13? Sorry the link I gave you is indeed not current. I give you the repo directly: https://github.com/espressif/esp-idf. I think you get gcc 11 if you use install.bat from master branch.

MartyMcFlyInTheSky avatar Aug 26 '22 11:08 MartyMcFlyInTheSky

preadv and pwritev do not exist in newlib-cygwin. I will add guard against them.

trcrsired avatar Aug 26 '22 13:08 trcrsired

BTW for your usecase, instead of

#include<fast_io.h>

You could just use

#include<fast_io_freestanding.h>

That would avoid any hosted feature.

Also the preadv and pwritev issue should be fixed with PR#181 .

trcrsired avatar Aug 26 '22 13:08 trcrsired

It compiles without errors now! Thank you a ton! Looking forward to implementing that driver as well (when I have time for it) :))

MartyMcFlyInTheSky avatar Aug 26 '22 13:08 MartyMcFlyInTheSky

does puts("Hello World\n") works for you? If that works, you can just use print("Hello World\n"); It prints out to C's stdout. (Maybe your toolchain already defines _write())

If it does not, then you can just define your own driver and makes it satisfy the concept of scatter output stream.

trcrsired avatar Aug 26 '22 14:08 trcrsired

You are free to contribute a driver for your device with pulling request. fast_io_driver is for 3rd party things.

trcrsired avatar Aug 26 '22 17:08 trcrsired