embvm / embvm-core

Core components, subsystems, and utilities for the Embedded Virtual Machine
Other
44 stars 9 forks source link

embvm-core: pthread.h include error with WSL #6

Closed phillipjohnston closed 2 years ago

phillipjohnston commented 2 years ago

Need to investigate pthread argument application in embvm-core. Failing to build on WSL. Also, side note, why isn't the no-unknown-pragma warning being applied?

Source of report: https://github.com/embvm/embvm-project-skeleton/issues/1#issuecomment-1206669274

ninja: Entering directory `buildresults'
[22/393] Compiling C object subprojects/libmemory/src/libmemory_hosted_native.a.p/aligned_malloc.c.o
../subprojects/libmemory/src/aligned_malloc.c:12: warning: ignoring #pragma mark  [-Wunknown-pragmas]
   12 | #pragma mark - Definitions -
      | 
../subprojects/libmemory/src/aligned_malloc.c:35: warning: ignoring #pragma mark  [-Wunknown-pragmas]
   35 | #pragma mark - APIs -
      | 
[294/393] Compiling C++ object src/core/libcore.a.p/rtos_libcpp_threading.cpp.o
FAILED: src/core/libcore.a.p/rtos_libcpp_threading.cpp.o 
c++ -Isrc/core/libcore.a.p -Isrc/core -I../src/core -Isrc/utilities -I../src/utilities -Isrc/subsystems -I../src/subsystems -I../src/etl -I../subprojects/gsl-lite/include -Isubprojects/libcpp/include/c++ -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -std=c++17 -O2 -Wold-style-cast -Wnon-virtual-dtor -Wctor-dtor-privacy -Woverloaded-virtual -Wnoexcept -Wstrict-null-sentinel -Wuseless-cast -Wzero-as-null-pointer-constant -Wextra-semi -fno-rtti -fno-exceptions -fno-unwind-tables -fdiagnostics-show-option -ffunction-sections -fdata-sections -fdevirtualize -Wno-unknown-pragmas -Wno-padded -Wfloat-equal -Wconversion -Wlogical-op -Wundef -Wredundant-decls -Wshadow -Wstrict-overflow=2 -Wwrite-strings -Wpointer-arith -Wcast-qual -Wformat=2 -Wformat-truncation -Wmissing-include-dirs -Wcast-align -Wswitch-enum -Wsign-conversion -Wdisabled-optimization -Winvalid-pch -Wmissing-declarations -Wdouble-promotion -Wshadow -Wtrampolines -Wvector-operation-performance -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wcast-align=strict -fno-builtin -Wno-pedantic -fPIC -DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1 -DNO_ERRNO -DIFNAN_CHECK -DGDTOA_NO_ASSERT -DNO_FENV_H -nostdinc -fno-builtin -nostdinc++ -D_GNU_SOURCE -D_LIBCPP_FRAMEWORK_FORCE_PTHREAD -DDEBUG_ASSERT_NO_STDIO -Dgsl_CONFIG_DEFAULTS_VERSION=1 -Dgsl_CONFIG_NOT_NULL_EXPLICIT_CTOR=0 -isystem../subprojects/libc/printf/src -isystem../subprojects/libc/printf/src/printf -isystem../subprojects/libc/openlibm/src -isystem../subprojects/libc/openlibm/include -isystem../subprojects/libc/src/gdtoa/include -isystem../subprojects/libcpp/include/c++ -isystemsubprojects/libcpp/include/c++ -isystem../subprojects/libcpp/include/c++abi -isystemsubprojects/libcpp/include/c++abi -isystem../subprojects/libc/arch/x86_64/include -isystem../subprojects/libc/include -isystem../subprojects/etl/include -isystem../subprojects/libcpp/extensions -MD -MQ src/core/libcore.a.p/rtos_libcpp_threading.cpp.o -MF src/core/libcore.a.p/rtos_libcpp_threading.cpp.o.d -o src/core/libcore.a.p/rtos_libcpp_threading.cpp.o -c ../src/core/rtos/libcpp_threading.cpp
In file included from ../src/core/rtos/libcpp_threading.cpp:11:
subprojects/libcpp/include/c++/__external_threading:15:10: fatal error: pthread.h: No such file or directory
   15 | #include <pthread.h>
      |          ^~~~~~~~~~~
compilation terminated.
[297/393] Compiling C++ object src/core/libcore.a.p/driver_internal_basic_display.cpp.o
In file included from ../src/core/driver/internal/basic_display.cpp:4:
../src/core/driver/basic_display.hpp: In member function ‘void embvm::basicDisplay::lineH(embvm::basicDisplay::coord_t, embvm::basicDisplay::coord_t, uint8_t, embvm::basicDisplay::color, embvm::basicDisplay::mode)’:
../src/core/driver/basic_display.hpp:244:16: warning: conversion from ‘int’ to ‘embvm::basicDisplay::coord_t’ {aka ‘unsigned char’} may change value [-Wconversion]
  244 |   line(x, y, x + width, y, c, m);
      |              ~~^~~~~~~
../src/core/driver/basic_display.hpp: In member function ‘void embvm::basicDisplay::lineV(embvm::basicDisplay::coord_t, embvm::basicDisplay::coord_t, uint8_t, embvm::basicDisplay::color, embvm::basicDisplay::mode)’:
../src/core/driver/basic_display.hpp:276:19: warning: conversion from ‘int’ to ‘embvm::basicDisplay::coord_t’ {aka ‘unsigned char’} may change value [-Wconversion]
  276 |   line(x, y, x, y + height, c, m);
      |                 ~~^~~~~~~~
[303/393] Compiling C++ object src/core/libcore_native.a.p/driver_internal_basic_display.cpp.o
In file included from ../src/core/driver/internal/basic_display.cpp:4:
../src/core/driver/basic_display.hpp: In member function ‘void embvm::basicDisplay::lineH(embvm::basicDisplay::coord_t, embvm::basicDisplay::coord_t, uint8_t, embvm::basicDisplay::color, embvm::basicDisplay::mode)’:
../src/core/driver/basic_display.hpp:244:16: warning: conversion from ‘int’ to ‘embvm::basicDisplay::coord_t’ {aka ‘unsigned char’} may change value [-Wconversion]
  244 |   line(x, y, x + width, y, c, m);
      |              ~~^~~~~~~
../src/core/driver/basic_display.hpp: In member function ‘void embvm::basicDisplay::lineV(embvm::basicDisplay::coord_t, embvm::basicDisplay::coord_t, uint8_t, embvm::basicDisplay::color, embvm::basicDisplay::mode)’:
../src/core/driver/basic_display.hpp:276:19: warning: conversion from ‘int’ to ‘embvm::basicDisplay::coord_t’ {aka ‘unsigned char’} may change value [-Wconversion]
  276 |   line(x, y, x, y + height, c, m);
      |                 ~~^~~~~~~~
[311/393] Compiling C++ object src/core/libcore.a.p/driver_internal_i2c.cpp.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:55: default] Error 1
ragiton:embvm-core$
benner commented 2 years ago

I've got same/similar issue on Ubuntu 22.04:

[296/393] Compiling C++ object src/core/libcore.a.p/rtos_libcpp_threading.cpp.o
FAILED: src/core/libcore.a.p/rtos_libcpp_threading.cpp.o 
ccache c++ -Isrc/core/libcore.a.p -Isrc/core -I../src/core -Isrc/utilities -I../src/utilities -Isrc/subsystems -I../src/subsystems -I../src/etl -I../subprojects/gsl-lite/include -Isubprojects/libcpp/include/c++ -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -std=c++17 -O2 -Wold-style-cast -Wnon-virtual-dtor -Wctor-dtor-privacy -Woverloaded-virtual -Wnoexcept -Wstrict-null-sentinel -Wuseless-cast -Wzero-as-null-pointer-constant -Wextra-semi -fno-rtti -fno-exceptions -fno-unwind-tables -fdiagnostics-show-option -ffunction-sections -fdata-sections -fdevirtualize -Wno-unknown-pragmas -Wno-padded -Wfloat-equal -Wconversion -Wlogical-op -Wundef -Wredundant-decls -Wshadow -Wstrict-overflow=2 -Wwrite-strings -Wpointer-arith -Wcast-qual -Wformat=2 -Wformat-truncation -Wmissing-include-dirs -Wcast-align -Wswitch-enum -Wsign-conversion -Wdisabled-optimization -Winvalid-pch -Wmissing-declarations -Wdouble-promotion -Wshadow -Wtrampolines -Wvector-operation-performance -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wcast-align=strict -fno-builtin -Wno-pedantic -fPIC -DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1 -DNO_ERRNO -DIFNAN_CHECK -DGDTOA_NO_ASSERT -DNO_FENV_H -nostdinc -fno-builtin -nostdinc++ -D_GNU_SOURCE -D_LIBCPP_FRAMEWORK_FORCE_PTHREAD -DDEBUG_ASSERT_NO_STDIO -Dgsl_CONFIG_DEFAULTS_VERSION=1 -Dgsl_CONFIG_NOT_NULL_EXPLICIT_CTOR=0 -isystem../subprojects/libc/printf/src -isystem../subprojects/libc/printf/src/printf -isystem../subprojects/libc/openlibm/src -isystem../subprojects/libc/openlibm/include -isystem../subprojects/libc/src/gdtoa/include -isystem../subprojects/libcpp/include/c++ -isystemsubprojects/libcpp/include/c++ -isystem../subprojects/libcpp/include/c++abi -isystemsubprojects/libcpp/include/c++abi -isystem../subprojects/libc/arch/x86_64/include -isystem../subprojects/libc/include -isystem../subprojects/etl/include -isystem../subprojects/libcpp/extensions -MD -MQ src/core/libcore.a.p/rtos_libcpp_threading.cpp.o -MF src/core/libcore.a.p/rtos_libcpp_threading.cpp.o.d -o src/core/libcore.a.p/rtos_libcpp_threading.cpp.o -c ../src/core/rtos/libcpp_threading.cpp
In file included from ../src/core/rtos/libcpp_threading.cpp:11:
subprojects/libcpp/include/c++/__external_threading:15:10: fatal error: pthread.h: No such file or directory
   15 | #include <pthread.h>
      |          ^~~~~~~~~~~
compilation terminated.
[317/393] Compiling C++ object src/core/libcore_native.a.p/driver_internal_i2c.cpp.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:55: default] Error 1
zsh: exit 2     make
phillipjohnston commented 2 years ago

Thanks @benner for the confirmation!

We are using posix_dep = dependency('threads'), but this does not appear to be applying the -pthread compiler argument like I expected (upon looking at compile_commands.json). So this appears to be accidentally working for me. I'll get it addressed.

edit: Looking through Meson's code, this might just be a MacOS specific case. But looking at the error messages, that flag still isn't present. Something is up.

phillipjohnston commented 2 years ago

Ok, dug into this more with a Linux VM, the real problem is elsewhere in the build architecture. There will be a libcpp change to address this, but I still need to figure out the proper approach.

phillipjohnston commented 2 years ago

https://github.com/embeddedartistry/libcpp/pull/52 will address the pthread.h failure. Now I see that the tests are segfaulting on Linux, so there is more work ahead for Linux (#7). I'll look into that on Monday.

phillipjohnston commented 2 years ago

https://github.com/embeddedartistry/libcpp/pull/52 has been merged. You will need to update the subproject dependency to pick up the changes.