I have an operator that dynamically compiles code and generates a shared object that it should be linked against. Currently, this operator uses the clause in the XML operator model to add the lib and libPath based on a static library name “libcustomoperatorlib.so,” since the library will be located in the application directory, not the toolkit directory. The Perl in the generic operator compiles the C++ and links it into the shared object under the constant name, located in the application directory.
The issue I have is that this means that a composite can only have one instance of this operator. If there are more, then it runs the risk of overwriting the old shared object with a different one, causing one of the instances to fail. Additionally, if the compilation is parallelized, it creates a race condition that could cause both operator instances to attempt to modify the shared object simultaneously, leading to undefined behavior.
The initial idea would be to randomly generate a library name and link against that, but the script is not passed any arguments related to the parameters for the operator instance or its context. Additionally, the Perl code in the .cgt doesn’t seem to have any ability to add to the lib, libPath, or includePath while the C++ is being generated.
Is there a way that I can have the operator dynamically compile to a library name unique to the operator instance and have it properly included in the libs?