-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix corrosion_set_linker_language #133
Comments
jschwe
added a commit
to jschwe/corrosion
that referenced
this issue
Feb 6, 2022
The corrosion generator is a 100% rust executable, so I don't think there is any benefit in us telling rust which linker it should use. Additionally corrosion_set_linker_language currently does not have any effect anyway (See corrosion-rs#133). Closes corrosion-rs#88 Signed-off-by: Jonathan Schwender <[email protected]>
When adding a test for #139, I noticed that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PR #126 brought up the topic that
corrosion_set_linker_language
currently does not do anything, since the used propertyLINKER_LANGUAGE
is apparently special and can't be used in the way that it was.Therefore the current behaviour of
corrosion_set_linker_language
is that nothing happens, and the choice of the linker is not influenced by using this function. E.g. addingcorrosion_set_linker_language(rust-exe C)
tocpp2rust/CMakeLists.txt
does not break the build, since still the C++ linker is invoked.As far as I can see this topic is only relevant for x2rust style projects, where linking is invoked via cargo.
#126 proposed to fix this by renaming the used property. Due to other corrosion code, the proposed change has the effect that the language specified in
corrosion_set_linker_language
is appended to a list oflinker_languages
andbuild_crate.rs
will choose the language from the list with the highestCMAKE_<lang>_LINKER_PREFERENCE
. This is probably not what a user would expect from the name of the function (In the case of cpp2rust, again still the C++ linker is invoked).We could of course also fix that, but I would instead propose to just deprecate
corrosion_set_linker_language
(which should not be a breaking change, since it effectively doesn't do anything anyway). Instead I think it would make more sense to add a functioncorrosion_set_linker(<target> <linker>)
, which allows the user to directly specify the linker it wants to use. If you want to explicitely use the compiler/linker CMake chose for a certain language, you could still docorrosion_set_linker(my_target ${CMAKE_C_COMPILER})
instead of explicitely specifiying a linker.The new behaviour would then be that if a linker was explictly set via
corrosion_set_linker
, then thelinker_languages
andCMAKE_<lang>_LINKER_PREFERENCE
is just completely ignored and the linker specified by the user is passed to cargo viaCARGO_TARGET_<target_triple>_LINKER
Any thoughts on this?
The text was updated successfully, but these errors were encountered: