How to manage kernel compilation manually

Good afternoon!
As I understand it, the kernel compilation takes place during the call of the .build() method, which looks as follows:

cl::Program program(context, source);, "OpenCL_optimization_options_from_specification");

But the thing is that the optimization options given in the spec are not able to meet my real needs - they are too abstract. For example, the -cl-opt-disable flag works and does not work.
In this connection, I have a question - how does the .build() method work? What exactly does it do in the source code (which I could not find (apparently, OpenCL is not so open))? And, most importantly, how can I manually communicate with the .cl code compiler to pass it compilation flags rather than optimization options?
I should note that I’m running on NVidia graphics cards (RTX 4080 and A100), so I’m mainly interested in answers and advice on how the .build() method works in relation to the NVidia infrastructure.
P.S. I am also aware of the `.compile()’ method, however it does not work. No matter what parameters I supply, nothing changes (even knowingly wrong ones).

You are using the OpenCL with C++ bindings. If you look into the source code in opencl.hpp, you will find the .build() function is actually a wrapper of the standard OpenCL C api clBuildProgram.
OpenCL is open, but only as a standard itself. That is, the OpenCL standard only defines what should clBuidProgram do, but not how to do it. It is usually the vendor of the device (gpu, cpu or fpga) who implemented the api, and it is not the OpenCL standard you should be looking at, if you want to know the specific implementation of clBuildProgram. You should read the source code of your, or whatever library mentioned in the icd file under your /etc/OpenCL/vendors/xxx.icd.
Unfortunately though, you are using NVIDIA graphics card, whose vendor is not very well known for its keen on open source movement. You will see a opencl library like /usr/lib/x86_64-linux-gnu/, but it will be challenging to find its source code, or impossible, at least as of my knowledege.