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

Correctly handle UEFI targets as Windows-like when emitting sections for LLVM bitcode #71881

Merged
merged 1 commit into from
May 5, 2020
Merged

Conversation

IsaacWoods
Copy link
Contributor

@IsaacWoods IsaacWoods commented May 4, 2020

This handles UEFI handles when emitting inline assembly for sections containing LLVM bitcode. See details in #71880. I have locally confirmed that this change fixes compilation of projects using the x86_64-unknown-uefi target compiling with cargo-xbuild, but I am not very familiar with LLVM bitcode so this may not be the correct approach.

r? @alexcrichton as they wrote the initial LLVM bitcode emitting code?

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 4, 2020
@petrochenkov
Copy link
Contributor

Thanks!
r? @petrochenkov @bors r+ rollup

This should really use target.options.is_like_windows after FIXMEs in the UEFI target spec (https://github.com/rust-lang/rust/blob/master/src/librustc_target/spec/uefi_msvc_base.rs) are fixed.
"Is like Windows" in this case means "uses PE/COFF as a binary format".

@bors
Copy link
Contributor

bors commented May 4, 2020

📌 Commit 6e77729 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 5, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#71587 (Report cannot move errors in promoted MIR)
 - rust-lang#71711 (Updates to some ignored tests)
 - rust-lang#71845 (Add const examples)
 - rust-lang#71878 (Add remove_current_as_list to LinkedList's CursorMut)
 - rust-lang#71881 (Correctly handle UEFI targets as Windows-like when emitting sections for LLVM bitcode)
 - rust-lang#71883 (add a missing "at" in a comment)
 - rust-lang#71891 (¬∃x. ¬y => ∀x. y)
 - rust-lang#71892 (Update btree_map::VacantEntry::insert docs to actually call insert)
 - rust-lang#71902 (Suggest to add missing feature when using gated const features)
 - rust-lang#71904 (fix typo in function name)

Failed merges:

r? @ghost
@bors bors merged commit c1b2fd2 into rust-lang:master May 5, 2020
dvdhrm added a commit to dvdhrm/rust that referenced this pull request Jun 2, 2020
Add a new codegen test which cross-compiles a UEFI program and verifies
that an entry-point is emitted.

The UEFI code-generation has broken in nightly before, see for instance:

    commit c1b2fd2
    Merge: faccb0f 6e77729
    Author: Dylan DPC <dylan.dpc@gmail.com>
    Date:   Tue May 5 01:49:44 2020 +0200

        Rollup merge of rust-lang#71881 - IsaacWoods:master, r=petrochenkov

        Correctly handle UEFI targets as Windows-like when emitting sections for LLVM bitcode

This commit adds a very simple UEFI program and verifies that
cross-compilation with the built-in `x86_64-unknown-uefi` target works.
No runtime testing, nor any elaborate code-validation is done. This
simply serves as base test that verifies compilation works and an entry
point is emitted.

Usually, you would use `libcore`, but in this test we do not want to
trigger re-compilation of `libcore` for `x86_64-unknown-uefi`. Hence, we
pull in just enough of `libcore` to make the test compile.

This UEFI program is fully functional and returns success (i.e., 0). You
can run it from your UEFI BootManager or from EfiShell.

The imported UEFI definitions are explicitly kept simple. For more
elaborate use-cases you would want the full UEFI specification (see the
`r_efi` crate for a standalone import of the base UEFI specification).
ids1024 added a commit to system76/firmware-setup that referenced this pull request Oct 8, 2020
This eliminated the two awkward `ld` steps from the Makefile, and seems
to produce a smaller `.efi`. It seems to work, based on quick testing in
qemu.

Using 'uefi' for target because apparently Rust cares:
rust-lang/rust#71881

Some changes to the target specification here are from
`rustc -Z unstable-options --print target-spec-json --target x86_64-unknown-uefi`.
We probably want more of the settings from there, but most likely still
need our own custom target to change some things.
jackpot51 pushed a commit to system76/firmware-setup that referenced this pull request Oct 16, 2020
This eliminated the two awkward `ld` steps from the Makefile, and seems
to produce a smaller `.efi`. It seems to work, based on quick testing in
qemu.

Using 'uefi' for target because apparently Rust cares:
rust-lang/rust#71881

Some changes to the target specification here are from
`rustc -Z unstable-options --print target-spec-json --target x86_64-unknown-uefi`.
We probably want more of the settings from there, but most likely still
need our own custom target to change some things.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants