ecmwf / eckit

A C++ toolkit that supports development of tools and applications at ECMWF.

Home Page:https://confluence.ecmwf.int/display/eckit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eckit fails to build on macOS using Intel compilers

kgerheiser opened this issue · comments

I get an error when using Intel compilers on macOS. It's related to handle_strerror_r. It attempts to pass a type int to char *. So, I think the first #ifdef _GNU_SOURCE is being used which accepts a char *, but should be using the second function definition with #elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || _POSIX_VERSION >= 200112L || _XOPEN_VERSION >= 600) which does take an int.

Maybe a preprocessor check like __INTEL_COMPILER and APPLE? I guess _GNU_SOURCE is defined but Intel by the function template doesn't match.

Using Intel 2021.4.0 compilers, and macOS 11.6.5

#if defined(_GNU_SOURCE)
/* To use with GNU libc strerror_r */
static void handle_strerror_r(std::ostream& s, int e, char[], char* p) {
if (p) {
s << " (" << p << ")";
}
else {
s << " (errno = " << e << ") ";
}
}
#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || _POSIX_VERSION >= 200112L || _XOPEN_VERSION >= 600)
/* To use with XSI-compliant strerror_r
*
* Linux defines _POSIX_C_SOURCE and _XOPEN_SOURCE
* BSD defines _POSIX_VERSION and _XOPEN_VERSION
* glibc defines _GNU_SOURCE and implements a non-XSI compliant strerror_r
*/
static void handle_strerror_r(std::ostream& s, int e, char es[], int hs) {
if (hs == 0) {
s << " (" << es << ") ";
}
else {
s << " (errno = " << e << ") ";
}
}

   eckit.dir/log/SavedStatus.cc.o -c /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src/eckit/log/SavedStatus.cc
  >> 679    /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src/eckit/log/Log.cc(367): error: argument of type "int" is incompatible with parameter of type "char *"
     680          handle_strerror_r(s, e, estr, strerror_r(e, estr, sizeof(estr)));
     681                                        ^
     682
     683    [ 27%] Building CXX object src/eckit/CMakeFiles/eckit.dir/log/Seconds.cc.o
     684    cd /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-build-xru6mio/src/eckit && /Users/KIG/Desktop/hpc-stack/install/intel-2021.4/mpich/3.4.2/bin/mpic++ -Deckit_EXPORTS -I/Users/KIG/Desktop/spack-stack/cache/build_s
            tage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-build-xru6mio/src -I/Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src -I/Users/KIG/Desktop/spack-stack/envs/all.default/install/intel/2021
            .4.0/lz4-1.9.3-cn5gcbi/include -I/opt/local/include -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -O2 -g -DNDEBUG -std=gnu++11 -MD -MT src/eckit/CMakeFiles/eckit.dir/log/Seconds.cc.o -MF CMakeFiles/eckit.dir/log/Seconds.cc.o.d -o CMakeFiles/eckit.di
            r/log/Seconds.cc.o -c /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src/eckit/log/Seconds.cc
     685    [ 27%] Building CXX object src/eckit/CMakeFiles/eckit.dir/log/Statistics.cc.o
     ...

     689    remark #11074: Inlining inhibited by limit max-size
     690    remark #11074: Inlining inhibited by limit max-total-size
     691    remark #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo
     692    [ 28%] Building CXX object src/eckit/CMakeFiles/eckit.dir/log/SysLog.cc.o
     693    cd /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-build-xru6mio/src/eckit && /Users/KIG/Desktop/hpc-stack/install/intel-2021.4/mpich/3.4.2/bin/mpic++ -Deckit_EXPORTS -I/Users/KIG/Desktop/spack-stack/cache/build_s
            tage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-build-xru6mio/src -I/Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src -I/Users/KIG/Desktop/spack-stack/envs/all.default/install/intel/2021
            .4.0/lz4-1.9.3-cn5gcbi/include -I/opt/local/include -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -O2 -g -DNDEBUG -std=gnu++11 -MD -MT src/eckit/CMakeFiles/eckit.dir/log/SysLog.cc.o -MF CMakeFiles/eckit.dir/log/SysLog.cc.o.d -o CMakeFiles/eckit.dir/
            log/SysLog.cc.o -c /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src/eckit/log/SysLog.cc
     694    compilation aborted for /Users/KIG/Desktop/spack-stack/cache/build_stage/spack-stage-eckit-1.18.0-xru6mio4qaly46azyjnghicrlbtfukpz/spack-src/src/eckit/log/Log.cc (code 2)
  >> 695    make[2]: *** [src/eckit/CMakeFiles/eckit.dir/log/Log.cc.o] Error 2
     696    make[2]: *** Waiting for unfinished jobs....
     697    remark #11074: Inlining inhibited by limit max-total-size
     698    remark #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo
     699    remark #11074: Inlining inhibited by limit max-total-size
     700    remark #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo
     701    remark #11074: Inlining inhibited by limit max-total-size
     702    remark #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo
     703    remark #11074: Inlining inhibited by limit max-total-size
     704    remark #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo
  >> 705    make[1]: *** [src/eckit/CMakeFiles/eckit.dir/all] Error 2
  >> 706    make: *** [all] Error 2