I use a tool to generate a 111k-lines long C++ class implementation. The methods it generates work as they should, but they tend to trigger a slow path in the APIs that they use.
Is there any way, with Clang on Mac OS X, that I can manually implement some of the most-used methods in a different source file and tell the linker (or any other relevant program) to ignore the tool-generated method if another implementation for that method exists?
I am in complete control of the tool's output, though it would be pretty hard to automatically generate better code.
If the code is delivered in a library, then the linker searches through the .o files in successive libraries until all unresolved symbols have been satisfied. So if your code generation can ensure the weak code is separated into different .cpp files, then you can deliver the custom written versions in an earlier .a on the link path, which will be used before the .a supplied by the code generation.
Alternatively, if you could add a false template into your code, then you could specify an explicit specialization for the code. This would be used by the compiler/linker as it is a specific specialization.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments