flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
457 stars 137 forks source link

arb-2.22.1 fails to build with flint2-2.8.4 ? #406

Closed bjodah closed 4 months ago

bjodah commented 2 years ago

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 ```bash #!/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) <= -WORD(1) << (FLINT_BITS - 3) ||
                                       ~~~~~~~~ ^
/build/flint2-2.8.4/mpoly/test_irreducible.c:883:41: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
            if (points[i].x <= -WORD(1) << (FLINT_BITS - 3) ||
                               ~~~~~~~~ ^
/build/flint2-2.8.4/mpoly/test_irreducible.c:884:41: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
                points[i].y <= -WORD(1) << (FLINT_BITS - 3) ||
                               ~~~~~~~~ ^
3 warnings generated.
[2876/3851] Building C object CMakeFiles/flint.dir/mpoly/unpack_vec.c.o
/.../
[3849/3851] Building C object CMakeFiles/flint.dir/fq_templates/sqrt.c.o
[3850/3851] Linking C shared library lib/libflint.so.16.1.4
[3851/3851] Creating library symlink lib/libflint.so.16 lib/libflint.so
+ cmake --install /build/flint2-2.8.4-debug
-- Install configuration: "Debug"
-- Installing: /opt/flint2-2.8.4-debug/lib/libflint.so.16.1.4
/.../
-- Installing: /opt/flint2-2.8.4-debug/include/flint/ulong_extras.h
+ 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
-- The C 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
-- 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  
flint2 found in /opt/flint2-2.8.4-debug/lib/libflint.so
mpfr found in /usr/lib/x86_64-linux-gnu/libmpfr.so
mpir found in /usr/lib/x86_64-linux-gnu/libgmp.so
flint/flint.h found in /opt/flint2-2.8.4-debug/include
mpfr.h found in /usr/include
gmp.h found in /usr/include/x86_64-linux-gnu
-- Configuring done
-- Generating done
-- Build files have been written to: /build/arb-2.22.1-debug
+ cmake --build /build/arb-2.22.1-debug
[1/1367] Building C object CMakeFiles/arb.dir/acb/arg.c.o
/.../
[297/1367] Building C object CMakeFiles/arb.dir/acb_hypgeom/pfq_choose_n.c.o
/build/arb-2.22.1/acb_hypgeom/pfq_choose_n.c:187:28: warning: implicit conversion from 'long' to 'double' changes value from 4611686018427387903 to 4611686018427387904 [-Wimplicit-const-int-float-conversion]
        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))
                          ^  ~
/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) << (FLINT_BITS - 2)) - WORD(1)))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/arb-2.22.1/arb_hypgeom/sum_fmpq_arb_rs.c:52:16: warning: implicit conversion from 'long' to 'double' changes value from 4611686018427387903 to 4611686018427387904 [-Wimplicit-const-int-float-conversion]
        return COEFF_MAX;
        ~~~~~~ ^~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/fmpz.h:69:50: note: expanded from macro 'COEFF_MAX'
#define COEFF_MAX ((WORD(1) << (FLINT_BITS - 2)) - WORD(1))
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/build/arb-2.22.1/arb_hypgeom/sum_fmpq_arb_rs.c:57:20: 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) << (FLINT_BITS - 2)) - WORD(1)))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/arb-2.22.1/arb_hypgeom/sum_fmpq_arb_rs.c:59:20: warning: implicit conversion from 'long' to 'double' changes value from 4611686018427387903 to 4611686018427387904 [-Wimplicit-const-int-float-conversion]
            return COEFF_MAX;
            ~~~~~~ ^~~~~~~~~
/opt/flint2-2.8.4-debug/include/flint/fmpz.h:69:50: note: expanded from macro 'COEFF_MAX'
#define COEFF_MAX ((WORD(1) << (FLINT_BITS - 2)) - WORD(1))
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
4 warnings generated.
[872/1367] Building C object CMakeFiles/arb.dir/arb_hypgeom/sum_fmpq_imag_arb_bs.c.o
/.../
[1149/1367] Building C object CMakeFiles/arb.dir/bernoulli/mod_p_harvey.c.o
FAILED: CMakeFiles/arb.dir/bernoulli/mod_p_harvey.c.o 
/usr/bin/clang-13 -DARB_BUILD_DLL -Darb_EXPORTS -I/opt/flint2-2.8.4-debug/include -I/build/arb-2.22.1 -fsanitize=address -g -fPIC -MD -MT CMakeFiles/arb.dir/bernoulli/mod_p_harvey.c.o -MF CMakeFiles/arb.dir/bernoulli/mod_p_harvey.c.o.d -o CMakeFiles/arb.dir/bernoulli/mod_p_harvey.c.o -c /build/arb-2.22.1/bernoulli/mod_p_harvey.c
/build/arb-2.22.1/bernoulli/mod_p_harvey.c:182:31: error: use of undeclared identifier 'p'
    FLINT_ASSERT(s > 0 && s < p);
                              ^
/build/arb-2.22.1/bernoulli/mod_p_harvey.c:182:31: error: use of undeclared identifier 'p'
/build/arb-2.22.1/bernoulli/mod_p_harvey.c:184:23: error: use of undeclared identifier 'max_words'
    FLINT_ASSERT(n <= max_words);
                      ^
/build/arb-2.22.1/bernoulli/mod_p_harvey.c:184:23: error: use of undeclared identifier 'max_words'
4 errors generated.
[1150/1367] Building C object CMakeFiles/arb.dir/bool_mat/all.c.o
/.../
[1158/1367] Building C object CMakeFiles/arb.dir/bool_mat/directed_path.c.o
ninja: build stopped: subcommand failed.
bjodah commented 2 years ago

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.

fredrik-johansson commented 2 years ago

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 commented 2 years ago

The asserts should be fixed now.