[llvm-bugs] [Bug 39885] New: lld does not link clang-compiled openmp code that uses -fopenmp-targets option

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 4 17:31:23 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39885

            Bug ID: 39885
           Summary: lld does not link clang-compiled openmp code that uses
                    -fopenmp-targets option
           Product: lld
           Version: unspecified
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: deachempat at cray.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

I have a clang compiler configured to use lld as the linker and that uses the
openmp runtime for compiling OpenMP programs.

When I compile the attached test code like this:

clang -v -dynamic -fopenmp -fopenmp-targets=x86_64 -save-temps 
omp_target_simple.c

I see the following error during the link step:

 "/home/users/deachempat/ptmp/clang-devel/fresh/build/bin/ld.lld" -z relro
--hash-style=gnu --hash-style=both --enable-new-dtags --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crti.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/crtbegin.o
-L/usr/lib64/gcc/x86_64-suse-linux/4.8
-L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib
-L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../..
-L/ptmp/deachempat/clang-devel/fresh/build/bin/../lib -L/lib -L/usr/lib
omp-target-simple-host-x86_64-unknown-linux-gnu.o -lomp -lomptarget -lgcc
--as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib64/gcc/x86_64-suse-linux/4.8/crtend.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crtn.o -T a.lk
ld.lld: error: a.lk:13: unknown command a.out-openmp-x86_64
>>>     a.out-openmp-x86_64
>>>     ^
clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)


The generated linker script looks like this:

  /*
       OpenMP Offload Linker Script
 *** Automatically generated by Clang ***
*/
TARGET(binary)
INPUT(a.out-openmp-x86_64)
SECTIONS
{
  .omp_offloading.x86_64 :
  ALIGN(0x10)
  {
    PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64 = .);
    a.out-openmp-x86_64
    PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64 = .);
  }
  .omp_offloading.entries :
  ALIGN(0x10)
  SUBALIGN(0x01)
  {
    PROVIDE_HIDDEN(.omp_offloading.entries_begin = .);
    *(.omp_offloading.entries)
    PROVIDE_HIDDEN(.omp_offloading.entries_end = .);
  }
}
INSERT BEFORE .data

I tried manually modifying a.out-openmp-x86_64 line to a.out-openmp-x86_64(*).
I then hit this error:

$ /home/users/deachempat/ptmp/clang-devel/fresh/build/bin/ld.lld -z relro
--hash-style=gnu --hash-style=both --enable-new-dtags --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crti.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/crtbegin.o
-L/usr/lib64/gcc/x86_64-suse-linux/4.8
-L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib
-L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../..
-L/ptmp/deachempat/clang-devel/fresh/build/bin/../lib -L/lib -L/usr/lib
omp-target-simple-host-x86_64-unknown-linux-gnu.o -lomp -lomptarget -lgcc
--as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib64/gcc/x86_64-suse-linux/4.8/crtend.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crtn.o -T a.lk
ld.lld: error: unable to INSERT AFTER/BEFORE .data: section not defined



Here are the sections that are defined in
omp-target-simple-host-x86_64-unknown-linux-gnu.o:

$ readelf -S -W omp-target-simple-host-x86_64-unknown-linux-gnu.o

There are 27 section headers, starting at offset 0x1340:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg
Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00     
0   0  0
  [ 1] .strtab           STRTAB          0000000000000000 000fdd 000360 00     
0   0  1
  [ 2] .text             PROGBITS        0000000000000000 000040 0004e5 00  AX 
0   0 16
  [ 3] .rela.text        RELA            0000000000000000 000b60 0001e0 18    
26   2  8
  [ 4] .group            GROUP           0000000000000000 0007f0 000024 04    
26  18  4
  [ 5] .text.startup     PROGBITS        0000000000000000 000530 000081 00 AXG 
0   0 16
  [ 6] .rela.text.startup RELA            0000000000000000 000d40 0000c0 18   G
26   5  8
  [ 7] .rodata.str1.1    PROGBITS        0000000000000000 0005b1 000029 01 AMS 
0   0  1
  [ 8] .data             PROGBITS        0000000000000000 0005e0 000048 00  WA 
0   0  8
  [ 9] .rela.data        RELA            0000000000000000 000e00 000048 18    
26   8  8
  [10] .rodata           PROGBITS        0000000000000000 000628 000001 00   A 
0   0  1
  [11] .rodata.cst16     PROGBITS        0000000000000000 000630 000020 10  AM 
0   0  8
  [12] .rodata.str1.16   PROGBITS        0000000000000000 000650 000026 01 AMS 
0   0 16
  [13] .omp_offloading.entries PROGBITS        0000000000000000 000676 000020
00   A  0   0  1
  [14] .rela.omp_offloading.entries RELA            0000000000000000 000e48
000030 18     26  13  8
  [15] .rodata..omp_offloading.device_images PROGBITS        0000000000000000
000698 000020 00  AG  0   0  8
  [16] .rela.rodata..omp_offloading.device_images RELA           
0000000000000000 000e78 000060 18   G 26  15  8
  [17] .rodata..omp_offloading.descriptor PROGBITS        0000000000000000
0006b8 000020 00  AG  0   0  8
  [18] .rela.rodata..omp_offloading.descriptor RELA            0000000000000000
000ed8 000048 18   G 26  17  8
  [19] .init_array.0     INIT_ARRAY      0000000000000000 0006d8 000008 00 WAG 
0   0  8
  [20] .rela.init_array.0 RELA            0000000000000000 000f20 000018 18   G
26  19  8
  [21] .comment          PROGBITS        0000000000000000 0006e0 000038 01  MS 
0   0  1
  [22] .note.GNU-stack   PROGBITS        0000000000000000 000718 000000 00     
0   0  1
  [23] .eh_frame         X86_64_UNWIND   0000000000000000 000718 0000d8 00   A 
0   0  8
  [24] .rela.eh_frame    RELA            0000000000000000 000f38 000090 18    
26  23  8
  [25] .llvm_addrsig     LOOS+0xfff4c03  0000000000000000 000fc8 000015 00   E
26   0  1
  [26] .symtab           SYMTAB          0000000000000000 000818 000348 18     
1  17  8
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  l (large), p (processor specific)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181205/ff3020e9/attachment-0001.html>


More information about the llvm-bugs mailing list