@@ -178,6 +178,35 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild(
178178 return UR_RESULT_SUCCESS;
179179}
180180
181+ // /////////////////////////////////////////////////////////////////////////////
182+ // / @brief Intercept function for urProgramLink
183+ // / TODO: It is technically possible that user directly calls urProgramLinkExp
184+ // / instead of urProgramLink, intercept urProgramLinkExp if that happens.
185+ __urdlllocal ur_result_t UR_APICALL urProgramLink (
186+ ur_context_handle_t hContext, // /< [in] handle of the context instance.
187+ uint32_t count, // /< [in] number of program handles in `phPrograms`.
188+ const ur_program_handle_t *
189+ phPrograms, // /< [in][range(0, count)] pointer to array of program handles.
190+ const char *
191+ pOptions, // /< [in][optional] pointer to linker options null-terminated string.
192+ ur_program_handle_t
193+ *phProgram // /< [out] pointer to handle of program object created.
194+ ) {
195+ auto pfnProgramLink = context.urDdiTable .Program .pfnLink ;
196+
197+ if (nullptr == pfnProgramLink) {
198+ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
199+ }
200+
201+ context.logger .debug (" ==== urProgramLink" );
202+
203+ UR_CALL (pfnProgramLink (hContext, count, phPrograms, pOptions, phProgram));
204+
205+ UR_CALL (context.interceptor ->registerDeviceGlobals (hContext, *phProgram));
206+
207+ return UR_RESULT_SUCCESS;
208+ }
209+
181210// /////////////////////////////////////////////////////////////////////////////
182211// / @brief Intercept function for urEnqueueKernelLaunch
183212__urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch (
@@ -422,6 +451,7 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramProcAddrTable(
422451 }
423452
424453 pDdiTable->pfnBuild = ur_sanitizer_layer::urProgramBuild;
454+ pDdiTable->pfnLink = ur_sanitizer_layer::urProgramLink;
425455
426456 return UR_RESULT_SUCCESS;
427457}
0 commit comments