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

Conflicting types for 'uvwasi_serdes_read_uint{32,16,8}_t' #34510

Closed
triaxx opened this issue Jul 25, 2020 · 5 comments
Closed

Conflicting types for 'uvwasi_serdes_read_uint{32,16,8}_t' #34510

triaxx opened this issue Jul 25, 2020 · 5 comments
Labels
build Issues and PRs related to build files or the CI. wasi Issues and PRs related to the WebAssembly System Interface.

Comments

@triaxx
Copy link

triaxx commented Jul 25, 2020

When trying to build nodejs-14.6.0 on NetBSD 8.2 with GCC 6.5.0, I get the following errors:

  cc -o /usr/pkgsrc/lang/nodejs/work/node-v14.6.0/out/Release/obj.target/uvwasi/deps/uvwasi/src/wasi_serdes.o ../deps/uvwasi/src/wasi_serdes.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D__STDC_FORMAT_MACROS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' -I/usr/pkg/include -I../deps/uvwasi/include -I../deps/uv/include  -pthread -Wall -Wextra -Wno-unused-parameter -m64 -fvisibility=hidden -O3 -fno-omit-frame-pointer  -MMD -MF /usr/pkgsrc/lang/nodejs/work/node-v14.6.0/out/Release/.deps//usr/pkgsrc/lang/nodejs/work/node-v14.6.0/out/Release/obj.target/uvwasi/deps/uvwasi/src/wasi_serdes.o.d.raw -I/usr/pkg/include -I/usr/include -O2 -D_FORTIFY_SOURCE=2 -pthread -I/usr/pkg/include -I/usr/include -c
../deps/uvwasi/src/wasi_serdes.c: In function 'uvwasi_serdes_write_uint64_t':
../deps/uvwasi/src/wasi_serdes.c:7:3: warning: implicit declaration of function 'uvwasi_serdes_write_uint32_t' [-Wimplicit-function-declaration]
   uvwasi_serdes_write_uint32_t(ptr, offset, (uint32_t) value);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: At top level:
../deps/uvwasi/src/wasi_serdes.c:11:6: warning: conflicting types for 'uvwasi_serdes_write_uint32_t'
 void uvwasi_serdes_write_uint32_t(void* ptr,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c:7:3: note: previous implicit declaration of 'uvwasi_serdes_write_uint32_t' was here
   uvwasi_serdes_write_uint32_t(ptr, offset, (uint32_t) value);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: In function 'uvwasi_serdes_write_uint32_t':
../deps/uvwasi/src/wasi_serdes.c:14:3: warning: implicit declaration of function 'uvwasi_serdes_write_uint16_t' [-Wimplicit-function-declaration]
   uvwasi_serdes_write_uint16_t(ptr, offset, (uint16_t) value);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: At top level:
../deps/uvwasi/src/wasi_serdes.c:18:6: warning: conflicting types for 'uvwasi_serdes_write_uint16_t'
 void uvwasi_serdes_write_uint16_t(void* ptr,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c:14:3: note: previous implicit declaration of 'uvwasi_serdes_write_uint16_t' was here
   uvwasi_serdes_write_uint16_t(ptr, offset, (uint16_t) value);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: In function 'uvwasi_serdes_write_uint16_t':
../deps/uvwasi/src/wasi_serdes.c:21:3: warning: implicit declaration of function 'uvwasi_serdes_write_uint8_t' [-Wimplicit-function-declaration]
   uvwasi_serdes_write_uint8_t(ptr, offset, (uint8_t) value);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: At top level:
../deps/uvwasi/src/wasi_serdes.c:25:6: warning: conflicting types for 'uvwasi_serdes_write_uint8_t'
 void uvwasi_serdes_write_uint8_t(void* ptr,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c:21:3: note: previous implicit declaration of 'uvwasi_serdes_write_uint8_t' was here
   uvwasi_serdes_write_uint8_t(ptr, offset, (uint8_t) value);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: In function 'uvwasi_serdes_read_uint64_t':
../deps/uvwasi/src/wasi_serdes.c:32:18: warning: implicit declaration of function 'uvwasi_serdes_read_uint32_t' [-Wimplicit-function-declaration]
   uint64_t low = uvwasi_serdes_read_uint32_t(ptr, offset);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: At top level:
../deps/uvwasi/src/wasi_serdes.c:37:10: error: conflicting types for 'uvwasi_serdes_read_uint32_t'
 uint32_t uvwasi_serdes_read_uint32_t(const void* ptr, size_t offset) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c:32:18: note: previous implicit declaration of 'uvwasi_serdes_read_uint32_t' was here
   uint64_t low = uvwasi_serdes_read_uint32_t(ptr, offset);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: In function 'uvwasi_serdes_read_uint32_t':
../deps/uvwasi/src/wasi_serdes.c:38:18: warning: implicit declaration of function 'uvwasi_serdes_read_uint16_t' [-Wimplicit-function-declaration]
   uint32_t low = uvwasi_serdes_read_uint16_t(ptr, offset);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: At top level:
../deps/uvwasi/src/wasi_serdes.c:43:10: error: conflicting types for 'uvwasi_serdes_read_uint16_t'
 uint16_t uvwasi_serdes_read_uint16_t(const void* ptr, size_t offset) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c:38:18: note: previous implicit declaration of 'uvwasi_serdes_read_uint16_t' was here
   uint32_t low = uvwasi_serdes_read_uint16_t(ptr, offset);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: In function 'uvwasi_serdes_read_uint16_t':
../deps/uvwasi/src/wasi_serdes.c:44:18: warning: implicit declaration of function 'uvwasi_serdes_read_uint8_t' [-Wimplicit-function-declaration]
   uint16_t low = uvwasi_serdes_read_uint8_t(ptr, offset);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c: At top level:
../deps/uvwasi/src/wasi_serdes.c:49:9: error: conflicting types for 'uvwasi_serdes_read_uint8_t'
 uint8_t uvwasi_serdes_read_uint8_t(const void* ptr,  size_t offset) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/uvwasi/src/wasi_serdes.c:44:18: note: previous implicit declaration of 'uvwasi_serdes_read_uint8_t' was here
   uint16_t low = uvwasi_serdes_read_uint8_t(ptr, offset);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[1]: *** [deps/uvwasi/uvwasi.target.mk:94: /usr/pkgsrc/lang/nodejs/work/node-v14.6.0/out/Release/obj.target/uvwasi/deps/uvwasi/src/wasi_serdes.o] Error 1
gmake[1]: *** Waiting for unfinished jobs....
../deps/uvwasi/src/uvwasi.c: In function 'uvwasi_poll_oneoff':
../deps/uvwasi/src/uvwasi.c:2279:21: warning: 'timer_userdata' may be used uninitialized in this function [-Wmaybe-uninitialized]
     event->userdata = timer_userdata;
     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
gmake: *** [Makefile:104: node] Error 2
*** Error code 2

Stop.
bmake[1]: stopped in /usr/pkgsrc/lang/nodejs
*** Error code 1

Stop.
bmake: stopped in /usr/pkgsrc/lang/nodejs
@triaxx
Copy link
Author

triaxx commented Jul 25, 2020

When stopping compilation after preprocessing stage, own can notice that wrong function prototypes are defined from the BASIC_TYPE_(name, type) macro (deps/uvwasi/include/wasi_serdes.h) as for example:

# 16 "../include/wasi_serdes.h"
void uvwasi_serdes_write___uint8_t(void* ptr, size_t offset, 
# 16 "../include/wasi_serdes.h" 3 4 
__uint8_t 
# 16 "../include/wasi_serdes.h"
value);

By inspecting /usr/include/stdint.h on NetBSD, own can see this kind of following definitions:

#ifndef uint8_t
typedef __uint8_t uint8_t;
#define uint8_t   __uint8_t
#endif

The patch below fixes the compilation warnings/errors but I am not sure that is the more elegant manner to solve the issue:

--- deps/uvwasi/include/wasi_serdes.h.orig  2020-07-20 22:18:45.000000000 +0000
+++ deps/uvwasi/include/wasi_serdes.h
@@ -12,6 +12,14 @@
 #define BASIC_TYPE(type) BASIC_TYPE_(type, type)
 #define BASIC_TYPE_UVWASI(type) BASIC_TYPE_(type, uvwasi_##type)
 
+/* NetBSD defines uint{8,16,32,64}_t as __uint{8,16,32,64}_t */
+#if defined(__NetBSD__)
+#undef uint8_t
+#undef uint16_t
+#undef uint32_t
+#undef uint64_t
+#endif
+
 #define UVWASI_SERDES_SIZE_uint8_t sizeof(uint8_t)
 BASIC_TYPE(uint8_t)
 #define UVWASI_SERDES_SIZE_uint16_t sizeof(uint16_t)

@triaxx
Copy link
Author

triaxx commented Jul 25, 2020

Actually, at least NetBSD 8.2 is affected but NetBSD 9.0 is not. The patch below is maybe more adapted to a general case:

--- deps/uvwasi/include/wasi_serdes.h.orig  2020-07-20 22:18:45.000000000 +0000
+++ deps/uvwasi/include/wasi_serdes.h
@@ -13,12 +13,24 @@
 #define BASIC_TYPE_UVWASI(type) BASIC_TYPE_(type, uvwasi_##type)
 
 #define UVWASI_SERDES_SIZE_uint8_t sizeof(uint8_t)
+#ifdef uint8_t
+#undef uint8_t
+#endif
 BASIC_TYPE(uint8_t)
 #define UVWASI_SERDES_SIZE_uint16_t sizeof(uint16_t)
+#ifdef uint16_t
+#undef uint16_t
+#endif
 BASIC_TYPE(uint16_t)
 #define UVWASI_SERDES_SIZE_uint32_t sizeof(uint32_t)
+#ifdef uint32_t
+#undef uint32_t
+#endif
 BASIC_TYPE(uint32_t)
 #define UVWASI_SERDES_SIZE_uint64_t sizeof(uint64_t)
+#ifdef uint64_t
+#undef uint64_t
+#endif
 BASIC_TYPE(uint64_t)
 
 #define UVWASI_SERDES_SIZE_advice_t sizeof(uvwasi_advice_t)

@addaleax addaleax added build Issues and PRs related to build files or the CI. wasi Issues and PRs related to the WebAssembly System Interface. labels Jul 25, 2020
@addaleax
Copy link
Member

Does this help? It seems cleaner than messing with macros for builtins.

diff --git a/deps/uvwasi/include/wasi_serdes.h b/deps/uvwasi/include/wasi_serdes.h
index f927b82bac9c..746fb72b123e 100644
--- a/deps/uvwasi/include/wasi_serdes.h
+++ b/deps/uvwasi/include/wasi_serdes.h
@@ -9,17 +9,16 @@
   void uvwasi_serdes_write_##name(void* ptr, size_t offset, type value);      \
   type uvwasi_serdes_read_##name(const void* ptr, size_t offset);             \
 
-#define BASIC_TYPE(type) BASIC_TYPE_(type, type)
 #define BASIC_TYPE_UVWASI(type) BASIC_TYPE_(type, uvwasi_##type)
 
 #define UVWASI_SERDES_SIZE_uint8_t sizeof(uint8_t)
-BASIC_TYPE(uint8_t)
+BASIC_TYPE_(uint8_t, uint8_t)
 #define UVWASI_SERDES_SIZE_uint16_t sizeof(uint16_t)
-BASIC_TYPE(uint16_t)
+BASIC_TYPE_(uint16_t, uint16_t)
 #define UVWASI_SERDES_SIZE_uint32_t sizeof(uint32_t)
-BASIC_TYPE(uint32_t)
+BASIC_TYPE_(uint32_t, uint32_t)
 #define UVWASI_SERDES_SIZE_uint64_t sizeof(uint64_t)
-BASIC_TYPE(uint64_t)
+BASIC_TYPE_(uint64_t, uint64_t)
 
 #define UVWASI_SERDES_SIZE_advice_t sizeof(uvwasi_advice_t)
 BASIC_TYPE_UVWASI(advice_t)

(/cc @cjihrig)

@cjihrig
Copy link
Contributor

cjihrig commented Jul 25, 2020

Assuming @addaleax's patch fixes the issue, do @addaleax or @triaxx want to send a PR to https://github.com/cjihrig/uvwasi? If not, I can do it. I'm doing some maintenance right now, and am due for a new release soon.

@triaxx
Copy link
Author

triaxx commented Jul 29, 2020

@cjihrig: done.
@addaleax: thank you for your path that is clearly cleaner that the mine!

@triaxx triaxx closed this as completed Jul 29, 2020
cjihrig pushed a commit to nodejs/uvwasi that referenced this issue Aug 1, 2020
This commit removes a macro, and fixes compilation errors on
certain platforms such as NetBSD 8.2.

Refs: nodejs/node#34510
Fixes: #145
cjihrig pushed a commit to nodejs/uvwasi that referenced this issue Aug 2, 2020
This commit removes a macro, and fixes compilation errors on
certain platforms such as NetBSD 8.2.

Refs: nodejs/node#34510
Fixes: #145
cjihrig added a commit to cjihrig/node that referenced this issue Aug 4, 2020
Notable changes:

- The uvwasi_preopen_t now uses const char* for the mapped_path
  and real_path fields. Previously, these were not `const`.
- uvwasi_path_filestat_get() now properly handles the
  UVWASI_LOOKUP_SYMLINK_FOLLOW flag.
- uvwasi_options_init() has been added to reduce the boilerplate
  code associated with initializing uvwasi_options_t's.
- The DEBUG() macro has been renamed to UVWASI_DEBUG() to reduce
  naming conflicts with other projects.
- A compilation error on NetBSD 8.2 has been fixed.
- The uvwasi_fd_filestat_set_times() and
  uvwasi_path_filestat_set_times() functions now have proper
  implementations.

Fixes: nodejs#34510
jasnell pushed a commit that referenced this issue Aug 7, 2020
Notable changes:

- The uvwasi_preopen_t now uses const char* for the mapped_path
  and real_path fields. Previously, these were not `const`.
- uvwasi_path_filestat_get() now properly handles the
  UVWASI_LOOKUP_SYMLINK_FOLLOW flag.
- uvwasi_options_init() has been added to reduce the boilerplate
  code associated with initializing uvwasi_options_t's.
- The DEBUG() macro has been renamed to UVWASI_DEBUG() to reduce
  naming conflicts with other projects.
- A compilation error on NetBSD 8.2 has been fixed.
- The uvwasi_fd_filestat_set_times() and
  uvwasi_path_filestat_set_times() functions now have proper
  implementations.

Fixes: #34510

PR-URL: #34623
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this issue Aug 8, 2020
Notable changes:

- The uvwasi_preopen_t now uses const char* for the mapped_path
  and real_path fields. Previously, these were not `const`.
- uvwasi_path_filestat_get() now properly handles the
  UVWASI_LOOKUP_SYMLINK_FOLLOW flag.
- uvwasi_options_init() has been added to reduce the boilerplate
  code associated with initializing uvwasi_options_t's.
- The DEBUG() macro has been renamed to UVWASI_DEBUG() to reduce
  naming conflicts with other projects.
- A compilation error on NetBSD 8.2 has been fixed.
- The uvwasi_fd_filestat_set_times() and
  uvwasi_path_filestat_set_times() functions now have proper
  implementations.

Fixes: #34510

PR-URL: #34623
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit that referenced this issue Aug 11, 2020
Notable changes:

- The uvwasi_preopen_t now uses const char* for the mapped_path
  and real_path fields. Previously, these were not `const`.
- uvwasi_path_filestat_get() now properly handles the
  UVWASI_LOOKUP_SYMLINK_FOLLOW flag.
- uvwasi_options_init() has been added to reduce the boilerplate
  code associated with initializing uvwasi_options_t's.
- The DEBUG() macro has been renamed to UVWASI_DEBUG() to reduce
  naming conflicts with other projects.
- A compilation error on NetBSD 8.2 has been fixed.
- The uvwasi_fd_filestat_set_times() and
  uvwasi_path_filestat_set_times() functions now have proper
  implementations.

Fixes: #34510

PR-URL: #34623
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this issue Sep 22, 2020
Notable changes:

- The uvwasi_preopen_t now uses const char* for the mapped_path
  and real_path fields. Previously, these were not `const`.
- uvwasi_path_filestat_get() now properly handles the
  UVWASI_LOOKUP_SYMLINK_FOLLOW flag.
- uvwasi_options_init() has been added to reduce the boilerplate
  code associated with initializing uvwasi_options_t's.
- The DEBUG() macro has been renamed to UVWASI_DEBUG() to reduce
  naming conflicts with other projects.
- A compilation error on NetBSD 8.2 has been fixed.
- The uvwasi_fd_filestat_set_times() and
  uvwasi_path_filestat_set_times() functions now have proper
  implementations.

Fixes: #34510

PR-URL: #34623
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this issue Sep 22, 2020
Notable changes:

- The uvwasi_preopen_t now uses const char* for the mapped_path
  and real_path fields. Previously, these were not `const`.
- uvwasi_path_filestat_get() now properly handles the
  UVWASI_LOOKUP_SYMLINK_FOLLOW flag.
- uvwasi_options_init() has been added to reduce the boilerplate
  code associated with initializing uvwasi_options_t's.
- The DEBUG() macro has been renamed to UVWASI_DEBUG() to reduce
  naming conflicts with other projects.
- A compilation error on NetBSD 8.2 has been fixed.
- The uvwasi_fd_filestat_set_times() and
  uvwasi_path_filestat_set_times() functions now have proper
  implementations.

Fixes: #34510

PR-URL: #34623
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. wasi Issues and PRs related to the WebAssembly System Interface.
Projects
None yet
Development

No branches or pull requests

3 participants