Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ function(link_bc)
${ARGN}
)

if( ARG_INTERNALIZE )
string( FIND "${ARG_INPUTS}" "/generic/" has_generic )
if( ARG_INTERNALIZE OR has_generic LESS 0 )
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is inverted. When has_generic is LESS than 0, it means no generic implementation was found, but the condition suggests that --override flags should NOT be added in this case. However, based on the comment on line 99 and the problem description, --override flags should only be added when generic bitcode EXISTS (i.e., when has_generic is NOT less than 0). The condition should be if( ARG_INTERNALIZE OR has_generic GREATER_EQUAL 0 ).

Suggested change
if( ARG_INTERNALIZE OR has_generic LESS 0 )
if( ARG_INTERNALIZE OR has_generic GREATER_EQUAL 0 )

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this actually be negative? Or equal 0?

Copy link
Contributor Author

@wenju-he wenju-he Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this actually be negative? Or equal 0?

Yes, it can be negative, 0 or positive.
if "/generic/" is found, has_generic is greater or equal to 0, which is the 0-based index of the first occurrence. Otherwise, has_generic is equal to -1, meaning pattern is not found.

The above Copilot AI analysis is not correct. The newly added check is to make sure "--override" is not appended to each non-generic bitcode if there is not a single generic bitcode in ARG_INPUTS and in this case has_generic at line 96 is -1.
In contrary, at line 103 - 106, it is trying to add "--override" to non-generic bitcodes so it expects that has_generic at line 104 is -1.

set( inputs_with_flag ${ARG_INPUTS} )
else()
# Add the --override flag for non-generic bitcode files so that their
Expand Down
Loading