arb icon indicating copy to clipboard operation
arb copied to clipboard

arb-2.22.1 fails to build with flint2-2.8.4 ?

Open bjodah opened this issue 2 years ago • 3 comments

Hi, and thank you for your continued work on arb and flint!

I do get some compile errors (use of undeclared identifier) in bernoulli/mod_p_harvey.c.

I tried to compile arb 2.22.1 and flint 2.8.4 using clang-13 on Ubuntu 20.04, here's the script:

build-flint-arb.sh
#!/bin/bash
set -euxo pipefail
curl -Ls https://github.com/wbhart/flint2/archive/refs/tags/v2.8.4.tar.gz | tar xz -C /build/
cmake \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_INSTALL_PREFIX=/opt/flint2-2.8.4-debug \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
    -DCMAKE_GENERATOR=Ninja \
    -S /build/flint2-2.8.4 \
    -B /build/flint2-2.8.4-debug
cmake --build /build/flint2-2.8.4-debug
cmake --install /build/flint2-2.8.4-debug
ln -s /build/flint2-2.8.4-debug/compile_commands.json /opt/flint2-2.8.4-debug

curl -Ls https://github.com/fredrik-johansson/arb/archive/refs/tags/2.22.1.tar.gz | tar xz -C /build/
CMAKE_PREFIX_PATH=/opt/flint2-2.8.4-debug/ cmake \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_INSTALL_PREFIX=/opt/arb-2.22.1-debug \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
    -DCMAKE_GENERATOR=Ninja \
    -S /build/arb-2.22.1 \
    -B /build/arb-2.22.1-debug
cmake --build /build/arb-2.22.1-debug
cmake --install /build/arb-2.22.1-debug
ln -s /build/arb-2.22.1-debug/compile_commands.json /opt/arb-2.22.1-debug
Output log (/.../ indicates where I've cut out lines with no warnings between them)
+ curl -Ls https://github.com/wbhart/flint2/archive/refs/tags/v2.8.4.tar.gz
+ tar xz -C /build/
+ cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/opt/flint2-2.8.4-debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_GENERATOR=Ninja -S /build/flint2-2.8.4 -B /build/flint2-2.8.4-debug
-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang-13 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++-13 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GMP: /usr/include/x86_64-linux-gnu (Required is at least version "6.0.0") 
-- Found MPFR: /usr/include (Required is at least version "1.0.0") 
-- Found PythonInterp: /usr/bin/python (found version "3.8.10") 
-- Found CBLAS: /usr/include/x86_64-linux-gnu  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test HAS_FLAG_MPOPCNT
-- Performing Test HAS_FLAG_MPOPCNT - Success
-- Performing Test HAS_FLAG_UNROLL_LOOPS
-- Performing Test HAS_FLAG_UNROLL_LOOPS - Success
-- Performing Test FLINT_USES_POPCNT
-- Performing Test FLINT_USES_POPCNT - Success
-- Performing Test FLINT_USES_FENV
-- Performing Test FLINT_USES_FENV - Success
-- Performing Test FLINT_USES_CPUSET
-- Performing Test FLINT_USES_CPUSET - Failed
-- Using FLINT memory manager: reentrant
-- Checking for IPO
-- Checking for IPO - found
-- Configuring done
-- Generating done
-- Build files have been written to: /build/flint2-2.8.4-debug
+ cmake --build /build/flint2-2.8.4-debug
[1/3851] Building C object CMakeFiles/flint.dir/fprintf.c.o
/../
[2875/3851] Building C object CMakeFiles/flint.dir/mpoly/test_irreducible.c.o
/build/flint2-2.8.4/mpoly/test_irreducible.c:843:49: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
            if (FLINT_MIN(lox, loy)  (y) ? (y) : (x))
                          ^  ~
/build/arb-2.22.1/acb_hypgeom/pfq_choose_n.c:222:32: warning: implicit conversion from 'long' to 'double' changes value from 4611686018427387903 to 4611686018427387904 [-Wimplicit-const-int-float-conversion]
    n_max = FLINT_MIN(WORD_MAX / 2, 50 + 10.0 * prec);
            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/flint.h:292:27: note: expanded from macro 'FLINT_MIN'
#define FLINT_MIN(x, y) ((x) > (y) ? (y) : (x))
                          ^  ~
2 warnings generated.
[298/1367] Building C object CMakeFiles/arb.dir/acb_hypgeom/li_series.c.o
/.../
[324/1367] Building C object CMakeFiles/arb.dir/acb_hypgeom/u_asymp.c.o
/build/arb-2.22.1/acb_hypgeom/u_asymp.c:351:57: warning: implicit conversion from 'long' to 'double' changes value from 4611686018427387903 to 4611686018427387904 [-Wimplicit-const-int-float-conversion]
                    prec + moreprec, FLINT_MIN(WORD_MAX / 2, 50 + 10.0 * prec));
                                     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/flint.h:292:27: note: expanded from macro 'FLINT_MIN'
#define FLINT_MIN(x, y) ((x) > (y) ? (y) : (x))
                          ^  ~
1 warning generated.
[325/1367] Building C object CMakeFiles/arb.dir/acb_hypgeom/spherical_y.c.o
/.../
[1367] Building C object CMakeFiles/arb.dir/arb_hypgeom/legendre_p_ui.c.o
/build/arb-2.22.1/arb_hypgeom/legendre_p_ui.c:212:38: warning: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-const-int-float-conversion]
            K_one = FLINT_MIN(K_one, UWORD_MAX * 0.25);
                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/flint.h:141:19: note: expanded from macro 'UWORD_MAX'
#define UWORD_MAX ULONG_MAX
                  ^
/usr/lib/llvm-13/lib/clang/13.0.0/include/limits.h:57:37: note: expanded from macro 'ULONG_MAX'
#define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
                                    ^
/opt/flint2-2.8.4-debug/include/flint/flint.h:292:33: note: expanded from macro 'FLINT_MIN'
#define FLINT_MIN(x, y) ((x) > (y) ? (y) : (x))
                                ^
/build/arb-2.22.1/arb_hypgeom/legendre_p_ui.c:212:38: warning: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-const-int-float-conversion]
            K_one = FLINT_MIN(K_one, UWORD_MAX * 0.25);
                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/flint.h:141:19: note: expanded from macro 'UWORD_MAX'
#define UWORD_MAX ULONG_MAX
                  ^
/usr/lib/llvm-13/lib/clang/13.0.0/include/limits.h:57:37: note: expanded from macro 'ULONG_MAX'
#define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
                                    ^
/opt/flint2-2.8.4-debug/include/flint/flint.h:292:39: note: expanded from macro 'FLINT_MIN'
#define FLINT_MIN(x, y) ((x) > (y) ? (y) : (x))
                                      ^
2 warnings generated.
[849/1367] Building C object CMakeFiles/arb.dir/arb_hypgeom/legendre_p_ui_root.c.o
/.../
[871/1367] Building C object CMakeFiles/arb.dir/arb_hypgeom/sum_fmpq_arb_rs.c.o
/build/arb-2.22.1/arb_hypgeom/sum_fmpq_arb_rs.c:48:16: warning: implicit conversion from 'long' to 'double' changes value from -4611686018427387903 to -4611686018427387904 [-Wimplicit-const-int-float-conversion]
        return COEFF_MIN;
        ~~~~~~ ^~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/fmpz.h:72:20: note: expanded from macro 'COEFF_MIN'
#define COEFF_MIN (-((WORD(1)  0 && s 

bjodah avatar Feb 28 '22 07:02 bjodah

Since the the undefined variables only appear in FLINT_ASSERT macros, I simply patch mod_p_harvey.c using sed:

$ sed -i '/    FLINT_ASSERT/d' /build/arb-2.22.1/bernoulli/mod_p_harvey.c

so no rush to fix this. I did see quite a few warnings during compilation (as seen in the log), but I obviously don't have the expertise to judge if any of those are worrisome or not.

bjodah avatar Feb 28 '22 08:02 bjodah

Thanks for reporting.

You're right, it's just the asserts that are broken (I have not tested with asserts enabled). This should be easy to fix.

The other warnings should be harmless, but would be good to fix to keep things clean.

fredrik-johansson avatar Feb 28 '22 08:02 fredrik-johansson

The asserts should be fixed now.

fredrik-johansson avatar Mar 01 '22 12:03 fredrik-johansson