Skip to content
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

Ensure SYMTAB in rlib's with arch code but no syms #5

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

aurxenon
Copy link
Contributor

I was experimenting with using no_std and rustc_codegen_gcc, and it mostly works great, except that librustc_std_workspace_core.rlib would cause a linker error, as GNU LD couldn't find a symbol table for the archive. Investigating it seems to have uncovered an oversight, has_object will effectively inevitably always get reset back to false once it hits the lib.rmeta file, which causes a problem if there's also no symbols pulled out of any of the interior object files (this happens if get_native_object_symbols doesn't see any global symbols prior to lib.rmeta). The rest of the code following will incorrectly assume that since there's no symbols, there must not be any objects inside, and thus no need for a SYMTAB.

Screenshot 2023-03-21 232658

src/archive_writer.rs Outdated Show resolved Hide resolved
Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

Of course. This explains the trouble I had with getting it to work for webassembly. Thanks for finding this!

@aurxenon aurxenon force-pushed the fix_for_missing_libcore_symtab branch from 776f223 to 65c840d Compare March 23, 2023 18:57
@aurxenon
Copy link
Contributor Author

I applied your suggestion, let me know if I should make any more changes.

@aurxenon aurxenon force-pushed the fix_for_missing_libcore_symtab branch from 65c840d to 21cbbc5 Compare March 23, 2023 19:00
src/archive_writer.rs Outdated Show resolved Hide resolved
@aurxenon aurxenon force-pushed the fix_for_missing_libcore_symtab branch from 21cbbc5 to d99dfda Compare March 23, 2023 20:51
Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

Thanks! I will merge and do a release tomorrow. I'm currently on my phone.

@bjorn3 bjorn3 merged commit 5748cc6 into rust-lang:master Mar 24, 2023
@bjorn3
Copy link
Member

bjorn3 commented Mar 24, 2023

Released as v0.1.3.

bjorn3 added a commit to bjorn3/rust that referenced this pull request Mar 24, 2023
This updates object to 0.30 and fixes a bug where the symbol table
would be omitted for archives where there are object files yet none
that export any symbol. This bug could lead to linker errors for crates
like rustc_std_workspace_core which don't contain any code of their own
but exist solely for their dependencies. This is likely the cause of
the linker issues I was experiencing on Webassembly. It has been shown
to cause issues on other platforms too.

cc rust-lang/ar_archive_writer#5
@bjorn3
Copy link
Member

bjorn3 commented Mar 24, 2023

Opened rust-lang/rust#109562 to update ar_archive_writer.

Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 28, 2023
…=Mark-Simulacrum

Update ar_archive_writer to 0.1.3

This updates object to 0.30 and fixes a bug where the symbol table would be omitted for archives where there are object files yet none that export any symbol. This bug could lead to linker errors for crates like rustc_std_workspace_core which don't contain any code of their own but exist solely for their dependencies. This is likely the cause of the linker issues I was experiencing on Webassembly. It has been shown to cause issues on other platforms too.

cc rust-lang/ar_archive_writer#5
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.

2 participants