On Thu, Mar 20, 2014 at 05:50:13PM +0100, Bernd Schmidt wrote: > --- libgcc/crtstuff.c (revision 208706) > +++ libgcc/crtstuff.c (working copy) > @@ -311,6 +311,15 @@ register_tm_clones (void) > } > #endif /* USE_TM_CLONE_REGISTRY */ > > +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) > +void *_omp_func_table[0] > + __attribute__ ((__used__, visibility ("protected"), > + section (".offload_func_table_section"))) = { }; > +void *_omp_var_table[0] > + __attribute__ ((__used__, visibility ("protected"), > + section (".offload_var_table_section"))) = { }; > +#endif > + > #if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP) > > #ifdef OBJECT_FORMAT_ELF > @@ -752,6 +761,23 @@ __do_global_ctors (void) > #error "What are you doing with crtstuff.c, then?" > #endif > > +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) > +void *_omp_funcs_end[0] > + __attribute__ ((__used__, visibility ("protected"), > + section (".offload_func_table_section"))) = { }; > +void *_omp_vars_end[0] > + __attribute__ ((__used__, visibility ("protected"), > + section (".offload_var_table_section"))) = { }; > +extern void *_omp_func_table[]; > +extern void *_omp_var_table[]; > +void *__OPENMP_TARGET__[] __attribute__ ((__visibility__ ("protected"))) = > +{ > + &_omp_func_table, &_omp_funcs_end, > + &_omp_var_table, &_omp_vars_end > +}; > +#endif > + > + > #else /* ! CRT_BEGIN && ! CRT_END */ > #error "One of CRT_BEGIN or CRT_END must be defined." > #endif
I don't like these libgcc changes at all. First of all, we should find a way which has no runtime costs for at least programs not compiled with -fopenmp/-fopenacc at all, preferrably no runtime cost for any program or shared library that actually doesn't contain any offloading code. The above costs every single binary/shared library 5 exported symbols (with the worst ever visibility, protected should basically never be used, it is even more costly than normal symbol visibility, why it isn't just hidden?) and 4 * sizeof (void *) bytes in data section and 4 runtime relocations (with the protected visibility costly ones). When we were discussing the design last year, my strong preference was that either this lives in some other crt object that mkoffload/linker plugin adds to link, or that it would be completely mkoffload synthetized. Also, I'd prefer if __OPENMP_TARGET__ header was as compact as possible for the case when there is nothing to offload (ideally, if __OPENMP_TARGET__ symbol is never referenced, not create it at all, if it is referenced, but there is nothing to offload, say just a single 0 byte, otherwise say an uleb128 number how many different kinds of offload data there are and then for each one some identification which offload it is for, the tables, where to find it. Jakub