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

Compling with musl libc (Alpine Linux) #4373

Closed
ax3l opened this issue Mar 12, 2025 · 2 comments · Fixed by #4374 or #4385
Closed

Compling with musl libc (Alpine Linux) #4373

ax3l opened this issue Mar 12, 2025 · 2 comments · Fixed by #4374 or #4385

Comments

@ax3l
Copy link
Member

ax3l commented Mar 12, 2025

Compiling with alpine/musl libc, which is a common libc used in Python & Docker environments, does not support exception management fegetexcept, feenableexcept, fedisableexcept. They seem to be GNU-only.

We need to guard the respective functions in AMReX.cpp with the GNU libc macro HAVE_FEDISABLEEXCEPT (double check name, we can also use other checks to make sure GNU libc is used/not used).

Error message:


2025-03-12T18:45:57.8097333Z /project/amrex/Src/Base/AMReX.cpp: In function 'amrex::AMReX* amrex::Initialize(int&, char**&, bool, MPI_Comm, const std::function<void()>&, std::ostream&, std::ostream&, ErrorHandler)':
2025-03-12T18:45:57.8099222Z /project/amrex/Src/Base/AMReX.cpp:592:36: error: 'fegetexcept' was not declared in this scope; did you mean 'fetestexcept'?
2025-03-12T18:45:57.8101686Z   592 |                 prev_fpe_excepts = fegetexcept();
2025-03-12T18:45:57.8102198Z       |                                    ^~~~~~~~~~~
2025-03-12T18:45:57.8102649Z       |                                    fetestexcept
2025-03-12T18:45:57.8144630Z /project/amrex/Src/Base/AMReX.cpp:594:21: error: 'feenableexcept' was not declared in this scope; did you mean 'feraiseexcept'?
2025-03-12T18:45:57.8146351Z   594 |                     feenableexcept(curr_fpe_excepts);  // trap floating point exceptions
2025-03-12T18:45:57.8147659Z       |                     ^~~~~~~~~~~~~~
2025-03-12T18:45:57.8148211Z       |                     feraiseexcept
2025-03-12T18:45:57.8241552Z /project/amrex/Src/Base/AMReX.cpp: In function 'void amrex::Finalize(AMReX*)':
2025-03-12T18:45:57.8242876Z /project/amrex/Src/Base/AMReX.cpp:830:13: error: 'fedisableexcept' was not declared in this scope; did you mean 'feraiseexcept'?
2025-03-12T18:45:57.8244687Z   830 |             fedisableexcept(curr_fpe_excepts);
2025-03-12T18:45:57.8245754Z       |             ^~~~~~~~~~~~~~~
2025-03-12T18:45:57.8246205Z       |             feraiseexcept
2025-03-12T18:45:57.8286837Z /project/amrex/Src/Base/AMReX.cpp:831:13: error: 'feenableexcept' was not declared in this scope; did you mean 'feraiseexcept'?
2025-03-12T18:45:57.8287996Z   831 |             feenableexcept(prev_fpe_excepts);
2025-03-12T18:45:57.8288608Z       |             ^~~~~~~~~~~~~~
2025-03-12T18:45:57.8290043Z       |             feraiseexcept
2025-03-12T18:45:57.8384040Z /project/amrex/Src/Base/AMReX.cpp: In function 'amrex::FPExcept amrex::getFPExcept()':
2025-03-12T18:45:57.8385386Z /project/amrex/Src/Base/AMReX.cpp:946:20: error: 'fegetexcept' was not declared in this scope; did you mean 'fetestexcept'?
2025-03-12T18:45:57.8387144Z   946 |     auto excepts = fegetexcept();
2025-03-12T18:45:57.8387583Z       |                    ^~~~~~~~~~~
2025-03-12T18:45:57.8387965Z       |                    fetestexcept
2025-03-12T18:45:57.8440571Z /project/amrex/Src/Base/AMReX.cpp: In function 'amrex::FPExcept amrex::setFPExcept(FPExcept)':
2025-03-12T18:45:57.8441877Z /project/amrex/Src/Base/AMReX.cpp:959:5: error: 'fedisableexcept' was not declared in this scope; did you mean 'disableFPExcept'?
2025-03-12T18:45:57.8443618Z   959 |     fedisableexcept(flags);
2025-03-12T18:45:57.8444166Z       |     ^~~~~~~~~~~~~~~
2025-03-12T18:45:57.8444686Z       |     disableFPExcept
2025-03-12T18:45:57.8495493Z /project/amrex/Src/Base/AMReX.cpp:964:5: error: 'feenableexcept' was not declared in this scope; did you mean 'feraiseexcept'?
2025-03-12T18:45:57.8514793Z   964 |     feenableexcept(flags);
2025-03-12T18:45:57.8515706Z       |     ^~~~~~~~~~~~~~
2025-03-12T18:45:57.8516209Z       |     feraiseexcept
2025-03-12T18:45:57.8552656Z /project/amrex/Src/Base/AMReX.cpp: In function 'amrex::FPExcept amrex::disableFPExcept(FPExcept)':
2025-03-12T18:45:57.8554349Z /project/amrex/Src/Base/AMReX.cpp:979:5: error: 'fedisableexcept' was not declared in this scope; did you mean 'disableFPExcept'?
2025-03-12T18:45:57.8556262Z   979 |     fedisableexcept(flags);
2025-03-12T18:45:57.8556646Z       |     ^~~~~~~~~~~~~~~
2025-03-12T18:45:57.8556979Z       |     disableFPExcept
2025-03-12T18:45:57.8606731Z /project/amrex/Src/Base/AMReX.cpp: In function 'amrex::FPExcept amrex::enableFPExcept(FPExcept)':
2025-03-12T18:45:57.8608424Z /project/amrex/Src/Base/AMReX.cpp:994:5: error: 'feenableexcept' was not declared in this scope; did you mean 'feraiseexcept'?
2025-03-12T18:45:57.8610129Z   994 |     feenableexcept(flags);
2025-03-12T18:45:57.8610504Z       |     ^~~~~~~~~~~~~~
2025-03-12T18:45:57.8610825Z       |     feraiseexcept

Seen in https://github.com/BLAST-ImpactX/impactx-wheels

@ax3l ax3l changed the title Compling with musl Compling with musl libc (Alpine Linux) Mar 12, 2025
@WeiqunZhang WeiqunZhang linked a pull request Mar 13, 2025 that will close this issue
@ax3l ax3l closed this as completed in 5b19359 Mar 14, 2025
@ax3l ax3l reopened this Mar 21, 2025
@ax3l
Copy link
Member Author

ax3l commented Mar 21, 2025

There is a bit more:

/home/runner/work/amrex/amrex/Src/Base/AMReX_BLBackTrace.cpp:39:10: fatal error: execinfo.h: No such file or directory
   39 | #include <execinfo.h>
      |          ^~~~~~~~~~~~
compilation terminated.

(see runner in #4375)

@ax3l
Copy link
Member Author

ax3l commented Mar 21, 2025

And a potential bug:

In file included from /usr/include/c++/14.2.0/bits/alloc_traits.h:33,
                 from /usr/include/c++/14.2.0/ext/alloc_traits.h:34,
                 from /usr/include/c++/14.2.0/bits/basic_string.h:39,
                 from /usr/include/c++/14.2.0/string:54,
                 from /usr/include/c++/14.2.0/bits/locale_classes.h:40,
                 from /usr/include/c++/14.2.0/bits/ios_base.h:41,
                 from /usr/include/c++/14.2.0/ios:44,
                 from /usr/include/c++/14.2.0/ostream:40,
                 from /usr/include/c++/14.2.0/iostream:41,
                 from /home/runner/work/amrex/amrex/Src/Base/AMReX_Dim3.H:8,
                 from /home/runner/work/amrex/amrex/Src/Base/AMReX_Algorithm.H:7,
                 from /home/runner/work/amrex/amrex/Src/Base/AMReX_Box.H:6,
                 from /home/runner/work/amrex/amrex/Src/Base/AMReX_RealVect.H:5,
                 from /home/runner/work/amrex/amrex/Src/EB/AMReX_distFcnElement.H:5,
                 from /home/runner/work/amrex/amrex/Src/EB/AMReX_distFcnElement.cpp:1:
In function 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = double; _Args = {}]',
    inlined from 'static _ForwardIterator std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = double*; _Size = unsigned int]' at /usr/include/c++/14.2.0/bits/stl_uninitialized.h:666:23,
    inlined from 'static _ForwardIterator std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = double*; _Size = unsigned int]' at /usr/include/c++/14.2.0/bits/stl_uninitialized.h:660:9,
    inlined from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = double*; _Size = unsigned int]' at /usr/include/c++/14.2.0/bits/stl_uninitialized.h:712:20,
    inlined from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = double*; _Size = unsigned int; _Tp = double]' at /usr/include/c++/14.2.0/bits/stl_uninitialized.h:779:44,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_default_append(size_type) [with _Tp = double; _Alloc = std::allocator<double>]' at /usr/include/c++/14.2.0/bits/vector.tcc:863:35,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_default_append(size_type) [with _Tp = double; _Alloc = std::allocator<double>]' at /usr/include/c++/14.2.0/bits/vector.tcc:805:5,
    inlined from 'void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = double; _Alloc = std::allocator<double>]' at /usr/include/c++/14.2.0/bits/stl_vector.h:1016:21,
    inlined from 'void amrex::SplineDistFcnElement2d::calc_D(bool)' at /home/runner/work/amrex/amrex/Src/EB/AMReX_distFcnElement.cpp:231:14:
/usr/include/c++/14.2.0/bits/stl_construct.h:119:7: error: null pointer dereference [-Werror=null-dereference]
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant