DrTimothyAldenDavis / SuiteSparse

The official SuiteSparse library: a suite of sparse matrix algorithms authored or co-authored by Tim Davis, Texas A&M University.
https://people.engr.tamu.edu/davis/suitesparse.html
Other
1.19k stars 265 forks source link

Compilation Error in ParU string printing macro #769

Closed rayegun closed 6 months ago

rayegun commented 9 months ago

I'm currently trying to build ParU for distribution in Julia's package manager. I'll be up front and say that sometimes there are issues due to the BinaryBuilder build environment. But we compile the rest of SuiteSparse just fine.

98% of the way through compilation of ParU the following errors are thrown:

In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp: In function ‘void paru_print_element(int64_t, paru_work*, ParU_Numeric*)’:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:27:35: note: in expansion of macro ‘LD’
         printf("%% paru_element " LD " is out of range; just " LD " elements \n", e,
                                   ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:27:15: note: to match this ‘(’
         printf("%% paru_element " LD " is out of range; just " LD " elements \n", e,
               ^
In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:34:35: note: in expansion of macro ‘LD’
         printf("%% paru_element " LD " is empty\n", e);
                                   ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:34:15: note: to match this ‘(’
         printf("%% paru_element " LD " is empty\n", e);
               ^
In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:51:31: note: in expansion of macro ‘LD’
     printf("%% paru_element " LD " is " LD " x " LD ":\n", e, m, n);
                               ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:51:11: note: to match this ‘(’
     printf("%% paru_element " LD " is " LD " x " LD ":\n", e, m, n);
           ^
In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:57:46: note: in expansion of macro ‘LD’
     for (int j = 0; j < n; j++) printf("%% " LD "\t", el_colIndex[j]);
                                              ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:57:39: note: to match this ‘(’
     for (int j = 0; j < n; j++) printf("%% " LD "\t", el_colIndex[j]);
                                       ^
In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:63:22: note: in expansion of macro ‘LD’
         printf("%% " LD "\t", el_rowIndex[i]);
                      ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:63:15: note: to match this ‘(’
         printf("%% " LD "\t", el_rowIndex[i]);
               ^
In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp: In function ‘void paru_print_paru_tupleList(paru_tupleList*, int64_t)’:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:88:28: note: in expansion of macro ‘LD’
     printf("%% There are " LD " tuples in this list:\n %%", numTuple);
                            ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:88:11: note: to match this ‘(’
     printf("%% There are " LD " tuples in this list:\n %%", numTuple);
           ^
In file included from /workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:14:
/workspace/srcdir/SuiteSparse/ParU/Source/paru_internal.hpp:61:16: error: expected ‘)’ before ‘PRId64’
 #define LD "%" PRId64
                ^~~~~~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:92:21: note: in expansion of macro ‘LD’
         printf(" (" LD "," LD ")", curTpl.e, curTpl.f);
                     ^~
/workspace/srcdir/SuiteSparse/ParU/Source/paru_print.cpp:92:15: note: to match this ‘(’
         printf(" (" LD "," LD ")", curTpl.e, curTpl.f);
               ^
make[2]: *** [ParU/CMakeFiles/ParU.dir/build.make:468: ParU/CMakeFiles/ParU.dir/Source/paru_print.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

CC:

sandbox:${WORKSPACE}/srcdir/SuiteSparse # cc --version
x86_64-linux-gnu-gcc (GCC) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rayegun commented 9 months ago

The compilation script was:

BLAS_NAME=blastrampoline
    if [[ "${target}" == *-mingw* ]]; then
        BLAS_LIB=${BLAS_NAME}-5
    else
        BLAS_LIB=${BLAS_NAME}
    fi

    if [[ ${bb_full_target} == *-sanitize+memory* ]]; then
        # Install msan runtime (for clang)
        cp -rL ${libdir}/linux/* /opt/x86_64-linux-musl/lib/clang/*/lib/linux/
    fi

    if [[ ${nbits} == 64 ]]; then
        CMAKE_OPTIONS=(
            -DBLAS64_SUFFIX="_64"
            -DSUITESPARSE_USE_64BIT_BLAS=YES
        )
    else
        CMAKE_OPTIONS=(
            -DSUITESPARSE_USE_64BIT_BLAS=NO
        )
    fi
    if [[ "${target}" == *-mingw* ]] && [[ "${GRAPHBLAS}" == "true" ]]; then
        CMAKE_OPTIONS+=(-DGBNCPUFEAT=1)
    fi
    cmake -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_INSTALL_PREFIX=${prefix} \
          -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
          -DCMAKE_FIND_ROOT_PATH=${prefix} \
          -DBUILD_STATIC_LIBS=OFF \
          -DBUILD_TESTING=OFF \
          -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;colamd;camd;ccolamd;umfpack;paru" \
          -DSUITESPARSE_DEMOS=OFF \
          -DSUITESPARSE_USE_STRICT=ON \
          -DSUITESPARSE_USE_CUDA=OFF \
          -DSUITESPARSE_USE_FORTRAN=OFF \
          -DSUITESPARSE_USE_OPENMP=ON \
          -DCHOLMOD_PARTITION=ON \
          -DBLAS_FOUND=1 \
          -DBLAS_LIBRARIES="${libdir}/lib${BLAS_LIB}.${dlext}" \
          -DBLAS_LINKER_FLAGS="${BLAS_LIB}" \
          -DBLA_VENDOR="${BLAS_NAME}" \
          -DLAPACK_LIBRARIES="${libdir}/lib${BLAS_LIB}.${dlext}" \
          -DLAPACK_LINKER_FLAGS="${BLAS_LIB}" \
          "${CMAKE_OPTIONS[@]}" \
          .
    make -j3

I am looking to see if I can reproduce the errors locally right now

DrTimothyAldenDavis commented 8 months ago

Thanks on Windows, right? I haven't seen that issue come up in my CI for SuiteSparse.

I'm working on ParU now. I should probably just remove printf and fprintf and use std::cout instead. Then I could avoid using PRId64 and related C-style macros.

mmuetzel commented 8 months ago

PRId64 and similar macros are defined in cinttypes (https://en.cppreference.com/w/cpp/types/integer). Maybe that header happens to be included indirectly for some platforms, compilers or STL implementations when paru_internal.hpp gets included in that compilation unit. So, it is "working for some". But it probably wouldn't hurt to directly include that header in paru_internal.hpp. Maybe, that would avoid that error in your build environment.

Edit: Cited wrong C++ header. Should be correct now.

mmuetzel commented 8 months ago

See #772 for a PR that includes that header. Does that make a difference for you?

rayegun commented 6 months ago

Fixed by that PR which was included in 7.7 thanks!

DrTimothyAldenDavis commented 6 months ago

ParU is undergoing a lot of changes for its 1.0 release. It's in the paru_dev2 branch.