I am not sure this is the right list for this question, but i will ask it anyways.
some of my functions which are not used in the final executable are optimized away by the clang++ linker. Is there any way to prevent clang++ to strip away these functions ? Maybe by some attribute prefixed at the the function signature ? I did some google search, but with no luck.
> I want to pass them to libraries later loaded into the application.
> If the global is not used, would the linker be able to optimize
> the global out and in turn optimize the function out again ?
Potentially, but the fix is fairly simple. Create a global that holds
pointers to the functions. Have the
code that wants to pass pointers to those functions read the pointers from
that global.
However, this begs the question of why the part of your code that
currently tries to pass the function
pointers isn't being recognised as referring to the functions in question.
How does that code work?
Ok this is the whole story. These *unused* functions are defined in LLVM
lli. and they are referenced in the bitcode lli is interpreting/JITting.
the bitcode expects lli to able to resolve these functions at JIT time.
basically, the bitcode is somewhat like libraries loaded into the lli
application. However, the linker optimized these functions out because it
sees no invocation of them in the final executable.