PlasmaLang / plasma

Plasma Programming Language
Other
162 stars 10 forks source link

Make Plasma run on void + musl #439

Closed PaulBone closed 1 year ago

PaulBone commented 2 years ago

A user reported this problem:

I had an error during building plasma from source:

runtime/pz_util.h:16:24: error: '__WORDSIZE' was not declared in this scope
   16 | #define WORDSIZE_BITS  __WORDSIZE
      |                        ^~~~~~~~~~
runtime/pz_gc.h:22:38: note: in expansion of macro 'WORDSIZE_BITS'

It may be due to the fact that I use musl on Void in stead of glibc, although I have gcompat, a compatibility layer to allow running glibc binaries on musl systems. I don't know anything about C, and even less regarding to its preprocessor though. (__WORDSIZE is defined in a macro).

Gertm commented 2 years ago

I tested this on Alpine (which is also based on musl) and got the same result. I used the git checkout for plasma: commit 02a31b59d9ad5526a1456f79349301916fa1b3fc

gcompat is not installed on Alpine by default, so that didn't make any difference.

musl doesn't include the entire feature set of libc, so it's likely that __WORDSIZE isn't defined in musl.

So I added -D__WORDSIZE=64 to the C_CXX_FLAGS in build.mk and it actually didn't crash anymore, but it did crash on a different error:

runtime/pz_gc_debug.cpp: In member function 'void pz::Heap::print_addr_info(void*) const':
runtime/pz_gc_debug.cpp:221:13: error: 'ptrdiff_t' was not declared in this scope; did you mean 'std::ptrdiff_t'?
  221 |             ptrdiff_t diff = (uint8_t *)cell_bop.pointer() - (uint8_t *)addr;
      |             ^~~~~~~~~
      |             std::ptrdiff_t
In file included from /usr/include/c++/11.2.1/cstdlib:41,
                 from /usr/include/c++/11.2.1/stdlib.h:36,
                 from runtime/pz_common.h:18,
                 from runtime/pz_gc_debug.cpp:9:
/usr/include/c++/11.2.1/x86_64-alpine-linux-musl/bits/c++config.h:281:33: note: 'std::ptrdiff_t' declared here
  281 |   typedef __PTRDIFF_TYPE__      ptrdiff_t;
      |                                 ^~~~~~~~~
runtime/pz_gc_debug.cpp:226:21: error: 'diff' was not declared in this scope
  226 |                     diff,
      |                     ^~~~
runtime/pz_gc_debug.cpp:249:13: error: 'ptrdiff_t' was not declared in this scope; did you mean 'std::ptrdiff_t'?
  249 |             ptrdiff_t diff = (uint8_t *)cell_fit.pointer() - (uint8_t *)addr;
      |             ^~~~~~~~~
      |             std::ptrdiff_t
In file included from /usr/include/c++/11.2.1/cstdlib:41,
                 from /usr/include/c++/11.2.1/stdlib.h:36,
                 from runtime/pz_common.h:18,
                 from runtime/pz_gc_debug.cpp:9:
/usr/include/c++/11.2.1/x86_64-alpine-linux-musl/bits/c++config.h:281:33: note: 'std::ptrdiff_t' declared here
  281 |   typedef __PTRDIFF_TYPE__      ptrdiff_t;
      |                                 ^~~~~~~~~
runtime/pz_gc_debug.cpp:254:21: error: 'diff' was not declared in this scope
  254 |                     diff,
      |                     ^~~~
make: *** [Makefile:192: runtime/pz_gc_debug.o] Error 1

I didn't go down the rabbit hole yet, but maybe this provides some extra clues for people who know more about C and C++.

PaulBone commented 1 year ago

Thanks @Gertm I'll keep my eyes open for that when I fix this.