[Openmp-commits] [PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

Sergey Dmitriev via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Sep 11 18:42:03 PDT 2019

sdmitriev added a comment.

In D64943#1666924 <https://reviews.llvm.org/D64943#1666924>, @JonChesterfield wrote:

> In D64943#1666849 <https://reviews.llvm.org/D64943#1666849>, @sdmitriev wrote:
> > In D64943#1666636 <https://reviews.llvm.org/D64943#1666636>, @JonChesterfield wrote:
> >
> > > I'm not sure copying the crtbegin/crtend mechanism from the early days of C runtime is ideal. Since the data is stored in a common section anyway, please could we rename it to __omp_offloading_entries in which case the linker will provide start/end symbols automatically?
> >
> >
> > Well, I never said that it is an ideal solution, but it is a known mechanism that works well in many cases and can also be reused for the offloading entry table.
> >  I do not fully understand your suggestion for renaming entries section, how it will help with providing start/end symbols for the entries. Can you please provide more details?
> Given a custom elf section with a C identifier as a name, the linker will provide definitions of `__start_name`/`__stop_name` to satisfy unresolved symbols. I don't believe this occurs if the section name is not a C identifier, e.g. contains a period. So unless I've misinterpreted the purpose of the two object files, they can be removed in exchange for renaming the section.
> - had to Google for the Microsoft equivalent, https://stackoverflow.com/questions/3808053/how-to-get-a-pointer-to-a-binary-section-in-msvc

Hm, I was not aware of this Linux linker feature, thanks a lot for the explanation! I see only one problem with using it as a replacement for the begin/end objects – it looks like `__start_name`/`__stop_name` symbols are created with `default` visibility instead of `hidden`. I guess it will cause problems for offload programs that use shared libraries because DSO’s `__start_name`/`__stop_name` symbols will be preempted by the executable’s symbols and that is not what we want. Is there any way to change this behavior?

As for the Windows support, you are right, `__omp_offloading_entries_begin`/`__omp_offloading_entries_end` symbols can be defined in the wrapper bit-code file with a help of the sections grouping (https://docs.microsoft.com/en-us/windows/win32/Debug/pe-format#grouped-sections-object-only). We were going to add this code to the wrapper tool later while adding Windows support.



More information about the Openmp-commits mailing list