I discovered an issue in the LTO streaming out for target - currently any file (even without any pragma) compiled with -fopenmp/-fopenacc contains .gnu.target_lto_* sections. This increases the size of an object file and makes lto-wrapper to run mkoffload.
Therefore, I propose to replace the condition before ipa_write_summaries:
- if (flag_openacc || flag_openmp)
+ if ((flag_openacc || flag_openmp) && !(vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars)))
But to do this, the offload_vars must be filled before the check (offload_funcs is already filled in expand_omp_target).
Here is the updated patch. Bootstrap passed. OK for gomp-4_0-branch?