magv / feynson

A tool for Feynman integral symmetries.
2 stars 1 forks source link

Issues compiling feynson with gcc 12 #1

Closed vsht closed 1 year ago

vsht commented 1 year ago

Hi,

I noticed that trying to build feynson using gcc 12.2.1 (shipped with Fedora 37) results into

g++  -O3 -g -std=c++14 -pedantic -Wall -Wextra -Wfatal-errors -Wno-sequence-point -pipe -fno-omit-frame-pointer -fpermissive -include version.h -o feynson feynson.cpp  -lginac -lcln -ldl -lgmp -lnauty
In file included from /usr/include/nauty/nausparse.h:26,
                 from feynson.cpp:156:
feynson.cpp: In function ‘std::vector<unsigned char> canonical_variable_permutation(const std::vector<std::pair<std::vector<int>, int> >&, unsigned int)’:
feynson.cpp:862:5: error: ‘_Thread_local’ does not name a type; did you mean ‘thread_local’?
  862 |     DYNALLSTAT(int, lab, lab_sz);
      |     ^~~~~~~~~~
compilation terminated due to -Wfatal-errors.
make: *** [Makefile:18: feynson] Error 1

Compiling it with clang works though

env CC=clang CXX=clang++ make
clang++  -O3 -g -std=c++14 -pedantic -Wall -Wextra -Wfatal-errors -Wno-sequence-point -pipe -fno-omit-frame-pointer -fpermissive -include version.h -o feynson feynson.cpp  -lginac -lcln -ldl -lgmp -lnauty
feynson.cpp:862:5: warning: '_Thread_local' is a C11 extension [-Wc11-extensions]
    DYNALLSTAT(int, lab, lab_sz);
    ^
/usr/include/nauty/nauty.h:1241:16: note: expanded from macro 'DYNALLSTAT'
        static TLS_ATTR type *name; static TLS_ATTR size_t name_sz=0
               ^
/usr/include/nauty/nauty.h:47:18: note: expanded from macro 'TLS_ATTR'
#define TLS_ATTR _Thread_local
                 ^
feynson.cpp:862:5: warning: '_Thread_local' is a C11 extension [-Wc11-extensions]
/usr/include/nauty/nauty.h:1241:44: note: expanded from macro 'DYNALLSTAT'
        static TLS_ATTR type *name; static TLS_ATTR size_t name_sz=0
                                           ^
/usr/include/nauty/nauty.h:47:18: note: expanded from macro 'TLS_ATTR'
#define TLS_ATTR _Thread_local
                 ^
feynson.cpp:863:5: warning: '_Thread_local' is a C11 extension [-Wc11-extensions]
    DYNALLSTAT(int, ptn, ptn_sz);
    ^
/usr/include/nauty/nauty.h:1241:16: note: expanded from macro 'DYNALLSTAT'
        static TLS_ATTR type *name; static TLS_ATTR size_t name_sz=0
               ^
/usr/include/nauty/nauty.h:47:18: note: expanded from macro 'TLS_ATTR'
#define TLS_ATTR _Thread_local
                 ^
feynson.cpp:863:5: warning: '_Thread_local' is a C11 extension [-Wc11-extensions]
/usr/include/nauty/nauty.h:1241:44: note: expanded from macro 'DYNALLSTAT'
        static TLS_ATTR type *name; static TLS_ATTR size_t name_sz=0
                                           ^
/usr/include/nauty/nauty.h:47:18: note: expanded from macro 'TLS_ATTR'
#define TLS_ATTR _Thread_local
                 ^
feynson.cpp:864:5: warning: '_Thread_local' is a C11 extension [-Wc11-extensions]
    DYNALLSTAT(int, orbits, orbits_sz);
    ^
/usr/include/nauty/nauty.h:1241:16: note: expanded from macro 'DYNALLSTAT'
        static TLS_ATTR type *name; static TLS_ATTR size_t name_sz=0
               ^
/usr/include/nauty/nauty.h:47:18: note: expanded from macro 'TLS_ATTR'
#define TLS_ATTR _Thread_local
                 ^
feynson.cpp:864:5: warning: '_Thread_local' is a C11 extension [-Wc11-extensions]
/usr/include/nauty/nauty.h:1241:44: note: expanded from macro 'DYNALLSTAT'
        static TLS_ATTR type *name; static TLS_ATTR size_t name_sz=0
                                           ^
/usr/include/nauty/nauty.h:47:18: note: expanded from macro 'TLS_ATTR'
#define TLS_ATTR _Thread_local
                 ^
6 warnings generated.

Cheers, Vladyslav

magv commented 1 year ago

Hi, Vlad. I think your copy of nauty was configured with --enable-tls, which is not the default. Unfortunately I don't see an easy way to disable it after it was configured that way, because #define USE_TLS is hardcoded into nauty.h. I could just not use DYNALLSTAT() though. Could you try the latest commit?

Come to think of it, it's strange in the first place that Nauty asks users to define their dynamically allocated structures as static. I guess that could help by not needing to reallocate the structures every time, but because I call DYNFREE() at the end of canonical_variable_permutation() anyway, this benefit is not really there.

vsht commented 1 year ago

Hi Vitaly,

many thanks for the quick fix. I can confirm that now feynson can be compiled using gcc 12.