The Saxon-SA optimizer may extract code into newly created global variables. Such variables are regarded as belonging to the main module. This may create an artificial reference from a library module to the main module, which is then reported as an error XQST0093, which occurs when there are references from module A to module B and also from module B to module A.
As a workaround, use
declare option saxon:allow-cycles "true";
in the main module.
A patch is being raised on the Saxon 9.1 branch. It is likely that the bug also affects 9.0. Although the situation can only arise (as far as I know) under Saxon-SA, the patch is in Saxon-B source code, module QueryModule.