Shadows always rendering in CPU render

Using cycles 3.4.0 as a library in our app. We set the visibility on an object for shadows using the PATH_RAY_SHADOW flag. In cuda and optix this works fine and objects obey the shadow setting. In CPU objects all cast shadows regardless of the PATH_RAY_SHADOW state. Shadows do go away if the light does not cast shadow. What cpp or h file can I look at to see where it determines if it should render a shadow?

I’m going to close this one. Turned out we used the stock embree precompiled libs from git and those libs do not enable the EMBREE_RAY_MASK define which allows flags to be set in embree. You need an embree with this enabled.