edubart / nelua-lang

Minimal, efficient, statically-typed and meta-programmable systems programming language heavily inspired by Lua, which compiles to C and native code.
https://nelua.io
MIT License
2k stars 62 forks source link

solaris 11, compilation failed #116

Closed tankf33der closed 3 years ago

tankf33der commented 3 years ago
$ gmake
<SKIP>
rpmalloc/rpmalloc.c:162:15: error: conflicting types for ‘madvise’
  162 |    extern int madvise(caddr_t, size_t, int);
      |               ^~~~~~~
In file included from rpmalloc/rpmalloc.c:155:
/usr/include/sys/mman.h:232:12: note: previous declaration of ‘madvise’ was here
  232 | extern int madvise(void *, size_t, int);
      |            ^~~~~~~
gmake[1]: *** [Makefile:63: nelua-lua] Error 1
$

This diff helped here:

bash-5.0$ git diff
diff --git a/src/rpmalloc/rpmalloc.c b/src/rpmalloc/rpmalloc.c
index 282a1dc..1d37e17 100644
--- a/src/rpmalloc/rpmalloc.c
+++ b/src/rpmalloc/rpmalloc.c
@@ -159,7 +159,7 @@ static DWORD fls_key;
 #    define MAP_HUGETLB MAP_ALIGNED_SUPER
 #  endif
 #  ifdef __sun
-   extern int madvise(caddr_t, size_t, int);
+   extern int madvise(void *, size_t, int);
 #  endif
 #  ifndef MAP_UNINITIALIZED
 #    define MAP_UNINITIALIZED 0
$

You have to handle Solaris 10 and 11.

edubart commented 3 years ago

Looks like rpmalloc is not supported there, you could build with gmake NO_RPMALLOC=1

tankf33der commented 3 years ago

RPMALLOC is supported for Solaris 11, it works.

Just add detection for Solaris 10 and 11.

edubart commented 3 years ago

I've reported the issue to rpmalloc project, and meanwhile I've disabled it for non Windows/Linux/MacOS platforms in commit https://github.com/edubart/nelua-lang/commit/85cc4bbf575621adaad9b0de1364e28ff0c4d8a6, because rpmalloc may not work good on many exotic operating systems so it's better to leave it enabled only on systems that are known to be working well, otherwise disabled.

The rpmalloc allocator is only used to speed up the Nelua compiler, it's not a critical piece, if the rpmalloc project fixes this issue I may enable it for all Solaris again in the future.

mjansson commented 3 years ago

RPMALLOC is supported for Solaris 11, it works.

Just add detection for Solaris 10 and 11.

@tankf33der do you know any preprocessor define that can be used to check if it’s Solaris 10 or 11 being targeted?

tankf33der commented 3 years ago

@tankf33der do you know any preprocessor define that can be used to check if it’s Solaris 10 or 11 being targeted?

@mjansson I did not find direct way for this in google.