Using clang LTO with POLLY

I’m hacking on a compiler with a fairly complicated build system and trying to experiment with POLLY ( alongside LLVM LTO.

The general shape of the last part of compilation looks like:

opt-6.0 -O2 -enable-tbaa -tbaa ‘-relocation-model=static’ application.ll -o application.o
clang -flto -c /tmp/baz_3.c -o /tmp/baz_4.o
clang -flto -o /tmp/floop -Wl,–gc-sections application.o -L/lots_of_lto_objs_here /tmp/baz_4.o -Wl,-u,foo -Wl,-u,bar -llto_obj1 -lto_obj2 -letc -lnuma

In the last step we link a whole bunch of LLVM LTO objects (LLVM IR bitcode, as I understand it). This seems to work fine, but now I’m struggling to add POLLY into the mix.

If I add -O3 -mllvm -polly to the last clang invocation, I just get

clang: warning: argument unused during compilation: ‘-mllvm -polly’ [-Wunused-command-line-argument]

Is there a convenient way to use POLLY with LTO? I’ve seen but I’m not sure how to adapt that to what I need in a convenient way since I’m doing a lot of shimming of clang, lld, etc in order to get as far as I have.

I think I need to stay on llvm/clang v6, although newer lld seemed to work fine.