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

CivetWeb samples fail to build with CONFIG_NEWLIB_LIBC #39037

Closed
icsys-omh opened this issue Oct 1, 2021 · 2 comments
Closed

CivetWeb samples fail to build with CONFIG_NEWLIB_LIBC #39037

icsys-omh opened this issue Oct 1, 2021 · 2 comments
Labels
area: civetweb area: newlib Newlib C Standard Library Enhancement Changes/Updates/Additions to existing features known issue Known issue

Comments

@icsys-omh
Copy link
Contributor

Describe the bug
The websocket_server sample application fails to build with conflicting types errors on pthread-related types when compiled with CONFIG_NEWLIB_LIBC.

I originally discovered this problem when working on a custom C++ application, where newlib was used to get some of the C++ standard library. However, the issue can be readily reproduced using the websocket server sample, as long as the libc_extension.c is removed from CMakeLists.txt.

To Reproduce
Steps to reproduce the behavior:

  1. Modify the websocket server sample to enable CONFIG_NEWLIB_LIBC, and remove the libc_extension.c file:
diff --git a/samples/net/civetweb/websocket_server/CMakeLists.txt b/samples/net/civetweb/websocket_server/CMakeLists.txt
index 022e360762..0cf01f8c90 100644
--- a/samples/net/civetweb/websocket_server/CMakeLists.txt
+++ b/samples/net/civetweb/websocket_server/CMakeLists.txt
@@ -23,7 +23,7 @@ project(civetweb_websocket_server)
 
 target_sources(app PRIVATE
                ${src_dir}/main.c
-               ${common_src_dir}/libc_extensions.c
                ${src_dir}/http_server_handlers.c
                ${src_dir}/websocket_server_handlers.c)
 
diff --git a/samples/net/civetweb/websocket_server/prj.conf b/samples/net/civetweb/websocket_server/prj.conf
index b582bdd921..771d45164a 100644
--- a/samples/net/civetweb/websocket_server/prj.conf
+++ b/samples/net/civetweb/websocket_server/prj.conf
@@ -1,6 +1,8 @@
 # General config
 CONFIG_CIVETWEB=y
 
+CONFIG_NEWLIB_LIBC=y
+
 # pthreads
 CONFIG_POSIX_API=y
 CONFIG_PTHREAD_IPC=y
  1. Try to build the sample application with west:
    west build samples/net/civetweb/websocket_server/ -b nucleo_f767zi --build-dir build/

Expected behavior
The build should succeed.

Impact
Our application uses code that relies on the C++ standard libary (std::string, std::chrono), so disabling newlib is hence not really an option. This hence means that Zephyr's Civetweb implementation is unusable.

Logs and console output
The full build log is this on Ubuntu 20.04 with Zephyr SDK 0.13.1:

-- west build: generating a build system
Including boilerplate (Zephyr base): /home/username/Projects/subseadisplay/zephyr/cmake/app/boilerplate.cmake
CMake Deprecation Warning at /home/username/Projects/subseadisplay/zephyr/cmake/app/boilerplate.cmake:37 (cmake_policy):
  The OLD behavior for policy CMP0079 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  /home/username/Projects/subseadisplay/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /home/username/Projects/subseadisplay/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
  CMakeLists.txt:21 (find_package)


-- Application: /home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server
-- Zephyr version: 2.7.0-rc1 (/home/username/Projects/subseadisplay/zephyr), build: v2.7.0-rc1-151-g81595ed4db20
-- Found Python3: /home/username/zephyr-venv/bin/python3 (found suitable exact version "3.8.10") found components: Interpreter 
-- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
-- Board: nucleo_f767zi
-- Cache files will be written to: /home/username/.cache/zephyr
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Using toolchain: zephyr 0.13.1 (/opt/zephyr-sdk-0.13.1)
-- Found dtc: /opt/zephyr-sdk-0.13.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/username/Projects/subseadisplay/zephyr/boards/arm/nucleo_f767zi/nucleo_f767zi.dts
-- Generated zephyr.dts: /home/username/Projects/subseadisplay/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/username/Projects/subseadisplay/zephyr/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/username/Projects/subseadisplay/zephyr/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /home/username/Projects/subseadisplay/zephyr/build/zephyr/dts.cmake

warning: MINIMAL_LIBC_MALLOC_ARENA_SIZE (defined at lib/libc/Kconfig:124) was assigned the value
'16384' but got the value ''. Check these unsatisfied dependencies: MINIMAL_LIBC_MALLOC (=n),
MINIMAL_LIBC (=n). See
http://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE.html
and/or look up MINIMAL_LIBC_MALLOC_ARENA_SIZE in the menuconfig/guiconfig interface. The Application
Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of
the manual might be helpful too.

Parsing /home/username/Projects/subseadisplay/zephyr/Kconfig
Loaded configuration '/home/username/Projects/subseadisplay/zephyr/boards/arm/nucleo_f767zi/nucleo_f767zi_defconfig'
Merged configuration '/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/prj.conf'
Configuration saved to '/home/username/Projects/subseadisplay/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/username/Projects/subseadisplay/zephyr/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Target architecture - arm
CMake Warning (dev) at /snap/cmake/936/share/cmake-3.21/Modules/GNUInstallDirs.cmake:236 (message):
  Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
  target architecture is known.  Please enable at least one language before
  including GNUInstallDirs.
Call Stack (most recent call first):
  /home/username/Projects/subseadisplay/modules/lib/civetweb/CMakeLists.txt:53 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Enabling tests in the build - ON
-- Thread Stack Size - 102400
-- Enabling server executable - ON
-- Serve no static files - OFF
-- Disable CGI support - OFF
-- Disable caching support - OFF
-- C++ wrappers - OFF
-- IP Version 6 - OFF
-- Websockets support - ON
-- Server statistics support - OFF
-- Memory Debugging - OFF
-- ASAN in debug mode - ON
-- Force x32 / x64 architecture - OFF
-- Lua CGI support - OFF
-- Executable installation - ON
-- Build if there are warnings - ON
-- Duktape CGI support - OFF
-- SSL support - ON
-- Compile for OpenSSL 1.1 API - OFF
-- Dynamically load SSL libraries - ON
-- Configuring C Compiler
-- Performing Test HAVE_C_FLAG_STD_C11
-- Performing Test HAVE_C_FLAG_STD_C11 - Failed
-- Performing Test HAVE_C_FLAG_STD_C99
-- Performing Test HAVE_C_FLAG_STD_C99 - Failed
-- Performing Test HAVE_C_FLAG_STD_C89
-- Performing Test HAVE_C_FLAG_STD_C89 - Failed
-- Performing Test HAVE_C_FLAG_FSANITIZE_UNDEFINED
-- Performing Test HAVE_C_FLAG_FSANITIZE_UNDEFINED - Failed
-- Performing Test HAVE_C_FLAG_FSANITIZE_ADDRESS
-- Performing Test HAVE_C_FLAG_FSANITIZE_ADDRESS - Failed
-- Performing Test HAVE_C_FLAG_COVERAGE
-- Performing Test HAVE_C_FLAG_COVERAGE - Failed
CMake Warning at /home/username/Projects/subseadisplay/zephyr/CMakeLists.txt:717 (message):
  No SOURCES given to Zephyr library: drivers__net

  Excluding target from build.


CMake Warning at /home/username/Projects/subseadisplay/zephyr/CMakeLists.txt:717 (message):
  No SOURCES given to Zephyr library: drivers__ethernet__phy

  Excluding target from build.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/username/Projects/subseadisplay/zephyr/build
-- west build: building application
[7/199] Preparing syscall dependency handling

[160/199] Building C object modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj
FAILED: modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj 
ccache /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBUILD_VERSION=v2.7.0-rc1-151-g81595ed4db20 -DCORE_CM7 -DHSE_VALUE=8000000 -DKERNEL -DMG_EXTERNAL_FUNCTION_log_access -DMG_EXTERNAL_FUNCTION_mg_cry_internal_impl -DNO_ALTERNATIVE_QUEUE -DNO_CACHING -DNO_CGI -DNO_FILES -DNO_FILESYSTEMS -DNO_SSL -DSTM32F767xx -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -DUSE_STACK_SIZE=0 -DUSE_WEBSOCKET -DZEPHYR_VERSION=\"2.7.0-rc1\" -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/include -I/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/../common/include -I/home/username/Projects/subseadisplay/zephyr/include -I/home/username/Projects/subseadisplay/zephyr/build/zephyr/include/generated -I/home/username/Projects/subseadisplay/zephyr/soc/arm/st_stm32/stm32f7 -I/home/username/Projects/subseadisplay/zephyr/lib/libc/newlib/include -I/home/username/Projects/subseadisplay/zephyr/drivers -I/home/username/Projects/subseadisplay/zephyr/soc/arm/st_stm32/common -I/home/username/Projects/subseadisplay/zephyr/subsys/net/l2 -I/home/username/Projects/subseadisplay/zephyr/subsys/net/lib/sockets/. -I/home/username/Projects/subseadisplay/zephyr/subsys/net/lib/dns/. -I/home/username/Projects/subseadisplay/modules/lib/civetweb/include -I/home/username/Projects/subseadisplay/modules/hal/cmsis/CMSIS/Core/Include -I/home/username/Projects/subseadisplay/modules/hal/stm32/stm32cube/stm32f7xx/soc -I/home/username/Projects/subseadisplay/modules/hal/stm32/stm32cube/stm32f7xx/drivers/include -I/home/username/Projects/subseadisplay/modules/hal/stm32/stm32cube/stm32f7xx/drivers/include/Legacy -I/home/username/Projects/subseadisplay/modules/hal/stm32/stm32cube/common_ll/include -I/home/username/Projects/subseadisplay/modules/lib/civetweb/src -I/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/src -Os -imacros /home/username/Projects/subseadisplay/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m7 -mthumb -mabi=aapcs -mfp16-format=ieee -imacros /home/username/Projects/subseadisplay/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/username/Projects/subseadisplay/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/username/Projects/subseadisplay=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj -MF modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj.d -o modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj -c /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:61,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_types.h:45:3: error: conflicting types for 'pthread_attr_t'
   45 | } pthread_attr_t;
      |   ^~~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:75:3: note: previous declaration of 'pthread_attr_t' was here
   75 | } pthread_attr_t;
      |   ^~~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:61,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_types.h:47:15: error: conflicting types for 'pthread_t'
   47 | typedef void *pthread_t;
      |               ^~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:32:20: note: previous declaration of 'pthread_t' was here
   32 | typedef __uint32_t pthread_t;            /* identify a thread */
      |                    ^~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:61,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_types.h:58:3: error: conflicting types for 'pthread_mutex_t'
   58 | } pthread_mutex_t;
      |   ^~~~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:154:20: note: previous declaration of 'pthread_mutex_t' was here
  154 | typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
      |                    ^~~~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:61,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_types.h:62:3: error: conflicting types for 'pthread_mutexattr_t'
   62 | } pthread_mutexattr_t;
      |   ^~~~~~~~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:169:3: note: previous declaration of 'pthread_mutexattr_t' was here
  169 | } pthread_mutexattr_t;
      |   ^~~~~~~~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:61,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_types.h:67:3: error: conflicting types for 'pthread_cond_t'
   67 | } pthread_cond_t;
      |   ^~~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:176:20: note: previous declaration of 'pthread_cond_t' was here
  176 | typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
      |                    ^~~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:61,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_types.h:70:3: error: conflicting types for 'pthread_condattr_t'
   70 | } pthread_condattr_t;
      |   ^~~~~~~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:186:3: note: previous declaration of 'pthread_condattr_t' was here
  186 | } pthread_condattr_t;         /* a condition attribute object */
      |   ^~~~~~~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:15,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/posix_sched.h:23:8: error: redefinition of 'struct sched_param'
   23 | struct sched_param {
      |        ^~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:23,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/sched.h:48:8: note: originally defined here
   48 | struct sched_param {
      |        ^~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:16,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/pthread_key.h:18:18: error: conflicting types for 'pthread_once_t'
   18 | typedef uint32_t pthread_once_t;
      |                  ^~~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:195:3: note: previous declaration of 'pthread_once_t' was here
  195 | } pthread_once_t;       /* dynamic package initialization */
      |   ^~~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:16,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/pthread_key.h:21:15: error: conflicting types for 'pthread_key_t'
   21 | typedef void *pthread_key_t;
      |               ^~~~~~~~~~~~~
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:190:20: note: previous declaration of 'pthread_key_t' was here
  190 | typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
      |                    ^~~~~~~~~~~~~
In file included from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:56: warning: "PTHREAD_CREATE_JOINABLE" redefined
   56 | #define PTHREAD_CREATE_JOINABLE     PTHREAD_JOINABLE
      | 
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:47: note: this is the location of the previous definition
   47 | #define PTHREAD_CREATE_JOINABLE  1
      | 
In file included from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:57: warning: "PTHREAD_CREATE_DETACHED" redefined
   57 | #define PTHREAD_CREATE_DETACHED     PTHREAD_DETACHED
      | 
In file included from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:223,
                 from /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/time.h:28,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/time.h:12,
                 from /home/username/Projects/subseadisplay/zephyr/include/posix/pthread.h:12,
                 from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:170:
/opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/_pthreadtypes.h:46: note: this is the location of the previous definition
   46 | #define PTHREAD_CREATE_DETACHED 0
      | 
In file included from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:168:
/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/../common/include/libc_extensions.h:26:5: error: expected ')' before '+' token
   26 | int iscntrl(int c);
      |     ^~~~~~~
/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/../common/include/libc_extensions.h:26:5: error: expected ')' before '[' token
   26 | int iscntrl(int c);
      |     ^~~~~~~
/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/../common/include/libc_extensions.h:26:5: error: expected ')' before '&' token
   26 | int iscntrl(int c);
      |     ^~~~~~~
In file included from /home/username/Projects/subseadisplay/modules/lib/civetweb/src/civetweb.c:172:
/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/../common/include/libc_extensions.h:42:5: error: expected identifier or '(' before 'int'
   42 | int ferror(FILE *stream);
      |     ^~~~~~
/home/username/Projects/subseadisplay/zephyr/samples/net/civetweb/websocket_server/../common/include/libc_extensions.h:42:5: error: expected ')' before '(' token
   42 | int ferror(FILE *stream);
      |     ^~~~~~
[161/199] Building C object modules/stm32/stm32cube/CMakeFiles/..__...stm32__stm32cube.dir/stm32f7xx/drivers/src/stm32f7xx_ll_utils.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /snap/bin/cmake --build /home/username/Projects/subseadisplay/zephyr/build

Environment (please complete the following information):
The build log above is from Ubuntu 20.04 with Zephyr SDK 0.13.1, but the same issue appears on Windows using GNU ARM Embedded 10-2020-q4-major.

@icsys-omh icsys-omh added the bug The issue is a bug, or the PR is fixing a bug label Oct 1, 2021
@stephanosio stephanosio changed the title samples/net/civetweb/websocket_server fails to build with CONFIG_NEWLIB_LIBC CivetWeb samples fail to build with CONFIG_NEWLIB_LIBC Oct 1, 2021
@stephanosio stephanosio added area: civetweb area: newlib Newlib C Standard Library known issue Known issue and removed bug The issue is a bug, or the PR is fixing a bug labels Oct 1, 2021
@stephanosio
Copy link
Member

This is a known issue and a very unfortunate limitation imposed by the status quo.

From #16683:

Using Newlib is not an option due to heavy conflicts with the POSIX layer (see #13787).

We will eventually address this issue by properly porting the newlib to the Zephyr (see zephyrproject-rtos/sdk-ng#350).

@cfriedt cfriedt added the Enhancement Changes/Updates/Additions to existing features label Oct 12, 2021
@gmarull
Copy link
Member

gmarull commented Aug 11, 2022

civetweb is no longer part of Zephyr, closing

@gmarull gmarull closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: civetweb area: newlib Newlib C Standard Library Enhancement Changes/Updates/Additions to existing features known issue Known issue
Projects
None yet
Development

No branches or pull requests

4 participants