Skip to content

Conversation

wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Sep 9, 2025

If there is no bitcode of generic implementation, all target bitcode files are added --override flag and our downstream has build error: llvm-link: Not enough positional command line arguments specified!

…mentation

If there is no bitcode of generic implementation, all target bitcode
files are added --override flag and there is build error:
`llvm-link: Not enough positional command line arguments specified!`
@llvmbot llvmbot added the libclc libclc OpenCL library label Sep 9, 2025
@wenju-he wenju-he requested a review from arsenm September 9, 2025 03:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a build error in libclc where llvm-link fails when no generic implementation bitcode exists. The issue occurs because the --override flag is incorrectly added to all target bitcode files when there's no generic bitcode to override.

  • Adds a check to detect the presence of generic implementation bitcode
  • Modifies the condition to only add --override flags when generic bitcode exists


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libclc libclc OpenCL library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants