A bug-report too difficult to make

Hi all,

I just found out that there is an extern “C” missing on the LLVMInitializeInstCombine function definition somewhere around this line:


As a result the function name gets mangled in the .lib file and is not accessible from LLVM C API.



It looks like there’s an extern "C" declaration in the corresponding header file, which appears to be sufficient. All of my attempts to grep for LLVMInitializeInstCombine in my build directory are leaving me with unmangled symbols, though I can’t say the same for LLVMInitializeAggressiveInstCombiner.

r336736 is an attempt to fix LLVMInitializeAggressiveInstCombiner. If I missed something, please let me know. (and if you’re still seeing a problem with LLVMInitializeInstCombine, more details about your setup/etc. would be appreciated.) :slight_smile:



I think I missed the root cause of the problem the previous time. Consider your sample code with a small tweak:

extern “C” {

void LLVMInitializeInstCombine(int);


char *LLVMInitializeInstCombine(int) { return 0; }

This will bomb out with error C2556: ‘char *LLVMInitializeInstCombine(int)’: overloaded function differs only by return type from ‘void LLVMInitializeInstCombine(int)’ in MSVC

But when you “tweak” the same way LLVMInitializeInstCombine in InstructionCombining.cpp the LLVMInstCombine project compiles w/ no error.

So the root cause here seems to be that the .h file with the extern “C” declaration of LLVMInitializeInstCombine is not included in InstructionCombining.cpp source, so a mismatch between declaration vs definition is possible and is actually happening.

My previous fix works but probably including Initialization.h would be better altogether.