eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.36k stars 613 forks source link

A trick to compile mraa with Node 15.0.1 and Swig 4.1.0 #1040

Open g-vidal opened 3 years ago

g-vidal commented 3 years ago

This is a followup to #969 and remarks from @Propanu and @nxhack , it is not a solution but just a trick to reach a successfull compilation. If anybody with the necessary competences can transform this contribution into a true solution it will be a great step... The changes made are validated by the compiler but I am not sure at all that they are correct or they will yield a totally operational library. First of all start the compilation with the last master then apply the following patch on the file mraajsJAVASCRIPT_wrap.cxx and restart compilation.

--- mraajsJAVASCRIPT_wrap.cxx
+++ mraajsJAVASCRIPT_wrap.cxx
@@ -782,7 +782,7 @@
 #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803)
 #define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len)
 #else
-#define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len)
+#define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::NewStringType::kNormal, len).ToLocalChecked()
 #endif

 #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
@@ -823,7 +823,7 @@
 #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
 #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
 #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
-#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str)
+#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str).ToLocalChecked()
 #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym)
 #endif

@@ -884,7 +884,7 @@
 #define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
 #define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
 #define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
-#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
+#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()->GetIsolate())
 #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len)
 #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent())
 #endif
@@ -1134,7 +1134,7 @@
 #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
   cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
 #else
-  cdata->handle.MarkIndependent();
+  cdata->handle.SetWeak();
 #endif

 }
@@ -1184,8 +1184,8 @@
   }
 #endif

-//  v8::Handle<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
-  v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
+   v8::Local<v8::ObjectTemplate> result_templ = class_templ->PrototypeTemplate();
+   v8::Local<v8::Object> result = result_templ->NewInstance(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
   SWIGV8_SetPrivateData(result, ptr, info, flags);

   SWIGV8_ESCAPE(result);
@@ -1409,7 +1409,7 @@
 #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
   cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
 #else
-  cdata->handle.MarkIndependent();
+  cdata->handle.SetWeak();
 #endif

   SWIGV8_ESCAPE(obj);
@@ -1441,7 +1441,7 @@
 #else  
   v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(result);
 #endif
-  arr->Set(arr->Length(), obj);
+  arr->Set(SWIGV8_CURRENT_CONTEXT(),arr->Length(), obj);

   SWIGV8_ESCAPE(arr);
 }
@@ -1473,16 +1473,16 @@
     SWIGV8_HANDLESCOPE_ESC();

     v8::Local<v8::FunctionTemplate> class_templ = SWIGV8_FUNCTEMPLATE_NEW_VOID();
-    class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol));
+    class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol).ToLocalChecked());

     v8::Handle<v8::ObjectTemplate> inst_templ = class_templ->InstanceTemplate();
     inst_templ->SetInternalFieldCount(1);

     v8::Handle<v8::ObjectTemplate> equals_templ = class_templ->PrototypeTemplate();
-    equals_templ->Set(SWIGV8_SYMBOL_NEW("equals"), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals));
+   equals_templ->Set(SWIGV8_SYMBOL_NEW("equals").ToLocalChecked(), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals), v8::PropertyAttribute::None);

     v8::Handle<v8::ObjectTemplate> cptr_templ = class_templ->PrototypeTemplate();
-    cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr"), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr));
+   cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr").ToLocalChecked(), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr), v8::PropertyAttribute::None);

     SWIGV8_ESCAPE(class_templ);
 }
@@ -1493,7 +1493,7 @@
 SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
   SwigV8FunctionCallback _func) {
     v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
-    proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func));
+   proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol).ToLocalChecked(), SWIGV8_FUNCTEMPLATE_NEW(_func), v8::PropertyAttribute::None);
 }

 /**
@@ -1502,7 +1502,7 @@
 SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
   SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
   v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
-  proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
+  proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol).ToLocalChecked(), getter, setter);
 }

 /**
@@ -1510,7 +1510,7 @@
  */
 SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
   const SwigV8FunctionCallback& _func) {
-  obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction());
+  obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol).ToLocalChecked(), SWIGV8_FUNCTEMPLATE_NEW(_func)->NewRemoteInstance().ToLocalChecked());
 }

 /**
@@ -1521,7 +1521,7 @@
 #if (V8_MAJOR_VERSION-0) < 5
   obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
 #else
-  obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter);
+  obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol).ToLocalChecked(), getter, setter);
 #endif
 }

@@ -12392,50 +12392,50 @@
 v8::Handle<v8::FunctionTemplate> _exports_uint8Array_class_0 = SWIGV8_CreateClassTemplate("uint8Array");
 _exports_uint8Array_class_0->SetCallHandler(_wrap_new_uint8Array);
 _exports_uint8Array_class_0->Inherit(_exports_uint8Array_class);
-_exports_uint8Array_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_uint8Array_obj = _exports_uint8Array_class_0->GetFunction();
+_exports_uint8Array_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_uint8Array_obj = _exports_uint8Array_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: Gpio (_exports_Gpio) */
 v8::Handle<v8::FunctionTemplate> _exports_Gpio_class_0 = SWIGV8_CreateClassTemplate("Gpio");
 _exports_Gpio_class_0->SetCallHandler(_wrap_new_Gpio);
 _exports_Gpio_class_0->Inherit(_exports_Gpio_class);
-_exports_Gpio_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_Gpio_obj = _exports_Gpio_class_0->GetFunction();
+_exports_Gpio_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_Gpio_obj = _exports_Gpio_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: I2c (_exports_I2c) */
 v8::Handle<v8::FunctionTemplate> _exports_I2c_class_0 = SWIGV8_CreateClassTemplate("I2c");
 _exports_I2c_class_0->SetCallHandler(_wrap_new_I2c);
 _exports_I2c_class_0->Inherit(_exports_I2c_class);
-_exports_I2c_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_I2c_obj = _exports_I2c_class_0->GetFunction();
+_exports_I2c_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_I2c_obj = _exports_I2c_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: Pwm (_exports_Pwm) */
 v8::Handle<v8::FunctionTemplate> _exports_Pwm_class_0 = SWIGV8_CreateClassTemplate("Pwm");
 _exports_Pwm_class_0->SetCallHandler(_wrap_new_Pwm);
 _exports_Pwm_class_0->Inherit(_exports_Pwm_class);
-_exports_Pwm_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_Pwm_obj = _exports_Pwm_class_0->GetFunction();
+_exports_Pwm_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_Pwm_obj = _exports_Pwm_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: Spi (_exports_Spi) */
 v8::Handle<v8::FunctionTemplate> _exports_Spi_class_0 = SWIGV8_CreateClassTemplate("Spi");
 _exports_Spi_class_0->SetCallHandler(_wrap_new_Spi);
 _exports_Spi_class_0->Inherit(_exports_Spi_class);
-_exports_Spi_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_Spi_obj = _exports_Spi_class_0->GetFunction();
+_exports_Spi_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_Spi_obj = _exports_Spi_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: Aio (_exports_Aio) */
 v8::Handle<v8::FunctionTemplate> _exports_Aio_class_0 = SWIGV8_CreateClassTemplate("Aio");
 _exports_Aio_class_0->SetCallHandler(_wrap_new_Aio);
 _exports_Aio_class_0->Inherit(_exports_Aio_class);
-_exports_Aio_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_Aio_obj = _exports_Aio_class_0->GetFunction();
+_exports_Aio_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_Aio_obj = _exports_Aio_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: Uart (_exports_Uart) */
 v8::Handle<v8::FunctionTemplate> _exports_Uart_class_0 = SWIGV8_CreateClassTemplate("Uart");
 _exports_Uart_class_0->SetCallHandler(_wrap_new_Uart);
 _exports_Uart_class_0->Inherit(_exports_Uart_class);
-_exports_Uart_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_Uart_obj = _exports_Uart_class_0->GetFunction();
+_exports_Uart_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_Uart_obj = _exports_Uart_class_0->NewRemoteInstance().ToLocalChecked();
 /* Class: Led (_exports_Led) */
 v8::Handle<v8::FunctionTemplate> _exports_Led_class_0 = SWIGV8_CreateClassTemplate("Led");
 _exports_Led_class_0->SetCallHandler(_wrap_new_Led);
 _exports_Led_class_0->Inherit(_exports_Led_class);
-_exports_Led_class_0->SetHiddenPrototype(true);
-v8::Handle<v8::Object> _exports_Led_obj = _exports_Led_class_0->GetFunction();
+_exports_Led_class_0->ReadOnlyPrototype();
+v8::Handle<v8::Object> _exports_Led_obj = _exports_Led_class_0->NewRemoteInstance().ToLocalChecked();

   /* add static class functions and variables */
@@ -12482,14 +12482,14 @@

   /* register classes */
-  exports_obj->Set(SWIGV8_SYMBOL_NEW("uint8Array"), _exports_uint8Array_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("Gpio"), _exports_Gpio_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("I2c"), _exports_I2c_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("Pwm"), _exports_Pwm_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("Spi"), _exports_Spi_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("Aio"), _exports_Aio_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("Uart"), _exports_Uart_obj);
-exports_obj->Set(SWIGV8_SYMBOL_NEW("Led"), _exports_Led_obj);
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_uint8Array_obj, SWIGV8_SYMBOL_NEW("uint8Array").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_Gpio_obj, SWIGV8_SYMBOL_NEW("Gpio").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_I2c_obj, SWIGV8_SYMBOL_NEW("I2c").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_Pwm_obj, SWIGV8_SYMBOL_NEW("Pwm").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_Spi_obj, SWIGV8_SYMBOL_NEW("Spi").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_Aio_obj, SWIGV8_SYMBOL_NEW("Aio").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_Uart_obj, SWIGV8_SYMBOL_NEW("Uart").ToLocalChecked());
+exports_obj->Set(SWIGV8_CURRENT_CONTEXT(), _exports_Led_obj, SWIGV8_SYMBOL_NEW("Led").ToLocalChecked());

   /* create and register namespace objects */
nxhack commented 3 years ago

@g-vidal

After a lot of testing, I found out that the main reason is that the handling of "SWIG_V8_VERSION" in swig is not consistent.

As a workaround, you can apply the following patch to swig.

--- a/Lib/javascript/v8/javascriptruntime.swg
+++ b/Lib/javascript/v8/javascriptruntime.swg
@@ -57,9 +57,10 @@
 #include <v8.h>

 #if defined(V8_MAJOR_VERSION) && defined(V8_MINOR_VERSION)
-#undef SWIG_V8_VERSION
+#ifndef SWIG_V8_VERSION
 #define SWIG_V8_VERSION (V8_MAJOR_VERSION * 256 + V8_MINOR_VERSION)
 #endif
+#endif

 #include <errno.h>
 #include <limits.h>
nxhack commented 3 years ago

libmraa generates "SWIG_V8_VERSION" in this way.

https://github.com/eclipse/mraa/blob/master/src/javascript/binding.gyp.cmake#L14 https://github.com/eclipse/mraa/blob/master/src/javascript/binding.gyp.cmake#L37

However, there is a strange replacement in swig's javascriptruntime.swg.

https://github.com/swig/swig/blob/master/Lib/javascript/v8/javascriptruntime.swg#L59-L62

I think there is inconsistency on SWIG.

g-vidal commented 3 years ago

Hi, Thanks for the trick it works ... almost ! I am using to raspberry Pi3, the mraa version downloaded today (2021-05-30) swig 4.1.0 from git master node version v16.2.0 ; it fails with error :

[ 38%] Building CXX object src/javascript/CMakeFiles/mraajs.dir/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx.o
In file included from /home/ens-ife/Logiciels/IoT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1822:
/home/ens-ife/Logiciels/IoT/mraa/api/mraa/gpio.hpp: In static member function ‘static void mraa::Gpio::v8isr(uv_work_t*, int)’:
/home/ens-ife/Logiciels/IoT/mraa/api/mraa/gpio.hpp:179:63: error: no matching function for call to ‘v8::Function::Call(v8::Local<v8::Object>, int&, v8::Local<v8::Value> [1])’
  179 |         f->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);

If I overcome this one I get a new one :

[ 36%] Building CXX object src/javascript/CMakeFiles/mraajs.dir/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx.o
/usr/local/include/node/v8.h: In instantiation of ‘v8::Local<T>::Local(v8::Local<S>) [with S = v8::Object; T = v8::Context]’:
/home/ens-ife/Logiciels/IoT/mraa/api/mraa/gpio.hpp:182:69:   required from here
/usr/local/include/node/v8.h:210:42: error: static assertion failed: type check
  210 |     static_assert(std::is_base_of<T, S>::value, "type check");
      |                                          ^~~~~

I'll go to #1064 to comment Maybe this one could be closed ????

nxhack commented 3 years ago

@g-vidal

I don't have a development environment for raspberry Pi, so this is just for looks.

Do I have the right version of gcc? node v16.x requires gcc and g++ version 8.3 or higher.

nxhack commented 3 years ago

@g-vidal

I created a development environment on a Raspberry Pi 3B with raspbian buster and tested it.

The raspbian buster, of course, contains gcc 8.3.

There seems to be a flaw in the patch.

Until it is fixed, please build cmake with "-DCMAKE_CXX_STANDARD=14".

I tested it again and it built without any problems. So I guess your problem is the gcc version.

nxhack commented 3 years ago

CMAKE config

cmake .. -DENABLEEXAMPLES=0 \
    -DBUILDSWIGNODE=ON \
    -DSWIG_EXECUTABLE=/usr/local/bin/swig \
    -DV8_ROOT_DIR=/usr/local/include/node \
    -DNODE_ROOT_DIR=/usr/local/include/node \
    -DPYTHON2LIBS_FOUND=FALSE \
    -DPYTHON2INTERP_FOUND=FALSE \
    -DFIRMATA=ON

cmake log

-- The C compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAS_C__Wall
-- Performing Test HAS_C__Wall - Success
-- Performing Test HAS_C__Werror_main
-- Performing Test HAS_C__Werror_main - Success
-- Performing Test HAS_C__Wformat
-- Performing Test HAS_C__Wformat - Success
-- Performing Test HAS_C__Wmain
-- Performing Test HAS_C__Wmain - Success
-- Performing Test HAS_C__Wuninitialized
-- Performing Test HAS_C__Wuninitialized - Success
-- Performing Test HAS_C__Winit_self
-- Performing Test HAS_C__Winit_self - Success
-- Performing Test HAS_C__Werror_implicit
-- Performing Test HAS_C__Werror_implicit - Success
-- Performing Test HAS_C__Werror_missing_parameter_type
-- Performing Test HAS_C__Werror_missing_parameter_type - Success
-- Performing Test HAS_CXX__Wall
-- Performing Test HAS_CXX__Wall - Success
-- Performing Test HAS_CXX__Werror_main
-- Performing Test HAS_CXX__Werror_main - Success
-- Performing Test HAS_CXX__Wformat
-- Performing Test HAS_CXX__Wformat - Success
-- Performing Test HAS_CXX__Wmain
-- Performing Test HAS_CXX__Wmain - Success
-- Performing Test HAS_CXX__Wuninitialized
-- Performing Test HAS_CXX__Wuninitialized - Success
-- Performing Test HAS_CXX__Winit_self
-- Performing Test HAS_CXX__Winit_self - Success
-- Performing Test HAS_CXX__Wnon_virtual_dtor
-- Performing Test HAS_CXX__Wnon_virtual_dtor - Success
-- Performing Test HAS_CXX__Woverloaded_virtual
-- Performing Test HAS_CXX__Woverloaded_virtual - Success
-- Performing Test HAS_CXX__Wreorder
-- Performing Test HAS_CXX__Wreorder - Success
-- INFO - libmraa Version v2.2.0-3-g833bac5
-- INFO - cmake Version 3.16.3
-- INFO - Target arch is armv7l
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.16", minimum required is "2.7") 
-- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (found suitable exact version "2.7.16") 
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.7.3", minimum required is "3") 
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is exact version "3.7.3")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'distutils.sysconfig'
-- INFO - Adding firmata backend support
-- INFO - Adding onewire backend support
-- INFO - Adding support for platform ALL
-- INFO - Adding support for all platforms
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
INFO - Adding ARM platforms
CMake Warning at src/CMakeLists.txt:219 (message):
  Enabled JSONPLAT but JSON-C library not found: Ignoring JSONPLAT

-- Found SWIG: /usr/local/bin/swig (found version "4.1.0") 
-- INFO - NODE_ROOT_DIR is /usr/local/include/node
-- Found Nodejs: /usr/local/bin/node (found version "16.2.0") 
-- Found v8: /usr/local/include/node/v8.h (found version "9.0.257.25-node.16")
CMake Warning (dev) at /usr/share/cmake-3.16/Modules/UseSWIG.cmake:607 (message):
  Policy CMP0078 is not set: UseSWIG generates standard target names.  Run
  "cmake --help-policy CMP0078" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

Call Stack (most recent call first):
  src/javascript/CMakeLists.txt:27 (swig_add_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/share/cmake-3.16/Modules/UseSWIG.cmake:460 (message):
  Policy CMP0086 is not set: UseSWIG honors SWIG_MODULE_NAME via -module
  flag.  Run "cmake --help-policy CMP0086" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/UseSWIG.cmake:702 (SWIG_ADD_SOURCE_TO_MODULE)
  src/javascript/CMakeLists.txt:27 (swig_add_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- INFO - swig Version 4.1.0
-- INFO - CXX compiler Version GNU 8.3.0
-- INFO - Using V8 version > 3 so requiring C++11 compiler
-- INFO - install NODE modules to /usr/local/include/node/lib/node_modules/mraa/
-- Could not run tests since python interpreter or python bindings not built
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) 
-- Install Google Test to enable additional unit testing
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/GIT/mraa/build

build log

Scanning dependencies of target mraa
[  2%] Building C object src/CMakeFiles/mraa.dir/mraa.c.o
[  5%] Building C object src/CMakeFiles/mraa.dir/gpio/gpio.c.o
[  8%] Building C object src/CMakeFiles/mraa.dir/gpio/gpio_chardev.c.o
[ 11%] Building C object src/CMakeFiles/mraa.dir/i2c/i2c.c.o
[ 14%] Building C object src/CMakeFiles/mraa.dir/pwm/pwm.c.o
[ 17%] Building C object src/CMakeFiles/mraa.dir/spi/spi.c.o
[ 20%] Building C object src/CMakeFiles/mraa.dir/aio/aio.c.o
[ 22%] Building C object src/CMakeFiles/mraa.dir/uart/uart.c.o
[ 25%] Building C object src/CMakeFiles/mraa.dir/led/led.c.o
/home/pi/GIT/mraa/src/led/led.c: In function ‘mraa_led_init’:
/home/pi/GIT/mraa/src/led/led.c:148:59: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
     strncpy(dev->led_path, (const char*) directory, sizeof(directory));
                                                           ^
/home/pi/GIT/mraa/src/led/led.c: In function ‘mraa_led_init_raw’:
/home/pi/GIT/mraa/src/led/led.c:179:59: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
     strncpy(dev->led_path, (const char*) directory, sizeof(directory));
                                                           ^
/home/pi/GIT/mraa/src/led/led.c: In function ‘mraa_led_get_trigfd’:
/home/pi/GIT/mraa/src/led/led.c:29:33: warning: ‘%s’ directive output may be truncated writing 7 bytes into a region of size between 0 and 63 [-Wformat-truncation=]
     snprintf(buf, MAX_SIZE, "%s/%s", dev->led_path, "trigger");
                                 ^~                  ~~~~~~~~~
/home/pi/GIT/mraa/src/led/led.c:29:5: note: ‘snprintf’ output between 9 and 72 bytes into a destination of size 64
     snprintf(buf, MAX_SIZE, "%s/%s", dev->led_path, "trigger");
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/led/led.c: In function ‘mraa_led_get_brightfd’:
/home/pi/GIT/mraa/src/led/led.c:44:33: warning: ‘%s’ directive output may be truncated writing 10 bytes into a region of size between 0 and 63 [-Wformat-truncation=]
     snprintf(buf, MAX_SIZE, "%s/%s", dev->led_path, "brightness");
                                 ^~                  ~~~~~~~~~~~~
/home/pi/GIT/mraa/src/led/led.c:44:5: note: ‘snprintf’ output between 12 and 75 bytes into a destination of size 64
     snprintf(buf, MAX_SIZE, "%s/%s", dev->led_path, "brightness");
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/led/led.c: In function ‘mraa_led_get_maxbrightfd’:
/home/pi/GIT/mraa/src/led/led.c:59:33: warning: ‘%s’ directive output may be truncated writing 14 bytes into a region of size between 0 and 63 [-Wformat-truncation=]
     snprintf(buf, MAX_SIZE, "%s/%s", dev->led_path, "max_brightness");
                                 ^~                  ~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/led/led.c:59:5: note: ‘snprintf’ output between 16 and 79 bytes into a destination of size 64
     snprintf(buf, MAX_SIZE, "%s/%s", dev->led_path, "max_brightness");
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 28%] Building C object src/CMakeFiles/mraa.dir/initio/initio.c.o
[ 31%] Building C object src/CMakeFiles/mraa.dir/grovepi/grovepi.c.o
[ 34%] Building C object src/CMakeFiles/mraa.dir/firmata/firmata.c.o
[ 37%] Building C object src/CMakeFiles/mraa.dir/firmata/firmata_mraa.c.o
[ 40%] Building C object src/CMakeFiles/mraa.dir/uart_ow/uart_ow.c.o
[ 42%] Building C object src/CMakeFiles/mraa.dir/iio/iio.c.o
/home/pi/GIT/mraa/src/iio/iio.c: In function ‘mraa_iio_get_channel_data’:
/home/pi/GIT/mraa/src/iio/iio.c:165:44: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
             syslog(LOG_ERR, "iio: Channel %d with channel bytes value <= 0");
                                           ~^
/home/pi/GIT/mraa/src/iio/iio.c:23:26: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 71 and 81 [-Wformat-truncation=]
 #define IIO_SYSFS_DEVICE "/sys/bus/iio/devices/" IIO_DEVICE
                          ^~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c:96:37: note: in expansion of macro ‘IIO_SYSFS_DEVICE’
             snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_SCAN_ELEM "/%s", dev->num, ent->d_name);
                                     ^~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c:595:80: note: format string is defined here
                 snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_SCAN_ELEM "/%s", dev->num, ent->d_name);
                                                                                ^~
/home/pi/GIT/mraa/src/iio/iio.c:96:13: note: ‘snprintf’ output between 48 and 313 bytes into a destination of size 128
             snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_SCAN_ELEM "/%s", dev->num, ent->d_name);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c: In function ‘mraa_iio_get_event_data’:
/home/pi/GIT/mraa/src/iio/iio.c:23:26: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 78 and 88 [-Wformat-truncation=]
 #define IIO_SYSFS_DEVICE "/sys/bus/iio/devices/" IIO_DEVICE
                          ^~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c:399:41: note: in expansion of macro ‘IIO_SYSFS_DEVICE’
                 snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_EVENTS "/%s", dev->num, ent->d_name);
                                         ^~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c:21:31: note: format string is defined here
 #define IIO_SCAN_ELEM "scan_elements"
                               ^~
/home/pi/GIT/mraa/src/iio/iio.c:399:17: note: ‘snprintf’ output between 41 and 306 bytes into a destination of size 128
                 snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_EVENTS "/%s", dev->num, ent->d_name);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c: In function ‘mraa_iio_update_channels’:
/home/pi/GIT/mraa/src/iio/iio.c:23:26: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 71 and 81 [-Wformat-truncation=]
 #define IIO_SYSFS_DEVICE "/sys/bus/iio/devices/" IIO_DEVICE
                          ^~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c:595:41: note: in expansion of macro ‘IIO_SYSFS_DEVICE’
                 snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_SCAN_ELEM "/%s", dev->num, ent->d_name);
                                         ^~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/iio/iio.c:595:80: note: format string is defined here
                 snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_SCAN_ELEM "/%s", dev->num, ent->d_name);
                                                                                ^~
/home/pi/GIT/mraa/src/iio/iio.c:595:17: note: ‘snprintf’ output between 48 and 313 bytes into a destination of size 128
                 snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_SCAN_ELEM "/%s", dev->num, ent->d_name);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 45%] Building C object src/CMakeFiles/mraa.dir/arm/arm.c.o
[ 48%] Building C object src/CMakeFiles/mraa.dir/arm/96boards.c.o
[ 51%] Building C object src/CMakeFiles/mraa.dir/arm/raspberry_pi.c.o
/home/pi/GIT/mraa/src/arm/raspberry_pi.c: In function ‘mraa_raspberry_pi’:
/home/pi/GIT/mraa/src/arm/raspberry_pi.c:644:49: warning: ‘%s’ directive writing up to 255 bytes into a region of size 48 [-Wformat-overflow=]
             sprintf(chip_path, "/sys/class/gpio/%s/label", child->d_name);
                                                 ^~
/home/pi/GIT/mraa/src/arm/raspberry_pi.c:644:13: note: ‘sprintf’ output between 23 and 278 bytes into a destination of size 64
             sprintf(chip_path, "/sys/class/gpio/%s/label", child->d_name);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 54%] Building C object src/CMakeFiles/mraa.dir/arm/beaglebone.c.o
/home/pi/GIT/mraa/src/arm/beaglebone.c: In function ‘mraa_beaglebone’:
/home/pi/GIT/mraa/src/arm/beaglebone.c:363:18: warning: variable ‘uart3_enabled’ set but not used [-Wunused-but-set-variable]
     unsigned int uart3_enabled = 0;
                  ^~~~~~~~~~~~~
/home/pi/GIT/mraa/src/arm/beaglebone.c: In function ‘set_pin_mode’:
/home/pi/GIT/mraa/src/arm/beaglebone.c:170:51: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 60 [-Wformat-truncation=]
     snprintf(pinmux_dir, sizeof(pinmux_dir), "ocp:%s_pinmux", pin_str);
                                                   ^~          ~~~~~~~
/home/pi/GIT/mraa/src/arm/beaglebone.c:170:5: note: ‘snprintf’ output between 12 and 75 bytes into a destination of size 64
     snprintf(pinmux_dir, sizeof(pinmux_dir), "ocp:%s_pinmux", pin_str);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/arm/beaglebone.c:171:38: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 37 [-Wformat-truncation=]
     snprintf(path, sizeof(path), "%s/%s/state", PLATFORM_OCP_PATH, pinmux_dir);
                                      ^~                            ~~~~~~~~~~
/home/pi/GIT/mraa/src/arm/beaglebone.c:171:5: note: ‘snprintf’ output between 34 and 97 bytes into a destination of size 64
     snprintf(path, sizeof(path), "%s/%s/state", PLATFORM_OCP_PATH, pinmux_dir);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/src/arm/beaglebone.c: In function ‘mraa_beaglebone_pwm_init_replace’:
/home/pi/GIT/mraa/src/arm/beaglebone.c:323:32: warning: ‘/export’ directive writing 7 bytes into a region of size between 1 and 64 [-Wformat-overflow=]
         sprintf(exportpath, "%s/export", chippath);
                                ^~~~~~~
/home/pi/GIT/mraa/src/arm/beaglebone.c:323:9: note: ‘sprintf’ output between 8 and 71 bytes into a destination of size 64
         sprintf(exportpath, "%s/export", chippath);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 57%] Building C object src/CMakeFiles/mraa.dir/arm/phyboard.c.o
[ 60%] Building C object src/CMakeFiles/mraa.dir/arm/banana.c.o
[ 62%] Building C object src/CMakeFiles/mraa.dir/arm/de_nano_soc.c.o
[ 65%] Building C object src/CMakeFiles/mraa.dir/arm/rockpi4.c.o
[ 68%] Building C object src/CMakeFiles/mraa.dir/arm/adlink_ipi.c.o
[ 71%] Building C object src/CMakeFiles/mraa.dir/version.c.o
[ 74%] Linking C shared library libmraa.so
[ 74%] Built target mraa
Scanning dependencies of target mraajs_swig_compilation
[ 77%] Swig compile mraajs.i for javascript
[ 77%] Built target mraajs_swig_compilation
Scanning dependencies of target mraajs
[ 80%] Building CXX object src/javascript/CMakeFiles/mraajs.dir/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx.o
In file included from /usr/local/include/node/node.h:65,
                 from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:171:
/usr/local/include/node/v8-platform.h:158:7: warning: ‘class v8::JobDelegate’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
 class JobDelegate {
       ^~~~~~~~~~~
In file included from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:171:
/usr/local/include/node/node.h:270:19: warning: ‘class node::IsolatePlatformDelegate’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
 class NODE_EXTERN IsolatePlatformDelegate {
                   ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1821:
/home/pi/GIT/mraa/api/mraa/gpio.hpp: In static member function ‘static void mraa::Gpio::v8isr(uv_work_t*, int)’:
/home/pi/GIT/mraa/api/mraa/gpio.hpp:181:89: warning: ignoring return value of ‘v8::MaybeLocal<v8::Value> v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*)’, declared with attribute warn_unused_result [-Wunused-result]
         f->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
                                                                                         ^
In file included from /usr/local/include/node/node.h:63,
                 from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:171:
/usr/local/include/node/v8.h:4739:43: note: declared here
   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
                                           ^~~~
In file included from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1821:
/home/pi/GIT/mraa/api/mraa/gpio.hpp: In member function ‘mraa::Result mraa::Gpio::useMmap(bool)’:
/home/pi/GIT/mraa/api/mraa/gpio.hpp:323:77: warning: ‘mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context, mraa_boolean_t)’ is deprecated [-Wdeprecated-declarations]
         return (Result) mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
                                                                             ^
In file included from /home/pi/GIT/mraa/api/mraa/gpio.hpp:29,
                 from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1821:
/home/pi/GIT/mraa/api/mraa/gpio.h:289:26: note: declared here
 DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
                          ^~~~~~~~~~~~~~~~~~~~
In file included from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1821:
/home/pi/GIT/mraa/api/mraa/gpio.hpp:323:77: warning: ‘mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context, mraa_boolean_t)’ is deprecated [-Wdeprecated-declarations]
         return (Result) mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
                                                                             ^
In file included from /home/pi/GIT/mraa/api/mraa/gpio.hpp:29,
                 from /home/pi/GIT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1821:
/home/pi/GIT/mraa/api/mraa/gpio.h:289:26: note: declared here
 DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
                          ^~~~~~~~~~~~~~~~~~~~
[ 82%] Linking CXX shared module mraa.node
[ 82%] Built target mraajs
Scanning dependencies of target mraa-i2c
[ 85%] Building C object tools/CMakeFiles/mraa-i2c.dir/mraa-i2c.c.o
[ 88%] Linking C executable mraa-i2c
[ 88%] Built target mraa-i2c
Scanning dependencies of target mraa-gpio
[ 91%] Building C object tools/CMakeFiles/mraa-gpio.dir/mraa-gpio.c.o
/home/pi/GIT/mraa/tools/mraa-gpio.c: In function ‘gpio_set’:
/home/pi/GIT/mraa/tools/mraa-gpio.c:99:13: warning: ‘mraa_gpio_use_mmaped’ is deprecated [-Wdeprecated-declarations]
             if (mraa_gpio_use_mmaped(gpio, 1) != MRAA_SUCCESS) {
             ^~
In file included from /home/pi/GIT/mraa/tools/mraa-gpio.c:13:
/home/pi/GIT/mraa/api/mraa/gpio.h:289:26: note: declared here
 DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
                          ^~~~~~~~~~~~~~~~~~~~
/home/pi/GIT/mraa/tools/mraa-gpio.c: In function ‘gpio_get’:
/home/pi/GIT/mraa/tools/mraa-gpio.c:117:13: warning: ‘mraa_gpio_use_mmaped’ is deprecated [-Wdeprecated-declarations]
             if (mraa_gpio_use_mmaped(gpio, 1) != MRAA_SUCCESS) {
             ^~
In file included from /home/pi/GIT/mraa/tools/mraa-gpio.c:13:
/home/pi/GIT/mraa/api/mraa/gpio.h:289:26: note: declared here
 DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
                          ^~~~~~~~~~~~~~~~~~~~
[ 94%] Linking C executable mraa-gpio
[ 94%] Built target mraa-gpio
Scanning dependencies of target mraa-uart
[ 97%] Building C object tools/CMakeFiles/mraa-uart.dir/mraa-uart.c.o
[100%] Linking C executable mraa-uart
[100%] Built target mraa-uart
g-vidal commented 3 years ago

many thanks @nxhack I am using bullseye the gcc version is OK gcc version 10.2.1 20210110 (Debian 10.2.1-6)

after the patch I build swig with cpp11 test option ./configure --enable-cpp11-testing test passes for C++17

I am compiling cmake to get cmake-3.20.3 I get exactly the same error quoted upstream

-- The C compiler identification is GNU 10.2.1 -- The CXX compiler identification is GNU 10.2.1

-- INFO - Using V8 version > 3 so requiring C++11 compiler -- INFO - install NODE modules to /usr/lib/node_modules/mraa/

any other idea...

g-vidal commented 3 years ago

@nxhack @Propanu same error occurs when building upm

Building CXX object src/2jciebu01_ble/CMakeFiles/jsupm_2jciebu01_ble.dir/CMakeFiles/jsupm_2jciebu01_ble.dir/2jciebu01_bleJAVASCRIPT_wrap.cxx.o
In file included from /usr/local/include/node/v8.h:30,
                 from /usr/local/include/node/node.h:63,
                 from /home/ens-ife/Logiciels/IoT/upm/build/src/2jciebu01_ble/CMakeFiles/jsupm_2jciebu01_ble.dir/2jciebu01_bleJAVASCRIPT_wrap.cxx:171:
/usr/local/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
/usr/local/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                      ^~~~~~~~~~~
      |                                      remove_cv
/usr/local/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                      ^~~~~~~~~~~
      |                                      remove_cv
/usr/local/include/node/v8-internal.h:452:50: error: template argument 2 is invalid
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                                  ^
/usr/local/include/node/v8-internal.h:452:63: error: ‘::Perform’ has not been declared
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                                               ^~~~~~~
nxhack commented 3 years ago

Thanks for the report. I will try it with gcc10. (In OpenWrt's cross build environment).

g-vidal commented 3 years ago

OK thanks for the followup if it may help I keep traces of the process in my draft blog without the logs and in french but code blocks are international ;-)

nxhack commented 3 years ago

https://blog.tremplin.ens-lyon.fr/GerardVidal/drafts/RaspberryPiMetBuildImage.html#head6.2.1 We no longer need this patch.

--- a/Lib/javascript/v8/javascriptruntime.swg
+++ b/Lib/javascript/v8/javascriptruntime.swg
@@ -57,9 +57,10 @@
 #include <v8.h>

 #if defined(V8_MAJOR_VERSION) && defined(V8_MINOR_VERSION)
-#undef SWIG_V8_VERSION
+#ifndef SWIG_V8_VERSION
 #define SWIG_V8_VERSION (V8_MAJOR_VERSION * 256 + V8_MINOR_VERSION)
 #endif
+#endif

 #include <errno.h>
 #include <limits.h>
g-vidal commented 3 years ago

Could it be the cause of the error ? I will restart without patching swig

The solution is pushed in the master or should I use another branch? AT the moment I am cloning mraa master.

nxhack commented 3 years ago

The version of gcc10 that can be configured in OpenWrt is 10.3.0, so I tested with that.

-- INFO - swig Version 4.1.0
-- INFO - CXX compiler Version GNU 10.3.0
-- INFO - Using V8 version > 3 so requiring C++11 compiler

I was able to build with gcc 10.3.0 without any problems.

That's strange...

nxhack commented 3 years ago

The solution is pushed in the master or should I use another branch? AT the moment I am cloning mraa master.

For swig, leave it as is 4.1.0. Please apply my patch for mraa and upm

nxhack commented 3 years ago

Probably not, but is swig's PTAH correct?

[ 38%] Building CXX object src/javascript/CMakeFiles/mraajs.dir/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx.o In file included from /home/ens-ife/Logiciels/IoT/mraa/build/src/javascript/CMakeFiles/mraajs.dir/mraajsJAVASCRIPT_wrap.cxx:1822: /home/ens-ife/Logiciels/IoT/mraa/api/mraa/gpio.hpp: In static member function ‘static void mraa::Gpio::v8isr(uv_work_t*, int)’: /home/ens-ife/Logiciels/IoT/mraa/api/mraa/gpio.hpp:179:63: error: no matching function for call to ‘v8::Function::Call(v8::Local, int&, v8::Local [1])’ 179 | f->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);

I'm curious about this log.

Try to explicitly specify "SWIG_EXECUTABLE", which is mraa's CMAKE option.

g-vidal commented 3 years ago

I don't think the difference between 10.2 and 10.3 might yield such discrepancy I was wondering if this does come from the combination of ./configure with option --enable-cpp11-testing and the old patch that was applied ? The enable-cpp11-testing sends a message in the log sayind that it tests c++17 which seems OK and it looks like just a testing option

Which patch ? where can I find it ? Thanks

nxhack commented 3 years ago

I tested swig with the "--enable-cpp11-testing" option, and mraa and upm were able to build without any problems.

checking whether to attempt to enable C++11 testing... yes
checking whether ccache g++ supports C++17 features with -std=c++17... yes
checking whether C++17 and earlier testing is enabled... yes

For more details about the patch, see

SWIG: This is the github master branch as it was in 4.1.0.

MRAA: The following patches have been applied to the master branch on github. https://github.com/eclipse/mraa/issues/1041 (This is the patch you created.) https://github.com/eclipse/mraa/pull/1064

UPM: The following patches have been applied to the master branch on github. https://github.com/eclipse/upm/pull/703 https://github.com/nxhack/openwrt-custom-packages/blob/master/libupm/patches/002-at42qt1070-id.patch https://github.com/nxhack/openwrt-custom-packages/blob/master/libupm/patches/003-link-atomic.patch https://github.com/nxhack/openwrt-custom-packages/blob/master/libupm/patches/004-uint8_t.patch

UPM need those options: -DWERROR=OFF -DCMAKE_CXX_STANDARD=14

g-vidal commented 3 years ago

I have cloned swig mraa and upm from your repo (from the cleaned V8 branches) everything run ssmoothly for all :+1:

It seems that -DCMAKE_CXX_STANDARD=14 is crucial ! 5why not 17 insteadof 14 ?)

I'll check tomorrow to compile the eclipse master version.. maybe need to change config parameters inside CMakefiles

nxhack commented 3 years ago

It seems that -DCMAKE_CXX_STANDARD=14 is crucial ! 5why not 17 insteadof 14 ?)

I set the number to 14 in order to support node.js v16. No other intentions.

g-vidal commented 3 years ago

Things are getting clearer !!! The behaviour is the same for mraa and upm I describe the example on mraa

At least we know where to look :-) your branch is working master eclipse is not . Here is the situation :

Tests are made using git clone -b master --single-branch https://github.com/swig/swig.git and cmake .. -Wno-dev -DCMAKE_INSTALL_PREFIX=/usr -DENABLEEXAMPLES=0 -DBUILDSWIGNODE=ON -DSWIG_EXECUTABLE=/usr/local/bin/swig -DV8_ROOT_DIR=/usr/local/include/node -DNODE_ROOT_DIR=/usr/local/include/node -DPYTHON2LIBS_FOUND=FALSE -DPYTHON2INTERP_FOUND=FALSE

situation 1 FAILS :

git clone https://github.com/eclipse/mraa

change in CMakefiles.txt

  cmake_policy(SET CMP0078 OLD)
  cmake_policy(SET CMP0086 NEW)
endif ()
option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDSWIGJAVA "Build Java API." ON)

patch with

--- include/version.h   2020-11-10 19:47:03.734243366 +0100
+++ include/version.h   2020-11-11 10:43:19.870180059 +0100
@@ -11,8 +11,8 @@
 extern "C" {
 #endif

-const char* gVERSION;
-const char* gVERSION_SHORT;
+extern const char* gVERSION;
+extern const char* gVERSION_SHORT;

 #ifdef __cplusplus
 }

Situation 2 WORKS :

git clone -b cleanup_V8_MAJOR_VERSION --single-branch https://github.com/nxhack/mraa.git

change in CMakefiles.txt

  cmake_policy(SET CMP0078 OLD)
  cmake_policy(SET CMP0086 NEW)
endif ()

.../...

option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDSWIGJAVA "Build Java API." ON)

patch with

--- include/version.h   2020-11-10 19:47:03.734243366 +0100
+++ include/version.h   2020-11-11 10:43:19.870180059 +0100
@@ -11,8 +11,8 @@
 extern "C" {
 #endif

-const char* gVERSION;
-const char* gVERSION_SHORT;
+extern const char* gVERSION;
+extern const char* gVERSION_SHORT;

 #ifdef __cplusplus
 }
g-vidal commented 3 years ago

Hi @nxhack I checked -DCMAKE_CXX_STANDARD=14 and -DCMAKE_CXX_STANDARD=17 no difference ! probably we may choose 17 as it is the more uptodate?

Any idea on the orign of he difference between your branch and eclipse master ?

nxhack commented 3 years ago

I checked -DCMAKE_CXX_STANDARD=14 and -DCMAKE_CXX_STANDARD=17 no difference ! probably we may choose 17 as it is the more uptodate?

I think we should choose conservative options.

Again. I will explain the procedure I described in more detail.

MRAA: The following patches have been applied to the master branch on github.

1041 (This is the patch you created.)

1064

git clone https://github.com/eclipse/mraa.git
cd mraa
wget https://patch-diff.githubusercontent.com/raw/eclipse/mraa/pull/1064.patch
patch -p1 < 1064.patch

And apply your gcc10 support patch to this.

nxhack commented 3 years ago

I recommend that you submit a pull request for the gcc10 patch.

g-vidal commented 3 years ago

I am sorry I did not understand that one patch was not yet installed . It works like a charm !

test OK on Raspberry Pi3 Linux myPi 5.12.6-v7 #1 SMP Mon May 31 18:19:07 CEST 2021 armv7l GNU/Linux SWIG Version 4.1.0 gcc version 10.2.1 20210110 (Debian 10.2.1-6) node v16.2.0 npm 7.15.0

I think that patch #1064 should be pushed in master @Propanu

nxhack commented 3 years ago

I recommend that you submit a pull request for the gcc10 patch.

The same patch had already been opened.

https://github.com/eclipse/mraa/pull/1012