https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65338
Bug ID: 65338 Summary: [5 Regression] Offloading from DSO is broken after OpenACC merge to trunk Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: iverbin at gcc dot gnu.org CC: jakub at gcc dot gnu.org, kyukhin at gcc dot gnu.org, tschwinge at gcc dot gnu.org The testcase: +++++ test.c: +++++ int f_aaa (void); int main () { int x = f_aaa (); #pragma omp target x++; return x; } +++++ libaaa.c: +++++ int f_aaa (void) { int x = 0; #pragma omp target x = 10; return x; } ++++++++++ $ gcc -fopenmp -shared -fPIC libaaa.c -o libaaa.so $ gcc -fopenmp -L. -laaa test.c $ ./a.out libgomp: Target function wasn't mapped The problem is caused by this change: -gomp_register_images_for_device (struct gomp_device_descr *device) +gomp_register_image_for_device (struct gomp_device_descr *device, + struct offload_image_descr *image) { - int i; - for (i = 0; i < num_offload_images; i++) + if (!device->offload_regions_registered + && (device->type == image->type + || device->type == OFFLOAD_TARGET_TYPE_HOST)) { - struct offload_image_descr *image = &offload_images[i]; - if (image->type == device->type) - device->register_image_func (image->host_table, image->target_data); + device->register_image_func (image->host_table, image->target_data); + device->offload_regions_registered = true; } } We should at least remove device->offload_regions_registered, or rework loading/registration to support dlopen'ed libraries. Related mail thread: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01455.html