stan-dev / cmdstan

CmdStan, the command line interface to Stan
https://mc-stan.org/users/interfaces/cmdstan
BSD 3-Clause "New" or "Revised" License
212 stars 93 forks source link

Compilation failed on Alpine Linux (>= 3.17) #1218

Closed remi-314softwares closed 12 months ago

remi-314softwares commented 12 months ago

Summary:

The compilation of cmdstan (2.33.1) failed on Alpine Linux, due to lack of mallinfo structure in Alpine Linux (>=3.17).

Description:

The compilation of cmdstan (2.33.1) failed on Alpine Linux, due to lack of mallinfo structure in Alpine Linux (>=3.17). Set the MALLOC_UNIXLIKE_OVERLOAD_ENABLED precomp value to 0 instead of __linux__ allow compilation to finish, but it's not a fix...

Reproducible Steps:

From a clean download and untar cmdstan 2.33.1 on Alpine Linux 3.18.3

cmdstan-2.33.1 # make build
...
../tbb_2020.3/src/tbbmalloc/proxy.cpp:27:47: error: missing binary operator before token "("
   27 | #if defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 16) && _GLIBCXX_HAVE_ALIGNED_ALLOC
      |                                               ^
../tbb_2020.3/src/tbbmalloc/proxy.cpp:284:26: error: return type 'struct mallinfo' is incomplete
  284 | struct mallinfo mallinfo() __THROW
      |                          ^
../tbb_2020.3/src/tbbmalloc/proxy.cpp: In function 'void mallinfo()':
../tbb_2020.3/src/tbbmalloc/proxy.cpp:286:21: error: aggregate 'mallinfo m' has incomplete type and cannot be defined
  286 |     struct mallinfo m;
      |                     ^
../tbb_2020.3/src/tbbmalloc/proxy.cpp:287:19: error: invalid application of 'sizeof' to incomplete type 'mallinfo'
  287 |     memset(&m, 0, sizeof(struct mallinfo));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~

Current Output:

../tbb_2020.3/src/tbbmalloc/proxy.cpp:27:47: error: missing binary operator before token "("
   27 | #if defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 16) && _GLIBCXX_HAVE_ALIGNED_ALLOC
      |                                               ^
../tbb_2020.3/src/tbbmalloc/proxy.cpp:284:26: error: return type 'struct mallinfo' is incomplete
  284 | struct mallinfo mallinfo() __THROW
      |                          ^
../tbb_2020.3/src/tbbmalloc/proxy.cpp: In function 'void mallinfo()':
../tbb_2020.3/src/tbbmalloc/proxy.cpp:286:21: error: aggregate 'mallinfo m' has incomplete type and cannot be defined
  286 |     struct mallinfo m;
      |                     ^
../tbb_2020.3/src/tbbmalloc/proxy.cpp:287:19: error: invalid application of 'sizeof' to incomplete type 'mallinfo'
  287 |     memset(&m, 0, sizeof(struct mallinfo));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~

Expected Output:

....

--- CmdStan v2.33.1 built ---

Current Version:

v2.33.1

WardBrian commented 12 months ago

I was able to confirm this locally (in docker). The issue is in the TBB library which we vendor.

Oddly, re-running make build after the error is raised seems to make more progress and eventually succeed. I think the error is only in tbbmalloc_proxy which is optional. The fact that we're trying to build it at all may be the issue

I believe you could also apk add libtbb-dev and then use that version by setting TBB_INTERFACE_NEW=true TBB_LIB=/path/to/libraries TBB_INC=/path/to/headers

remi-314softwares commented 12 months ago

Hello @WardBrian, It works fine now !! Thx a lot.