Skip to content

Conversation

@sp1ritCS
Copy link
Contributor

@sp1ritCS sp1ritCS commented Jan 8, 2026

If a build target has link_language set, use that instead of propagating the language the target was written in.

This fixes the issue, that if you have a build target with cpp sources but with link_language being set to 'c', targets which link against the build target will be linked with the cpp linker, even tho that isn't necessary.


The non-link_language branch has some special casing for rust, which might have to be replicated in the new branch too. I'm not quite sure what exactly is does, so I'd appreciate some feedback on if that is necessary.

@sp1ritCS sp1ritCS requested a review from jpakkane as a code owner January 8, 2026 10:59
@bonzini
Copy link
Collaborator

bonzini commented Jan 8, 2026

Yes, I think it should be replicated, and the combined loop could be something like this:

target_langs = [t.link_language] if t.link_language else list(t.compilers.keys())
for lang in target_langs:
    # Rust is always linked through a C-ABI target, so do not add
    # the compiler here
    if lang != 'rust' and lang not in self.compilers:
        self.compilers[lang] = t.all_compilers[lang]

@sp1ritCS sp1ritCS force-pushed the dont-promote-cpp-clink branch 5 times, most recently from 3a0aa14 to 38c851d Compare January 8, 2026 23:23
@sp1ritCS
Copy link
Contributor Author

sp1ritCS commented Jan 9, 2026

@bonzini ok, your code was missing the lang in link_langs check, but after adding that it seems to work.

The only problem that still exists is the lacking introspection from the vs backend. Should I just limit the testcase to ninja or is there a better way of detecting the linker a target is going to use?

@bonzini
Copy link
Collaborator

bonzini commented Jan 13, 2026

Should I just limit the testcase to ninja

Yeah, that makes sense but please add a comment.

@sp1ritCS sp1ritCS force-pushed the dont-promote-cpp-clink branch 2 times, most recently from a07a071 to 21a028c Compare January 13, 2026 14:21
@sp1ritCS
Copy link
Contributor Author

add a comment

I guess the skip reason works well enough for that :)

Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

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

A couple of small nits, otherwise this looks good to me.

@sp1ritCS sp1ritCS force-pushed the dont-promote-cpp-clink branch from 4dad829 to 1b76611 Compare February 2, 2026 20:09
@sp1ritCS
Copy link
Contributor Author

sp1ritCS commented Feb 2, 2026

Will re-trigger CI once GitHub actions are back up and running properly again

If a build target has link_language set, use that instead of propagating
the language the target was written in.

This fixes the issue, that if you have a build target with cpp sources
but with link_language being set to 'c', targets which link against the
build target will be linked with the cpp linker, even tho that isn't
necessary.
@sp1ritCS sp1ritCS force-pushed the dont-promote-cpp-clink branch from 1b76611 to 4225608 Compare February 2, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants