The OCaml compiler has a flag (-runtime-variant foo) that has the effect of linking libasmrunfoo.a instead.
In OCaml 4.02.2, whitequark contributed both the build of libasmrun_pic.a and an ocamlbuild flag runtime_variant(foo) to enable this feature in ocamlbuild. So you can use the tag 'runtime_variant(_pic)' at the level of one OCamlbuild project to enable this.
I suppose that what you would actually be looking for here is a way to set this runtime variant as the default at the level of the whole OCaml package tree (one opam switch). Unfortunately, I don't know whether the ocaml configure/build system makes this easy today. Could you consider opening an issue on the bugtracker (
http://caml.inria.fr/mantis/view_all_bug_page.php ) to track this feature request?
Do you have some documentation on what precisely is the change in gcc7 that causes this compatibility breakage?