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

Add new compile_intermediates function. #914

Merged
merged 6 commits into from Jan 24, 2024

Conversation

roblabla
Copy link
Contributor

@roblabla roblabla commented Jan 2, 2024

This new function can be used to just compile the files to a bunch of .o files. It won't create an archive file, nor print any of the cargo link directives. This is meant to be used by rustc to:

  • Compile the MUSL crtbegin.c here
  • Use different set of arguments when building the C and C++ parts of libunwind here

Currently, rustc guesses the output path of the object files, even though it's an unexposed implementation detail of cc. The latest version of cc added some hash to the generated object file name, which broke rustc's assumptions.

By providing a proper way to generate an object file using cc, this should hopefully make the system more robust.

Fixes #912

@thomcc
Copy link
Member

thomcc commented Jan 2, 2024

Thanks. I won't be able to take a look at this until the weekend.

@roblabla roblabla force-pushed the compile-intermediates branch 2 times, most recently from 1b35617 to 51af4a6 Compare January 2, 2024 18:48
src/lib.rs Outdated Show resolved Hide resolved
@roblabla roblabla force-pushed the compile-intermediates branch 2 times, most recently from 469c86d to 9675445 Compare January 3, 2024 09:26
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@NobodyXu
Copy link
Collaborator

pinging @roblabla just in case you forgot this PR/comment

This new function can be used to just compile the files to a bunch of .o
files.
Since rust-lang#684 was merged, it is
impossible for `obj` to not start with dst - if `obj` is absolute or
contains `../` in its Path, then the path will be hashed, and the file
will still be placed under dst.

As such, this obj.starts_with(&dst) check is always true.
Copy link
Collaborator

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

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

Thank you!

Could you please run cargo-fmt before committing?

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

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

Thank you!

@NobodyXu NobodyXu merged commit 385b43f into rust-lang:main Jan 24, 2024
18 checks passed
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.

Expose function compile to an object file
3 participants