Currently, lld LTO configuration explicitly sets relocation model
based on the linker flags, effectively overriding whatever model is
stored inside the module. This behavior differs from the behavior
one would get during regular linking or even ThinLTO with explicit
codegen where the linker flags such as -r, -pie or -shared don't
affect codegen. This breaks the case where user wants to deliberately
select different relocation model for codegen and for linking, which
is can be the case in special environments like kernels.
Concretely, we stumbled upon this issue while trying to build Zircon
kernel with ThinLTO but the resulting kernel wouldn't boot. Upon
investigation, we've noticed that the kernel code is non-relocatable
despite it being compiled with -fpie. The problem was that our build
passes --no-pie to the linker. This is on purpose, while we want pie
codegen, we want to link the final binary to be linked as static one
(because there's no dynamic linker in our environment).
This change alters the behavior to use the relocation model stored
in the module which is the default behavior of the LTO backend, and
allows overriding the model via -mllvm flag. This matches the behavior
already used for code model. With this change, our kernel builds and
boots even when built with (Thin)LTO.