Consider the following example: Let lib1.c contain function f1. Let lib2.c contain function f2.
Both f1 and f2 contain offloaded functions. Create a static library with both lib1.o and lib2.o. Next create a program which using that static library, but only calls f1. If you build this program without program-wide -flto, this will cause the nvptx linker to embed the offloaded functions for both f1 and f2 in the host's executable, whereas the host will only have the offloaded function for f1. This is a problem because the libgomp expects both the host and accelerator to have the same number of offloaded functions. As a temporary workaround, this patch teaches libgomp to allow the accelerator to possess more offloaded functions than the host. I've applied this patch to openacc-gcc-7-branch. Is it also suitable for trunk? Cesar
2017-10-11 Cesar Philippidis <ce...@codesourcery.com> libgomp/ * target.c (gomp_load_image_to_device): Allow the accelerator to possess more offloaded functions than the host. diff --git a/libgomp/target.c b/libgomp/target.c index a55c8f074d9..336581d2196 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -1452,7 +1452,7 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version, = devicep->load_image_func (devicep->target_id, version, target_data, &target_table); - if (num_target_entries != num_funcs + num_vars) + if (num_target_entries < num_funcs + num_vars) { gomp_mutex_unlock (&devicep->lock); if (is_register_lock)