dgasmith / gau2grid

Fast computation of a gaussian and its derivative on a grid.
https://gau2grid.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
29 stars 15 forks source link

Build issues macOS + gcc-8.0 (Also #42) #45

Closed wadejong closed 5 years ago

wadejong commented 5 years ago

This is reproducible.

cmake -H. -Bbuild -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 -DCMAKE_Fortran_COMPILER=gfortran-8

Homebrew installed gcc-8

Components of NWChemEx cannot compile properly with clang, hence we are using gcc on a Mac right now. Not clear where it goes wrong. Most likely the path to the include file is not found?

Bert

Originally posted by @wadejong in https://github.com/dgasmith/gau2grid/issues/42#issuecomment-507595828

dgasmith commented 5 years ago

Not sure I can reproduce this as Conda (my setup) and Homebrew are not friends. Once we debug this, I will add some Mac Homebrew GCC CI builds. Do you still see the same warnings (and errors) @maxscheurer was seeing?

/tmp/gau2grid/build/gau2grid_deriv2.c: In function 'gg_collocation_L8_deriv2':
/tmp/gau2grid/build/gau2grid_pragma.h:35:62: warning: incompatible implicit declaration of built-in function 'aligned_alloc'
     #define ALIGNED_MALLOC(alignment, size)                  aligned_alloc(alignment, size)
                                                              ^~~~~~~~~~~~~
/tmp/gau2grid/build/gau2grid_deriv2.c:5637:51: note: in expansion of macro 'ALIGNED_MALLOC'
     double* PRAGMA_RESTRICT cache_data = (double*)ALIGNED_MALLOC(64, 256 * sizeof(double));
                                                   ^~~~~~~~~~~~~~
/tmp/gau2grid/build/gau2grid_pragma.h:35:62: note: include '<stdlib.h>' or provide a declaration of 'aligned_alloc'
     #define ALIGNED_MALLOC(alignment, size)                  aligned_alloc(alignment, size)

If you add #include <stdlib.h> around line 34 of the generated gau2grid_pragma.h does it resolve? The other thing to try is -std=c++17 to double check that gau2grid is not trying to compile this under C++ which did obtain aligned_alloc until then.

wadejong commented 5 years ago

Yes, same error. Seems it doesn’t pick up stdlib.h. Manually inserting doesn’t help either, I guess it’s not in the include path chosen.

On Jul 2, 2019, at 4:05 PM, Daniel Smith notifications@github.com wrote:

Not sure I can reproduce this as Conda (my setup) and Homebrew are not friends. Once we debug this, I will add some Mac Homebrew GCC CI builds. Do you still see the same error @maxscheurer was seeing?

/tmp/gau2grid/build/gau2grid_deriv2.c: In function 'gg_collocation_L8_deriv2': /tmp/gau2grid/build/gau2grid_pragma.h:35:62: warning: incompatible implicit declaration of built-in function 'aligned_alloc'

define ALIGNED_MALLOC(alignment, size) aligned_alloc(alignment, size)

                                                          ^~~~~~~~~~~~~

/tmp/gau2grid/build/gau2grid_deriv2.c:5637:51: note: in expansion of macro 'ALIGNED_MALLOC' double PRAGMA_RESTRICT cache_data = (double)ALIGNED_MALLOC(64, 256 * sizeof(double)); ^~~~~~ /tmp/gau2grid/build/gau2grid_pragma.h:35:62: note: include '' or provide a declaration of 'aligned_alloc'

define ALIGNED_MALLOC(alignment, size) aligned_alloc(alignment, size)

If you add #include around line 34 of the generated gau2grid_pragma.h does it resolve? The other thing to try is -std=c++17 to double check that gau2grid is not trying to compile this under C++ which did obtain aligned_alloc until then.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

dgasmith commented 5 years ago

It doesn't make any sense that I can understand as it should raise an error if it cannot find the header. As this isn't an issue on Linux it makes me feel like this is some sort of strange Darwin thing. g++ has _GLIBCXX_HAVE_ALIGNED_ALLOC, but no analogy for gcc.

To get around this you can changed the ALIGNED_MALLOC to a simple #define ALIGNED_MALLOC(alignment, size) malloc(size); for now.

For the future we might add a __APPLE__ to direct Darwin to not used aligned_malloc or go back to old posix_memalign.

dgasmith commented 5 years ago

Can you double check your Homebrew glibc is 2.23?

dgasmith commented 5 years ago

Master now builds with GCC 4.9 and 8.0 on MacOS via Travis CI.