AvxWindowFmIndex icon indicating copy to clipboard operation
AvxWindowFmIndex copied to clipboard

Submodule divsfusort is missing OpenMP symbols when statically built

Open EricR86 opened this issue 1 year ago • 6 comments

When building a simple example and attempting to statically link in the libraries using the instructions from the README, the following error occurs:

/usr/bin/ld: ../AvxWindowFmIndex/build/libdivsufsort64.a(divsufsort.o): in function `sort_typeBstar._omp_fn.0':
divsufsort.c:(.text+0x40): undefined reference to `omp_get_thread_num'
/usr/bin/ld: divsufsort.c:(.text+0x7c): undefined reference to `GOMP_critical_name_end'
/usr/bin/ld: divsufsort.c:(.text+0xcf): undefined reference to `GOMP_critical_name_start'
/usr/bin/ld: divsufsort.c:(.text+0x12f): undefined reference to `GOMP_critical_name_end'
/usr/bin/ld: ../AvxWindowFmIndex/build/libdivsufsort64.a(divsufsort.o): in function `sort_typeBstar':
divsufsort.c:(.text+0x39d): undefined reference to `omp_get_max_threads'
/usr/bin/ld: divsufsort.c:(.text+0x421): undefined reference to `GOMP_parallel'

EricR86 avatar Feb 20 '24 20:02 EricR86

It it worth noting that the shared object of libawfmindex.so does end up linking to OpenMP:

$ ldd libawfmindex.so 
        linux-vdso.so.1 (0x00007fff16327000)
        libfastavector.so => /home/ericr/work/umap-fmindex/AvxWindowFmIndex/lib/FastaVector/build/libfastavector.so (0x00007f8aa3a6a000)
        libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f8aa3a17000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8aa37ef000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8aa3a88000)

EricR86 avatar Feb 20 '24 20:02 EricR86

Hi Eric, can you please tell me what OS you are attempting to compile on? iOS's builtin "gcc" is actually an old version of clang, which doesn't support openmp, and it's been a bit of a thorn in our side for a while to work around.

Sawwave avatar Feb 21 '24 00:02 Sawwave

also, just for sanity, if you are on iOS, did you install gcc with brew and give the path to the cmake?

cmake -DCMAKE_C_COMPILER=/path/to/gcc .

Sawwave avatar Feb 21 '24 01:02 Sawwave

Using WSL (linux) currently.

FWIW I'm working around this by simply including -lgomp in my builds though I assume one of the static libraries should linking to it through the cmake build.

EricR86 avatar Feb 21 '24 13:02 EricR86

Hi @EricR86 , I've added some changes that should fix your issues on WSL. I've tested it myself, but before I close this issue, I would appreciate it if you could check to make sure it's working for you.

Sawwave avatar Feb 27 '24 22:02 Sawwave

After a fresh rebuild the GOMP symbols are still undefined.

In retrospect I don't think this is a big deal, it just means that any binary using the static library has a runtime dependency on OpenMP which is not unreasonable and requires a -lgomp flag.

EricR86 avatar Feb 28 '24 18:02 EricR86

This issue has been addressed a while ago but wasn't closed.

Sawwave avatar Aug 09 '24 19:08 Sawwave