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

Compilation Error in ParU string printing macro #769

Closed
rayegun opened this issue Feb 28, 2024 · 6 comments
Closed

Compilation Error in ParU string printing macro #769

rayegun opened this issue Feb 28, 2024 · 6 comments

Comments

@rayegun
Copy link
Contributor

rayegun commented Feb 28, 2024

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
Copy link
Contributor Author

rayegun commented Feb 28, 2024

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
Copy link
Owner

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
Copy link
Contributor

mmuetzel commented Mar 6, 2024

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
Copy link
Contributor

mmuetzel commented Mar 6, 2024

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

mmuetzel added a commit to mmuetzel/SuiteSparse that referenced this issue Mar 27, 2024
Building with "include-what-you-use" slightly increases the build time.
Since we don't need to scan every compilation unit twice, add this on top
of the runner that only builds static libraries.

Having this check might have helped to avoid issues like DrTimothyAldenDavis#769.
@rayegun
Copy link
Contributor Author

rayegun commented May 15, 2024

Fixed by that PR which was included in 7.7 thanks!

@rayegun rayegun closed this as completed May 15, 2024
@DrTimothyAldenDavis
Copy link
Owner

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

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

No branches or pull requests

3 participants