@@ -354,16 +354,24 @@ urProgramGetBuildInfo(ur_program_handle_t hProgram, ur_device_handle_t hDevice,
354354 UrReturnHelper ReturnValue (propSize, pPropValue, pPropSizeRet);
355355
356356 switch (propName) {
357- case UR_PROGRAM_BUILD_INFO_STATUS: {
357+ case UR_PROGRAM_BUILD_INFO_STATUS:
358358 return ReturnValue (hProgram->BuildStatus );
359- }
360359 case UR_PROGRAM_BUILD_INFO_OPTIONS:
361360 return ReturnValue (hProgram->BuildOptions .c_str ());
362- case UR_PROGRAM_BUILD_INFO_LOG:
363- return ReturnValue (hProgram->InfoLog , hProgram->MaxLogSize );
364- case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: {
365- return ReturnValue (hProgram->BinaryType );
361+ case UR_PROGRAM_BUILD_INFO_LOG: {
362+ // We only know the maximum log length, which CUDA guarantees will include
363+ // the null terminator.
364+ // To determine the actual length of the log, search for the first
365+ // null terminator, not searching past the known maximum. If that does find
366+ // one, it will return the length excluding the null terminator, so remember
367+ // to include that.
368+ auto LogLen =
369+ std::min (hProgram->MaxLogSize ,
370+ strnlen (hProgram->InfoLog , hProgram->MaxLogSize ) + 1 );
371+ return ReturnValue (hProgram->InfoLog , LogLen);
366372 }
373+ case UR_PROGRAM_BUILD_INFO_BINARY_TYPE:
374+ return ReturnValue (hProgram->BinaryType );
367375 default :
368376 break ;
369377 }
0 commit comments