I would like to use musl with OpenMP. However, when I compile a simple OpenMP program such as
int main() {
int i;
#pragma omp parallel for
for(i=0; i<100; i++) {
printf("asdf\n");
}
}
with
musl-gcc -fopenmp foo.c
I get the error
/usr/bin/ld: h_errno: TLS definition in //lib/x86_64-linux-gnu/libc.so.6 section .tbss mismatches non-TLS definition in /usr/local/musl/lib/libc.so section .bss
//lib/x86_64-linux-gnu/libc.so.6: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Apperently there is a problem related to thread local storage (TLS). How can I get musl working with OpenMP?
I'm currently using Ubuntu 14.04, GCC 4.9.1, EGLIBC 2.19, on a Intel(R) Xeon(R) CPU E5-1620.
Here is what is sent to the linker which I found from the collect2 tag from musl-gcc -v -fopenmp omp.o
. I converted most of the spaces to newlines. The only difference between this and doing this without the -fopenmp
option is the addition of the pthread
and gomp
.
-plugin /usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccPvNBKp.res
-plugin-opt=-pass-through=/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a
-plugin-opt=-pass-through=/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a
-plugin-opt=-pass-through=-lpthread
-plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a
-plugin-opt=-pass-through=/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a
-dynamic-linker
/lib/ld-musl-x86_64.so.1
-nostdlib
-z relro
/usr/local/musl/lib/crt1.o
/usr/local/musl/lib/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o
-L/usr/local/musl/lib
-L /usr/lib/gcc/x86_64-linux-gnu/4.9/.
omp.o
-lgomp
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a
-lpthread
-lc
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o
/usr/local/musl/lib/crtn.o
Here is the output from musl-gcc -fopenmpomp.c -Wl,--trace
/usr/bin/ld: mode elf_x86_64
/usr/local/musl/lib/crt1.o
/usr/local/musl/lib/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o
-lc (/usr/local/musl/lib/libc.so)
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o
/usr/local/musl/lib/crtn.o
/usr/local/musl/lib/crt1.o