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

Rollup of 27 pull requests (second batch) #56817

Closed
wants to merge 65 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
934e4d3
Remove not used mod
yui-knk Nov 28, 2018
eaeebb5
Clearer error message for dead assign
JohnGinger Dec 2, 2018
54026c1
Fix line length
JohnGinger Dec 2, 2018
4cf5702
Fix stderr files
JohnGinger Dec 3, 2018
70536d4
Fix stderr file (unused variable)
JohnGinger Dec 3, 2018
c0e3f4b
Change to give a help message
JohnGinger Dec 7, 2018
aa04285
Add lint for items deprecated in future
aheart Dec 9, 2018
562f33b
Document time of back operations of a Linked List
Dec 10, 2018
a5a3da5
bootstrap: fix edition
ljedrz Dec 7, 2018
a336228
Add test to check library traits have #[must_use] attribute
aelred Dec 10, 2018
ecc4ca5
Add #[must_use] attribute to stdlib traits
aelred Dec 10, 2018
3246f49
Add trailing newline
aelred Dec 10, 2018
c3c2de9
reject invalid external doc attributes
euclio Nov 28, 2018
7f7045f
improve diagnostics for invalid external docs
euclio Nov 28, 2018
07a3d69
Update the stdsimd submodule
alexcrichton Dec 10, 2018
3d23e55
fix install broken link
mishaker Dec 10, 2018
f8c03b6
Add lint for stlib
aheart Dec 10, 2018
30f531b
generate invalidations from 2-phase-borrow activations
nikomatsakis Dec 4, 2018
8ee2c06
adopt polonius-engine 0.6.1
nikomatsakis Dec 4, 2018
1006425
Test capacity of ZST vector
KamilaBorowska Dec 11, 2018
5acab2d
Always set the RDRAND and RDSEED features on SGX
Dec 11, 2018
45b97f2
miri: use backtrace crate printing instead of rolling our own
RalfJung Dec 11, 2018
b17a3f2
fix rust-lang/rust issue #50583
piersfinlayson Dec 11, 2018
8e994a2
bump backtrace version to get prettier pretty-printing
RalfJung Dec 11, 2018
94c1c73
Documentation for impl From for AtomicBool and other Atomic types
phungleson Dec 11, 2018
b96186b
Add missing urls in ffi module docs
GuillaumeGomez Dec 11, 2018
517bfe0
Fix private_no_mangle_fns message grammar
turboladen Dec 12, 2018
29e7ca9
Add test of current behavior (infer free region within closure body) …
pnkfelix Dec 10, 2018
29bec2d
target: remove Box returned from get_targets
ljedrz Dec 12, 2018
8a6ca24
Allow ptr::hash to accept fat pointers
mbrubeck Dec 12, 2018
b9235ea
Account for `impl Trait` when suggesting lifetime
estebank Dec 12, 2018
ae893bb
Add short emoji status to toolstate updates
Manishearth Dec 12, 2018
bec5b66
Deduplicate unsatisfied trait bounds
estebank Dec 12, 2018
88cf2a2
Add x86_64-unknown-uefi target
Dec 13, 2018
a39f184
Use `dedup` instead of `dedup_by`
oli-obk Dec 13, 2018
9de6bee
debug logging, added conditional error message, tests updated
kevgrasso Nov 12, 2018
b6b278e
Fixes broken links
jrvidal Dec 14, 2018
42167b9
fix issue 54153 by ignoring issue-18804 test on windows/mac.
pnkfelix Dec 13, 2018
e44527a
Rollup merge of #53506 - phungleson:fix-from-docs-atomic, r=KodrAus
kennytm Dec 14, 2018
63e20b0
Rollup merge of #56203 - aheart:master, r=varkor
kennytm Dec 14, 2018
c41dcd0
Rollup merge of #56343 - yui-knk:remove_mir_stats_mod, r=nikomatsakis
kennytm Dec 14, 2018
8247686
Rollup merge of #56439 - JohnGinger:master, r=nikomatsakis
kennytm Dec 14, 2018
06eaf8b
Rollup merge of #56507 - nikomatsakis:polonius-integrate, r=MatthewJa…
kennytm Dec 14, 2018
ed5669a
Rollup merge of #56572 - kevgrasso:let_self_err_dev, r=estebank
kennytm Dec 14, 2018
f7e5aef
Rollup merge of #56600 - ljedrz:fix_edition, r=Mark-Simulacrum
kennytm Dec 14, 2018
40aba86
Rollup merge of #56672 - ccouzens:master, r=nikic
kennytm Dec 14, 2018
ccad2cf
Rollup merge of #56677 - aelred:must-use-on-traits, r=estebank
kennytm Dec 14, 2018
97d0748
Rollup merge of #56679 - euclio:external-doc-parse, r=estebank
kennytm Dec 14, 2018
8b57f97
Rollup merge of #56682 - alexcrichton:update-stdsimd, r=nikomatsakis
kennytm Dec 14, 2018
240e4e7
Rollup merge of #56691 - mishaker:fix_doc_install_broken_link, r=jona…
kennytm Dec 14, 2018
7c9baed
Rollup merge of #56710 - jethrogb:jb/sgx-target-features, r=alexcrichton
kennytm Dec 14, 2018
32e0e84
Rollup merge of #56713 - xfix:vec-test-zst-capacity, r=TimNN
kennytm Dec 14, 2018
bc8aef6
Rollup merge of #56718 - RalfJung:use-libbacktrace-printing, r=alexcr…
kennytm Dec 14, 2018
d1391e6
Rollup merge of #56725 - piersfinlayson:master, r=alexcrichton
kennytm Dec 14, 2018
a7d78d9
Rollup merge of #56731 - GuillaumeGomez:ffi-doc-urls, r=Centril
kennytm Dec 14, 2018
4c838e9
Rollup merge of #56738 - turboladen:fix-private_no_mangle_fns-message…
kennytm Dec 14, 2018
eaaee52
Rollup merge of #56746 - pnkfelix:issue-56537-add-test-of-closure-usi…
kennytm Dec 14, 2018
dccf781
Rollup merge of #56747 - ljedrz:remove_box_from_target, r=zackmdavis
kennytm Dec 14, 2018
433f083
Rollup merge of #56751 - mbrubeck:hash, r=dtolnay
kennytm Dec 14, 2018
3669769
Rollup merge of #56755 - estebank:impl-trait-lt-sugg, r=cramertj
kennytm Dec 14, 2018
9c56672
Rollup merge of #56758 - Manishearth:emoji-status-toolstate, r=kennytm
kennytm Dec 14, 2018
9d5f554
Rollup merge of #56760 - estebank:dedup-bounds, r=oli-obk
kennytm Dec 14, 2018
0362ccd
Rollup merge of #56769 - dvdhrm:uefi-target, r=alexcrichton
kennytm Dec 14, 2018
3ef52eb
Rollup merge of #56772 - pnkfelix:issue-54153-linkage-sometimes-requi…
kennytm Dec 14, 2018
38ac4ba
Rollup merge of #56808 - jrvidal:broken-links, r=kennytm
kennytm Dec 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add x86_64-unknown-uefi target
This adds a new rustc target-configuration called 'x86_64-unknown_uefi'.
Furthermore, it adds a UEFI base-configuration to be used with other
targets supported by UEFI (e.g., i386, armv7hl, aarch64, itanium, ...).

UEFI systems provide a very basic operating-system environment, meant
to unify how systems are booted. It is tailored for simplicity and fast
setup, as it is only meant to bootstrap other systems. For instance, it
copies most of the ABI from Microsoft Windows, rather than inventing
anything on its own. Furthermore, any complex CPU features are
disabled. Only one CPU is allowed to be up, no interrupts other than
the timer-interrupt are allowed, no process-separation is performed,
page-tables are identity-mapped, ...

Nevertheless, UEFI has an application model. Its main purpose is to
allow operating-system vendors to write small UEFI applications that
load their kernel and terminate the UEFI system. However, many other
UEFI applications have emerged in the past, including network-boot,
debug-consoles, and more.

This UEFI target allows to compile rust code natively as UEFI
applications. No standard library support is added, but libcore can be
used out-of-the-box if a panic-handler is provided. Furthermore,
liballoc works as well, if a `GlobalAlloc` handler is provided. Both
have been tested with this target-configuration.

Note that full libstd support is unlikely to happen. While UEFI does
have standardized interfaces for networking and alike, none of these
are mandatory and they are unlikely to be shipped in common consumer
firmwares. Furthermore, several features like process-separation are
not available (or only in very limited fashion). Those parts of libstd
would have to be masked.
David Herrmann committed Dec 13, 2018
commit 88cf2a23e24cdbf7a134d14185c1e5b69ffd07c3
3 changes: 3 additions & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ mod linux_musl_base;
mod openbsd_base;
mod netbsd_base;
mod solaris_base;
mod uefi_base;
mod windows_base;
mod windows_msvc_base;
mod thumb_base;
@@ -419,6 +420,8 @@ supported_targets! {
("aarch64-unknown-none", aarch64_unknown_none),

("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),

("x86_64-unknown-uefi", x86_64_unknown_uefi),
}

/// Everything `rustc` knows about how to compile for a specific target.
74 changes: 74 additions & 0 deletions src/librustc_target/spec/uefi_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// This defines a base target-configuration for native UEFI systems. The UEFI specification has
// quite detailed sections on the ABI of all the supported target architectures. In almost all
// cases it simply follows what Microsoft Windows does. Hence, whenever in doubt, see the MSDN
// documentation.
// UEFI uses COFF/PE32+ format for binaries. All binaries must be statically linked. No dynamic
// linker is supported. As native to COFF, binaries are position-dependent, but will be relocated
// by the loader if the pre-chosen memory location is already in use.
// UEFI forbids running code on anything but the boot-CPU. Not interrupts are allowed other than
// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all
// code runs in the same environment, no process separation is supported.

use spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions};
use std::default::Default;

pub fn opts() -> TargetOptions {
let mut pre_link_args = LinkArgs::new();

pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Link), vec![
// Suppress the verbose logo and authorship debugging output, which would needlessly
// clog any log files.
"/NOLOGO".to_string(),

// UEFI is fully compatible to non-executable data pages. Tell the compiler that
// non-code sections can be marked as non-executable, including stack pages.
"/NXCOMPAT".to_string(),

// There is no runtime for UEFI targets, prevent them from being linked. UEFI targets
// must be freestanding.
"/nodefaultlib".to_string(),

// Non-standard subsystems have no default entry-point in PE+ files. We have to define
// one. "efi_main" seems to be a common choice amongst other implementations and the
// spec.
"/entry:efi_main".to_string(),

// COFF images have a "Subsystem" field in their header, which defines what kind of
// program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION,
// EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION,
// which is very likely the most common option. Individual projects can override this
// with custom linker flags.
// The subsystem-type only has minor effects on the application. It defines the memory
// regions the application is loaded into (runtime-drivers need to be put into
// reserved areas), as well as whether a return from the entry-point is treated as
// exit (default for applications).
"/subsystem:efi_application".to_string(),
]);

TargetOptions {
dynamic_linking: false,
executables: true,
disable_redzone: true,
exe_suffix: ".efi".to_string(),
allows_weak_linkage: false,
panic_strategy: PanicStrategy::Abort,
singlethread: true,
emit_debug_gdb_scripts: false,

linker: Some("lld-link".to_string()),
lld_flavor: LldFlavor::Link,
pre_link_args,

.. Default::default()
}
}
58 changes: 58 additions & 0 deletions src/librustc_target/spec/x86_64_unknown_uefi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// This defines the amd64 target for UEFI systems as described in the UEFI specification. See the
// uefi-base module for generic UEFI options. On x86_64 systems (mostly called "x64" in the spec)
// UEFI systems always run in long-mode, have the interrupt-controller pre-configured and force a
// single-CPU execution.
// The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with
// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.

use spec::{LinkerFlavor, LldFlavor, Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::uefi_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = Some(64);

// We disable MMX and SSE for now. UEFI does not prevent these from being used, but there have
// been reports to GRUB that some firmware does not initialize the FP exception handlers
// properly. Therefore, using FP coprocessors will end you up at random memory locations when
// you throw FP exceptions.
// To be safe, we disable them for now and force soft-float. This can be revisited when we
// have more test coverage. Disabling FP served GRUB well so far, so it should be good for us
// as well.
base.features = "-mmx,-sse,+soft-float".to_string();

// UEFI systems run without a host OS, hence we cannot assume any code locality. We must tell
// LLVM to expect code to reference any address in the address-space. The "large" code-model
// places no locality-restrictions, so it fits well here.
base.code_model = Some("large".to_string());

// UEFI mostly mirrors the calling-conventions used on windows. In case of x86-64 this means
// small structs will be returned as int. This shouldn't matter much, since the restrictions
// placed by the UEFI specifications forbid any ABI to return structures.
base.abi_return_struct_as_int = true;

Ok(Target {
llvm_target: "x86_64-unknown-windows".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
target_os: "uefi".to_string(),
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
arch: "x86_64".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Link),

options: base,
})
}