-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
rust: Require native: true
for proc-macro
targets and allow linki…
#11743
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1408,7 +1408,7 @@ def link(self, target): | |||||||||||
msg = f"Can't link non-PIC static library {t.name!r} into shared library {self.name!r}. " | ||||||||||||
msg += "Use the 'pic' option to static_library to build with PIC." | ||||||||||||
raise InvalidArguments(msg) | ||||||||||||
if self.for_machine is not t.for_machine: | ||||||||||||
if self.for_machine is not t.for_machine and (not t.uses_rust() or t.rust_crate_type != 'proc-macro'): | ||||||||||||
msg = f'Tried to mix libraries for machines {self.for_machine} and {t.for_machine} in target {self.name!r}' | ||||||||||||
if self.environment.is_cross_build(): | ||||||||||||
raise InvalidArguments(msg + ' This is not possible in a cross build.') | ||||||||||||
|
@@ -1432,7 +1432,7 @@ def link_whole(self, target): | |||||||||||
msg = f"Can't link non-PIC static library {t.name!r} into shared library {self.name!r}. " | ||||||||||||
msg += "Use the 'pic' option to static_library to build with PIC." | ||||||||||||
raise InvalidArguments(msg) | ||||||||||||
if self.for_machine is not t.for_machine: | ||||||||||||
if self.for_machine is not t.for_machine and (not t.uses_rust() or t.rust_crate_type != 'proc-macro'): | ||||||||||||
msg = f'Tried to mix libraries for machines {self.for_machine} and {t.for_machine} in target {self.name!r}' | ||||||||||||
if self.environment.is_cross_build(): | ||||||||||||
raise InvalidArguments(msg + ' This is not possible in a cross build.') | ||||||||||||
|
@@ -2328,6 +2328,13 @@ def process_kwargs(self, kwargs): | |||||||||||
else: | ||||||||||||
raise InvalidArguments(f'Invalid rust_crate_type "{rust_crate_type}": must be a string.') | ||||||||||||
if rust_crate_type == 'proc-macro': | ||||||||||||
if 'native' not in kwargs: | ||||||||||||
kwargs['native'] = True | ||||||||||||
if not kwargs.get('native', False): | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You set it to
Suggested change
|
||||||||||||
if self.environment.is_cross_build(): | ||||||||||||
raise InvalidArguments('Rust "proc-macro" crate type requires "native: true". This will fail in a cross-build.') | ||||||||||||
else: | ||||||||||||
mlog.warning('Rust "proc-macro" crate type requires "native: true". This will fail in a cross-build.') | ||||||||||||
Comment on lines
+2334
to
+2337
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not require "native: true", that's the default in this case. I think it should always be an hard error, no need to downgrade to a warning if it's not a cross build. To happen, user must have explicitely wrote: shared_library(..., rust_crate_type: 'proc-macros', native: false) which is always wrong. What about:
Suggested change
|
||||||||||||
FeatureNew.single_use('Rust crate type "proc-macro"', '0.62.0', self.subproject) | ||||||||||||
|
||||||||||||
def get_import_filename(self) -> T.Optional[str]: | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ pm = shared_library( | |
'proc_macro_examples', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A couple of lines above, why is this test disabled on non-Linux, how does it fail? Theoretically there shouldn't be anything special required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sdroege some of the tests are disabled on certain platforms because toolchains might not be setup on those platforms (work needed) or tests can take too long. In this case, you are probably running into the second option. Azure CI takes an ungodly amount of time and will timeout frequently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could very well be historical reasons that have been fixed since then. Feel free to open a separate PR that unskip them and see how it goes on the CI. |
||
'proc.rs', | ||
rust_crate_type : 'proc-macro', | ||
native: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would I enable this test on the CI for actually doing cross-compilation? I see that there are Linux/armhf and mingw64 cross tests in the CI. Should I add the corresponding rust toolchains there? How would I then enable this test to actually run? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See e.g. cross/linux-mingw-w64-64bit.txt You just need to set up the rust compiler as a cross binary, and configure the corresponding .json file to change e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should add Giving it a try at cross rust compilation in CI there: #11990. |
||
) | ||
|
||
main = executable( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
t
can be aCustomTarget
which does not implementuses_rust()
. What about: