Skip to content

clang OmpSs-2: ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC

Building a simple OmpSs-2 program fails:

this derivation will be built:
  /nix/store/315rr7zljdml7bhpfkskqvnh60aahhwl-task_c.drv
building '/nix/store/315rr7zljdml7bhpfkskqvnh60aahhwl-task_c.drv'...
patching sources
building
++ echo CC=clang
CC=clang
++ clang -v
clang version 16.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/bin
++ cp /nix/store/8iy5yac47jamxmgv21yf955lzy7gbann-task.c task.c
++ cat task.c
#include <stdio.h>

int main()
{
    for (int i = 0; i < 10; i++) {
        #pragma oss task
        printf("Hello world!\n");
    }

    return 0;
}
++ clang -v -fompss-2 task.c -o task
clang version 16.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/bin
 "/nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/bin/clang-16" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name task.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/build -resource-dir /nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/lib/clang/16.0.0 -I /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/include -idirafter /nix/store/l1a7p8yp0nlvghq5vifz4qr6s11frxl5-glibc-2.35-224-dev/include -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -internal-isystem /nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wformat -Wformat-security -Werror=format-security -fdebug-compilation-dir=/build -ferror-limit 19 -fompss-2 -fwrapv -stack-protector 2 -stack-protector-buffer-size 4 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /build/task-51eea4.o -x c task.c
clang -cc1 version 16.0.0 based upon LLVM 16.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/include
 /nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/lib/clang/16.0.0/include
 /nix/store/l1a7p8yp0nlvghq5vifz4qr6s11frxl5-glibc-2.35-224-dev/include
End of search list.
 "/nix/store/1pq2hm4p2kchxv2158ljln60vbiadmsy-clang-ompss2-wrapper-2022.11/bin/ld" -pie --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o task /nix/store/2j8jqmnd9l7plihhf713yf291c9vyqjm-glibc-2.35-224/lib/Scrt1.o /nix/store/2j8jqmnd9l7plihhf713yf291c9vyqjm-glibc-2.35-224/lib/crti.o /nix/store/qm03mh5x2j4ls0y80y8h3zsyj4hb52w2-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtbeginS.o -L/nix/store/2j8jqmnd9l7plihhf713yf291c9vyqjm-glibc-2.35-224/lib -L/nix/store/qm03mh5x2j4ls0y80y8h3zsyj4hb52w2-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0 -L/nix/store/v8481v3a686aa0pa4d016c0lnz2j0wwb-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib -L/nix/store/vlgk1dcdkrfb8dqih7hliaqdffvvigcg-clang-ompss2-2022.11/lib -L/nix/store/qm03mh5x2j4ls0y80y8h3zsyj4hb52w2-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0 -L/nix/store/v8481v3a686aa0pa4d016c0lnz2j0wwb-gcc-11.3.0-lib/lib -dynamic-linker=/nix/store/2j8jqmnd9l7plihhf713yf291c9vyqjm-glibc-2.35-224/lib/ld-linux-x86-64.so.2 /build/task-51eea4.o -rpath /nix/store/wqn60bf1z8dpgfwbizdnz6dnx1fv73h1-task_c/lib64 -rpath /nix/store/wqn60bf1z8dpgfwbizdnz6dnx1fv73h1-task_c/lib /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o -z lazy -L /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib -rpath /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib -lnanos6 -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /nix/store/qm03mh5x2j4ls0y80y8h3zsyj4hb52w2-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtendS.o /nix/store/2j8jqmnd9l7plihhf713yf291c9vyqjm-glibc-2.35-224/lib/crtn.o
ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
>>> defined in /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o
>>> referenced by intercept-main-glibc.c:41 (loader/intercept-main-glibc.c:41)
>>>               /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o:(__libc_start_main)

ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
>>> defined in /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o
>>> referenced by intercept-main-glibc.c:43 (loader/intercept-main-glibc.c:43)
>>>               /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o:(__libc_start_main)

ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
>>> defined in /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o
>>> referenced by intercept-main-glibc.c:43 (loader/intercept-main-glibc.c:43)
>>>               /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o:(__libc_start_main)

ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
>>> defined in /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o
>>> referenced by intercept-main-glibc.c:43 (loader/intercept-main-glibc.c:43)
>>>               /nix/store/rlfvnn6q6lfhb5klkqrf9zapgw9bphlr-nanos6-2.8/lib/nanos6-main-wrapper.o:(__libc_start_main)

ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
...

CC @rpenacob