Next revision | Previous revision |
blog:2020:0418_jit_compiler_part4_crt_dependency [2020/07/10 12:11] – external edit 127.0.0.1 | blog:2020:0418_jit_compiler_part4_crt_dependency [2022/11/25 18:21] (current) – external edit 127.0.0.1 |
---|
So, for some reason, the JIT compiler couldn't link to my process defined "my_function" function... So this got me thinking: maybe that's because, my test application is just a regular application after all, so when I compile it, my compiler will see that function definition, but then, since I'm not **actually using it anywhere** in my code, the compiler will probably find that this is a good oportunity to optimize the code and remove this function completely! | So, for some reason, the JIT compiler couldn't link to my process defined "my_function" function... So this got me thinking: maybe that's because, my test application is just a regular application after all, so when I compile it, my compiler will see that function definition, but then, since I'm not **actually using it anywhere** in my code, the compiler will probably find that this is a good oportunity to optimize the code and remove this function completely! |
| |
Thus, my first idea was to explicitly tell the compiler "I might need to access this function symbol externally some day, so you should not remove it!"... And on windows/msvc, usually you do that with the **%%__declspec(dllexport)%%**, so I updated the code with: | Thus, my first idea was to explicitly tell the compiler "I might need to access this function symbol externally some day, so you should not remove it!"... And on windows/msvc, usually you do that with the %%__declspec(dllexport)%%, so I updated the code with: |
| |
<sxh cpp> | <sxh cpp> |
return a*b; | return a*b; |
} | } |
</sxh> | </sxh>/*__*/ |
| |
| |
// cleaning code here. | // cleaning code here. |
} | } |
</sxh> | </sxh>/*__*/ |
| |
With this construct, the JIT couldn't find "my_function", and, since I don't think the compiler would be able to optimize my function call away in that case, I'd say it seems that the function **must really be exported to be found** [//arrf, OK, fair enough.//] | With this construct, the JIT couldn't find "my_function", and, since I don't think the compiler would be able to optimize my function call away in that case, I'd say it seems that the function **must really be exported to be found** [//arrf, OK, fair enough.//] |
| |
| |
~~DISCUSSION~~ | ~~DISCUSSION:off~~ |
| |
| |