blog:2020:0418_jit_compiler_part4_crt_dependency

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
blog:2020:0418_jit_compiler_part4_crt_dependency [2021/09/02 13:40] – Discussion status changed manublog:2020:0418_jit_compiler_part4_crt_dependency [2022/11/25 18:21] (current) – external edit 127.0.0.1
Line 54: Line 54:
 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>
Line 61: Line 61:
  return a*b;  return a*b;
 } }
-</sxh>+</sxh>/*__*/
  
  
Line 89: Line 89:
   // 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.//]
  • blog/2020/0418_jit_compiler_part4_crt_dependency.txt
  • Last modified: 2022/11/25 18:21
  • by 127.0.0.1