提交 e3590fcc 编写于 作者: B bors

Auto merge of #114637 - matthiaskrgr:rollup-544y8p5, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #106425 (Make ExitStatus implement Default)
 - #113480 (add aarch64-unknown-teeos target)
 - #113586 (Mention style for new syntax in tracking issue template)
 - #113593 (CFI: Fix error compiling core with LLVM CFI enabled)
 - #114612 (update llvm-wrapper include to silence deprecation warning)
 - #114613 (Prevent constant rebuilds of `rustc-main` (and thus everything else))
 - #114615 (interpret: remove incomplete protection against invalid where clauses)
 - #114628 (Allowing re-implementation of mir_drops_elaborated query)
 - #114629 (tests: Uncomment now valid GAT code behind FIXME)
 - #114630 (Migrate GUI colors test to original CSS color format)
 - #114631 (add provisional cache test for new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
......@@ -39,10 +39,13 @@ for larger features an implementation could be broken up into multiple PRs.
- [ ] Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
instructions?)
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
- [ ] Formatting for new syntax has been added to the [Style Guide] ([nightly-style-procedure])
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/master/nightly-style-procedure.md
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide
### Unresolved Questions
<!--
......
......@@ -472,6 +472,8 @@ pub(crate) unsafe fn llvm_optimize(
Some(llvm::SanitizerOptions {
sanitize_address: config.sanitizer.contains(SanitizerSet::ADDRESS),
sanitize_address_recover: config.sanitizer_recover.contains(SanitizerSet::ADDRESS),
sanitize_cfi: config.sanitizer.contains(SanitizerSet::CFI),
sanitize_kcfi: config.sanitizer.contains(SanitizerSet::KCFI),
sanitize_memory: config.sanitizer.contains(SanitizerSet::MEMORY),
sanitize_memory_recover: config.sanitizer_recover.contains(SanitizerSet::MEMORY),
sanitize_memory_track_origins: config.sanitizer_memory_track_origins as c_int,
......@@ -507,6 +509,7 @@ pub(crate) unsafe fn llvm_optimize(
&*module.module_llvm.tm,
to_pass_builder_opt_level(opt_level),
opt_stage,
cgcx.opts.cg.linker_plugin_lto.enabled(),
config.no_prepopulate_passes,
config.verify_llvm_ir,
using_thin_buffers,
......
......@@ -1512,9 +1512,9 @@ fn cfi_type_test(
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: &'ll Value,
) {
let is_indirect_call = unsafe { llvm::LLVMIsAFunction(llfn).is_none() };
if is_indirect_call && fn_abi.is_some() && self.tcx.sess.is_sanitizer_cfi_enabled() {
if fn_attrs.is_some() && fn_attrs.unwrap().no_sanitize.contains(SanitizerSet::CFI) {
let is_indirect_call = unsafe { llvm::LLVMRustIsNonGVFunctionPointerTy(llfn) };
if self.tcx.sess.is_sanitizer_cfi_enabled() && let Some(fn_abi) = fn_abi && is_indirect_call {
if let Some(fn_attrs) = fn_attrs && fn_attrs.no_sanitize.contains(SanitizerSet::CFI) {
return;
}
......@@ -1526,7 +1526,7 @@ fn cfi_type_test(
options.insert(TypeIdOptions::NORMALIZE_INTEGERS);
}
let typeid = typeid_for_fnabi(self.tcx, fn_abi.unwrap(), options);
let typeid = typeid_for_fnabi(self.tcx, fn_abi, options);
let typeid_metadata = self.cx.typeid_metadata(typeid).unwrap();
// Test whether the function pointer is associated with the type identifier.
......@@ -1550,25 +1550,26 @@ fn kcfi_operand_bundle(
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: &'ll Value,
) -> Option<llvm::OperandBundleDef<'ll>> {
let is_indirect_call = unsafe { llvm::LLVMIsAFunction(llfn).is_none() };
let kcfi_bundle = if is_indirect_call && self.tcx.sess.is_sanitizer_kcfi_enabled() {
if fn_attrs.is_some() && fn_attrs.unwrap().no_sanitize.contains(SanitizerSet::KCFI) {
return None;
}
let is_indirect_call = unsafe { llvm::LLVMRustIsNonGVFunctionPointerTy(llfn) };
let kcfi_bundle =
if self.tcx.sess.is_sanitizer_kcfi_enabled() && let Some(fn_abi) = fn_abi && is_indirect_call {
if let Some(fn_attrs) = fn_attrs && fn_attrs.no_sanitize.contains(SanitizerSet::KCFI) {
return None;
}
let mut options = TypeIdOptions::empty();
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
}
if self.tcx.sess.is_sanitizer_cfi_normalize_integers_enabled() {
options.insert(TypeIdOptions::NORMALIZE_INTEGERS);
}
let mut options = TypeIdOptions::empty();
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
}
if self.tcx.sess.is_sanitizer_cfi_normalize_integers_enabled() {
options.insert(TypeIdOptions::NORMALIZE_INTEGERS);
}
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi.unwrap(), options);
Some(llvm::OperandBundleDef::new("kcfi", &[self.const_u32(kcfi_typeid)]))
} else {
None
};
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi, options);
Some(llvm::OperandBundleDef::new("kcfi", &[self.const_u32(kcfi_typeid)]))
} else {
None
};
kcfi_bundle
}
}
......@@ -475,6 +475,8 @@ pub enum OptStage {
pub struct SanitizerOptions {
pub sanitize_address: bool,
pub sanitize_address_recover: bool,
pub sanitize_cfi: bool,
pub sanitize_kcfi: bool,
pub sanitize_memory: bool,
pub sanitize_memory_recover: bool,
pub sanitize_memory_track_origins: c_int,
......@@ -894,6 +896,7 @@ pub fn LLVMStructTypeInContext<'a>(
pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
pub fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool;
// Operations on constants of any type
pub fn LLVMConstNull(Ty: &Type) -> &Value;
......@@ -2138,6 +2141,7 @@ pub fn LLVMRustOptimize<'a>(
TM: &'a TargetMachine,
OptLevel: PassBuilderOptLevel,
OptStage: OptStage,
IsLinkerPluginLTO: bool,
NoPrepopulatePasses: bool,
VerifyIR: bool,
UseThinLTOBuffers: bool,
......
......@@ -303,8 +303,6 @@ const_eval_remainder_overflow =
overflow in signed remainder (dividing MIN by -1)
const_eval_scalar_size_mismatch =
scalar size mismatch: expected {$target_size} bytes but got {$data_size} bytes instead
const_eval_size_of_unsized =
size_of called on unsized type `{$ty}`
const_eval_size_overflow =
overflow computing total size of `{$name}`
......
......@@ -862,7 +862,6 @@ fn diagnostic_message(&self) -> DiagnosticMessage {
InvalidProgramInfo::FnAbiAdjustForForeignAbi(_) => {
rustc_middle::error::middle_adjust_for_foreign_abi_error
}
InvalidProgramInfo::SizeOfUnsizedType(_) => const_eval_size_of_unsized,
InvalidProgramInfo::ConstPropNonsense => {
panic!("We had const-prop nonsense, this should never be printed")
}
......@@ -890,9 +889,6 @@ fn add_args<G: EmissionGuarantee>(
builder.set_arg("arch", arch);
builder.set_arg("abi", abi.name());
}
InvalidProgramInfo::SizeOfUnsizedType(ty) => {
builder.set_arg("ty", ty);
}
}
}
}
......
......@@ -269,13 +269,10 @@ pub fn eval_rvalue_into_place(
let ty = self.subst_from_current_frame_and_normalize_erasing_regions(ty)?;
let layout = self.layout_of(ty)?;
if let mir::NullOp::SizeOf | mir::NullOp::AlignOf = null_op && layout.is_unsized() {
// FIXME: This should be a span_bug, but const generics can run MIR
// that is not properly type-checked yet (#97477).
self.tcx.sess.delay_span_bug(
span_bug!(
self.frame().current_span(),
format!("{null_op:?} MIR operator called for unsized type {ty}"),
"{null_op:?} MIR operator called for unsized type {ty}",
);
throw_inval!(SizeOfUnsizedType(ty));
}
let val = match null_op {
mir::NullOp::SizeOf => layout.size.bytes(),
......
......@@ -15,7 +15,6 @@
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetSelect.h"
......
......@@ -25,11 +25,11 @@
#if LLVM_VERSION_GE(17, 0)
#include "llvm/Support/VirtualFileSystem.h"
#endif
#include "llvm/Support/Host.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/AlwaysInliner.h"
#include "llvm/Transforms/IPO/FunctionImport.h"
#include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/Transforms/IPO/LowerTypeTests.h"
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
#include "llvm/Transforms/Utils/AddDiscriminators.h"
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
......@@ -609,6 +609,8 @@ enum class LLVMRustOptStage {
struct LLVMRustSanitizerOptions {
bool SanitizeAddress;
bool SanitizeAddressRecover;
bool SanitizeCFI;
bool SanitizeKCFI;
bool SanitizeMemory;
bool SanitizeMemoryRecover;
int SanitizeMemoryTrackOrigins;
......@@ -625,6 +627,7 @@ LLVMRustOptimize(
LLVMTargetMachineRef TMRef,
LLVMRustPassBuilderOptLevel OptLevelRust,
LLVMRustOptStage OptStage,
bool IsLinkerPluginLTO,
bool NoPrepopulatePasses, bool VerifyIR, bool UseThinLTOBuffers,
bool MergeFunctions, bool UnrollLoops, bool SLPVectorize, bool LoopVectorize,
bool DisableSimplifyLibCalls, bool EmitLifetimeMarkers,
......@@ -736,6 +739,18 @@ LLVMRustOptimize(
std::vector<std::function<void(ModulePassManager &, OptimizationLevel)>>
OptimizerLastEPCallbacks;
if (!IsLinkerPluginLTO
&& SanitizerOptions && SanitizerOptions->SanitizeCFI
&& !NoPrepopulatePasses) {
PipelineStartEPCallbacks.push_back(
[](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(LowerTypeTestsPass(/*ExportSummary=*/nullptr,
/*ImportSummary=*/nullptr,
/*DropTypeTests=*/false));
}
);
}
if (VerifyIR) {
PipelineStartEPCallbacks.push_back(
[VerifyIR](ModulePassManager &MPM, OptimizationLevel Level) {
......
......@@ -2033,3 +2033,14 @@ extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) {
extern "C" bool LLVMRustIsBitcode(char *ptr, size_t len) {
return identify_magic(StringRef(ptr, len)) == file_magic::bitcode;
}
extern "C" bool LLVMRustIsNonGVFunctionPointerTy(LLVMValueRef V) {
if (unwrap<Value>(V)->getType()->isPointerTy()) {
if (auto *GV = dyn_cast<GlobalValue>(unwrap<Value>(V))) {
if (GV->getValueType()->isFunctionTy())
return false;
}
return true;
}
return false;
}
......@@ -184,8 +184,6 @@ pub enum InvalidProgramInfo<'tcx> {
/// (which unfortunately typeck does not reject).
/// Not using `FnAbiError` as that contains a nested `LayoutError`.
FnAbiAdjustForForeignAbi(call::AdjustForForeignAbiError),
/// SizeOf of unsized type was requested.
SizeOfUnsizedType(Ty<'tcx>),
/// We are runnning into a nonsense situation due to ConstProp violating our invariants.
ConstPropNonsense,
}
......
......@@ -75,7 +75,7 @@
mod ffi_unwind_calls;
mod function_item_references;
mod generator;
mod inline;
pub mod inline;
mod instsimplify;
mod large_enums;
mod lower_intrinsics;
......@@ -431,7 +431,9 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
tcx.alloc_steal_mir(body)
}
fn run_analysis_to_runtime_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// Made public such that `mir_drops_elaborated_and_const_checked` can be overridden
// by custom rustc drivers, running all the steps by themselves.
pub fn run_analysis_to_runtime_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
assert!(body.phase == MirPhase::Analysis(AnalysisPhase::Initial));
let did = body.source.def_id();
......
......@@ -89,7 +89,9 @@ session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-genera
session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`
session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`
session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`
session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`
session_sanitizer_not_supported = {$us} sanitizer is not supported for this target
......
......@@ -114,6 +114,10 @@ pub struct CannotMixAndMatchSanitizers {
#[diag(session_sanitizer_cfi_requires_lto)]
pub struct SanitizerCfiRequiresLto;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_requires_single_codegen_unit)]
pub struct SanitizerCfiRequiresSingleCodegenUnit;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_canonical_jump_tables_requires_cfi)]
pub struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
......
......@@ -1619,13 +1619,19 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
// LLVM CFI requires LTO.
if sess.is_sanitizer_cfi_enabled()
&& !(sess.lto() == config::Lto::Fat
|| sess.lto() == config::Lto::Thin
|| sess.opts.cg.linker_plugin_lto.enabled())
&& !(sess.lto() == config::Lto::Fat || sess.opts.cg.linker_plugin_lto.enabled())
{
sess.emit_err(errors::SanitizerCfiRequiresLto);
}
// LLVM CFI using rustc LTO requires a single codegen unit.
if sess.is_sanitizer_cfi_enabled()
&& sess.lto() == config::Lto::Fat
&& !(sess.codegen_units().as_usize() == 1)
{
sess.emit_err(errors::SanitizerCfiRequiresSingleCodegenUnit);
}
// LLVM CFI is incompatible with LLVM KCFI.
if sess.is_sanitizer_cfi_enabled() && sess.is_sanitizer_kcfi_enabled() {
sess.emit_err(errors::CannotMixAndMatchSanitizers {
......
use crate::spec::Target;
pub fn target() -> Target {
let mut base = super::teeos_base::opts();
base.features = "+strict-align,+neon,+fp-armv8".into();
base.max_atomic_width = Some(128);
base.linker = Some("aarch64-linux-gnu-ld".into());
Target {
llvm_target: "aarch64-unknown-none".into(),
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
options: base,
}
}
......@@ -83,6 +83,7 @@
mod redox_base;
mod solaris_base;
mod solid_base;
mod teeos_base;
mod thumb_base;
mod uefi_msvc_base;
mod unikraft_linux_musl_base;
......@@ -1494,6 +1495,8 @@ fn $module() {
("x86_64-unknown-none", x86_64_unknown_none),
("aarch64-unknown-teeos", aarch64_unknown_teeos),
("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl),
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx_710),
......
use super::{Cc, LinkerFlavor, Lld, PanicStrategy};
use crate::spec::{RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"];
let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"];
let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args);
super::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);
TargetOptions {
os: "teeos".into(),
vendor: "unknown".into(),
dynamic_linking: true,
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
// rpath hardcodes -Wl, so it can't be used together with ld.lld.
// C TAs also don't support rpath, so this is fine.
has_rpath: false,
// Note: Setting has_thread_local to true causes an error when
// loading / dyn-linking the TA
has_thread_local: false,
position_independent_executables: true,
relro_level: RelroLevel::Full,
crt_static_respected: true,
pre_link_args,
panic_strategy: PanicStrategy::Abort,
..Default::default()
}
}
......@@ -1528,7 +1528,7 @@ fn from(file: fs::File) -> Stdio {
// vs `_exit`. Naming of Unix system calls is not standardised across Unices, so terminology is a
// matter of convention and tradition. For clarity we usually speak of `exit`, even when we might
// mean an underlying system call such as `_exit`.
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
#[stable(feature = "process", since = "1.0.0")]
pub struct ExitStatus(imp::ExitStatus);
......
......@@ -235,7 +235,7 @@ pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
}
}
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
pub struct ExitStatus(i64);
impl ExitStatus {
......
......@@ -800,7 +800,7 @@ pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
//
// This is not actually an "exit status" in Unix terminology. Rather, it is a "wait status".
// See the discussion in comments and doc comments for `std::process::ExitStatus`.
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(PartialEq, Eq, Clone, Copy, Default)]
pub struct ExitStatus(c_int);
impl fmt::Debug for ExitStatus {
......
......@@ -55,7 +55,7 @@ pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
}
}
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
pub struct ExitStatus(c_int);
impl ExitStatus {
......
......@@ -179,7 +179,7 @@ pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
}
/// Unix exit statuses
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
pub struct ExitStatus(c_int);
impl ExitStatus {
......
......@@ -99,58 +99,59 @@ fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
pub struct ExitStatus(!);
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
#[non_exhaustive]
pub struct ExitStatus();
impl ExitStatus {
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
self.0
Ok(())
}
pub fn code(&self) -> Option<i32> {
self.0
Some(0)
}
}
impl Clone for ExitStatus {
fn clone(&self) -> ExitStatus {
self.0
impl fmt::Display for ExitStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<dummy exit status>")
}
}
impl Copy for ExitStatus {}
pub struct ExitStatusError(!);
impl PartialEq for ExitStatus {
fn eq(&self, _other: &ExitStatus) -> bool {
impl Clone for ExitStatusError {
fn clone(&self) -> ExitStatusError {
self.0
}
}
impl Eq for ExitStatus {}
impl Copy for ExitStatusError {}
impl fmt::Debug for ExitStatus {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl PartialEq for ExitStatusError {
fn eq(&self, _other: &ExitStatusError) -> bool {
self.0
}
}
impl fmt::Display for ExitStatus {
impl Eq for ExitStatusError {}
impl fmt::Debug for ExitStatusError {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0
}
}
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub struct ExitStatusError(ExitStatus);
impl Into<ExitStatus> for ExitStatusError {
fn into(self) -> ExitStatus {
self.0.0
self.0
}
}
impl ExitStatusError {
pub fn code(self) -> Option<NonZeroI32> {
self.0.0
self.0
}
}
......
......@@ -652,7 +652,7 @@ pub fn into_handle(self) -> Handle {
}
}
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
pub struct ExitStatus(c::DWORD);
impl ExitStatus {
......
......@@ -31,6 +31,7 @@
use crate::util::{exe, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date};
use crate::LLVM_TOOLS;
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
use filetime::FileTime;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Std {
......@@ -904,19 +905,12 @@ fn run(self, builder: &Builder<'_>) {
// our LLVM wrapper. Unless we're explicitly requesting `librustc_driver` to be built with
// debuginfo (via the debuginfo level of the executables using it): strip this debuginfo
// away after the fact.
// FIXME: to make things simpler for now, limit this to the host and target where we know
// `strip -g` is both available and will fix the issue, i.e. on a x64 linux host that is not
// cross-compiling. Expand this to other appropriate targets in the future.
if builder.config.rust_debuginfo_level_rustc == DebuginfoLevel::None
&& builder.config.rust_debuginfo_level_tools == DebuginfoLevel::None
&& target == "x86_64-unknown-linux-gnu"
&& target == builder.config.build
{
let target_root_dir = stamp.parent().unwrap();
let rustc_driver = target_root_dir.join("librustc_driver.so");
if rustc_driver.exists() {
output(Command::new("strip").arg("--strip-debug").arg(rustc_driver));
}
strip_debug(builder, target, &rustc_driver);
}
builder.ensure(RustcLink::from_rustc(
......@@ -1974,3 +1968,30 @@ pub enum CargoMessage<'a> {
success: bool,
},
}
pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path) {
// FIXME: to make things simpler for now, limit this to the host and target where we know
// `strip -g` is both available and will fix the issue, i.e. on a x64 linux host that is not
// cross-compiling. Expand this to other appropriate targets in the future.
if target != "x86_64-unknown-linux-gnu" || target != builder.config.build || !path.exists() {
return;
}
let previous_mtime = FileTime::from_last_modification_time(&path.metadata().unwrap());
// Note: `output` will propagate any errors here.
output(Command::new("strip").arg("--strip-debug").arg(path));
// After running `strip`, we have to set the file modification time to what it was before,
// otherwise we risk Cargo invalidating its fingerprint and rebuilding the world next time
// bootstrap is invoked.
//
// An example of this is if we run this on librustc_driver.so. In the first invocation:
// - Cargo will build librustc_driver.so (mtime of 1)
// - Cargo will build rustc-main (mtime of 2)
// - Bootstrap will strip librustc_driver.so (changing the mtime to 3).
//
// In the second invocation of bootstrap, Cargo will see that the mtime of librustc_driver.so
// is greater than the mtime of rustc-main, and will rebuild rustc-main. That will then cause
// everything else (standard library, future stages...) to be rebuilt.
t!(filetime::set_file_mtime(path, previous_mtime));
}
......@@ -133,7 +133,7 @@ pub unsafe fn setup(_build: &mut crate::Build) {}
// #[cfg(bootstrap)]
(Some(Mode::Std), "target_vendor", Some(&["unikraft"])),
(Some(Mode::Std), "target_env", Some(&["libnx"])),
// (Some(Mode::Std), "target_os", Some(&[])),
(Some(Mode::Std), "target_os", Some(&["teeos"])),
// #[cfg(bootstrap)] mips32r6, mips64r6
(
Some(Mode::Std),
......
......@@ -512,27 +512,21 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
// When building LLVM as a shared library on linux, it can contain unexpected debuginfo:
// some can come from the C++ standard library. Unless we're explicitly requesting LLVM to
// be built with debuginfo, strip it away after the fact, to make dist artifacts smaller.
// FIXME: to make things simpler for now, limit this to the host and target where we know
// `strip -g` is both available and will fix the issue, i.e. on a x64 linux host that is not
// cross-compiling. Expand this to other appropriate targets in the future.
if builder.llvm_link_shared()
&& builder.config.llvm_optimize
&& !builder.config.llvm_release_debuginfo
&& target == "x86_64-unknown-linux-gnu"
&& target == builder.config.build
{
// Find the name of the LLVM shared library that we just built.
let lib_name = find_llvm_lib_name("so");
// If the shared library exists in LLVM's `/build/lib/` or `/lib/` folders, strip its
// debuginfo. Note: `output` will propagate any errors here.
let strip_if_possible = |path: PathBuf| {
if path.exists() {
output(Command::new("strip").arg("--strip-debug").arg(path));
}
};
strip_if_possible(out_dir.join("lib").join(&lib_name));
strip_if_possible(out_dir.join("build").join("lib").join(&lib_name));
// debuginfo.
crate::compile::strip_debug(builder, target, &out_dir.join("lib").join(&lib_name));
crate::compile::strip_debug(
builder,
target,
&out_dir.join("build").join("lib").join(&lib_name),
);
}
t!(stamp.write());
......
......@@ -28,6 +28,7 @@
- [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md)
- [\*-android and \*-androideabi](platform-support/android.md)
- [\*-linux-ohos](platform-support/openharmony.md)
- [aarch64-unknown-teeos](platform-support/aarch64-unknown-teeos.md)
- [\*-esp-espidf](platform-support/esp-idf.md)
- [\*-unknown-fuchsia](platform-support/fuchsia.md)
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
......
......@@ -221,6 +221,7 @@ target | std | host | notes
[`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon
[`aarch64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ |
[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | | ARM64 OpenHarmony |
[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
[`aarch64-unknown-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS |
`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
[`aarch64-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit
......
# `aarch64-unknown-teeos`
**Tier: 3**
Target for the TEEOS operating system.
TEEOS is a mini os run in TrustZone, for trusted/security apps. The kernel of TEEOS is HongMeng/ChCore micro kernel. The libc for TEEOS is a part of musl.
It's very small that there is no RwLock, no network, no stdin, and no file system for apps in TEEOS.
Some abbreviation:
| Abbreviation | The full text | Description |
| ---- | ---- | ---- |
| TEE | Trusted Execution Environment | ARM TrustZone devide the system into two worlds/modes -- the secure world/mode and the normal world/mode. TEE is in the secure world/mode. |
| REE | Rich Execution Environment | The normal world. for example, Linux for Android phone is in REE side. |
| TA | Trusted Application | The app run in TEE side system. |
| CA | Client Application | The progress run in REE side system. |
TEEOS is open source in progress. [MORE about](https://gitee.com/opentrustee-group)
## Target maintainers
- Petrochenkov Vadim
- Sword-Destiny
## Setup
We use OpenHarmony SDK for TEEOS.
The OpenHarmony SDK doesn't currently support Rust compilation directly, so
some setup is required.
First, you must obtain the OpenHarmony SDK from [this page](https://gitee.com/openharmony/docs/tree/master/en/release-notes).
Select the version of OpenHarmony you are developing for and download the "Public SDK package for the standard system".
Create the following shell scripts that wrap Clang from the OpenHarmony SDK:
`aarch64-unknown-teeos-clang.sh`
```sh
#!/bin/sh
exec /path/to/ohos-sdk/linux/native/llvm/bin/clang \
--target aarch64-linux-gnu \
"$@"
```
`aarch64-unknown-teeos-clang++.sh`
```sh
#!/bin/sh
exec /path/to/ohos-sdk/linux/native/llvm/bin/clang++ \
--target aarch64-linux-gnu \
"$@"
```
## Building the target
To build a rust toolchain, create a `config.toml` with the following contents:
```toml
profile = "compiler"
changelog-seen = 2
[build]
sanitizers = true
profiler = true
target = ["x86_64-unknown-linux-gnu", "aarch64-unknown-teeos"]
submodules = false
compiler-docs = false
extended = true
[install]
bindir = "bin"
libdir = "lib"
[target.aarch64-unknown-teeos]
cc = "/path/to/scripts/aarch64-unknown-teeos-clang.sh"
cxx = "/path/to/scripts/aarch64-unknown-teeos-clang.sh"
linker = "/path/to/scripts/aarch64-unknown-teeos-clang.sh"
ar = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
ranlib = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ranlib"
llvm-config = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-config"
```
## Building Rust programs
Rust does not yet ship pre-compiled artifacts for this target. To compile for
this target, you will either need to build Rust with the target enabled (see
"Building the target" above), or build your own copy of `core` by using
`build-std` or similar.
You will need to configure the linker to use in `~/.cargo/config`:
```toml
[target.aarch64-unknown-teeos]
linker = "/path/to/aarch64-unknown-teeos-clang.sh"
```
## Testing
Running the Rust testsuite is not possible now.
More information about how to test CA/TA. [See here](https://gitee.com/openharmony-sig/tee_tee_dev_kit/tree/master/docs)
......@@ -1645,7 +1645,7 @@ fn check_expected_errors(&self, expected_errors: Vec<errors::Error>, proc_res: &
if self.props.known_bug {
if !expected_errors.is_empty() {
self.fatal_proc_rec(
"`known_bug` tests should not have an expected errors",
"`known_bug` tests should not have an expected error",
proc_res,
);
}
......
......@@ -46,53 +46,53 @@ call-function: (
"check-colors",
{
"theme": "ayu",
"mod": "rgb(57, 175, 215)",
"macro": "rgb(163, 122, 204)",
"struct": "rgb(255, 160, 165)",
"enum": "rgb(255, 160, 165)",
"trait": "rgb(57, 175, 215)",
"fn": "rgb(253, 214, 135)",
"type": "rgb(255, 160, 165)",
"union": "rgb(255, 160, 165)",
"keyword": "rgb(57, 175, 215)",
"sidebar": "rgb(83, 177, 219)",
"sidebar_current": "rgb(255, 180, 76)",
"sidebar_current_background": "rgba(0, 0, 0, 0)",
"mod": "#39afd7",
"macro": "#a37acc",
"struct": "#ffa0a5",
"enum": "#ffa0a5",
"trait": "#39afd7",
"fn": "#fdd687",
"type": "#ffa0a5",
"union": "#ffa0a5",
"keyword": "#39afd7",
"sidebar": "#53b1db",
"sidebar_current": "#ffb44c",
"sidebar_current_background": "transparent",
},
)
call-function: (
"check-colors",
{
"theme": "dark",
"mod": "rgb(210, 153, 29)",
"macro": "rgb(9, 189, 0)",
"struct": "rgb(45, 191, 184)",
"enum": "rgb(45, 191, 184)",
"trait": "rgb(183, 140, 242)",
"fn": "rgb(43, 171, 99)",
"type": "rgb(45, 191, 184)",
"union": "rgb(45, 191, 184)",
"keyword": "rgb(210, 153, 29)",
"sidebar": "rgb(253, 191, 53)",
"sidebar_current": "rgb(253, 191, 53)",
"sidebar_current_background": "rgb(68, 68, 68)",
"mod": "#d2991d",
"macro": "#09bd00",
"struct": "#2dbfb8",
"enum": "#2dbfb8",
"trait": "#b78cf2",
"fn": "#2bab63",
"type": "#2dbfb8",
"union": "#2dbfb8",
"keyword": "#d2991d",
"sidebar": "#fdbf35",
"sidebar_current": "#fdbf35",
"sidebar_current_background": "#444",
},
)
call-function: (
"check-colors",
{
"theme": "light",
"mod": "rgb(56, 115, 173)",
"macro": "rgb(6, 128, 0)",
"struct": "rgb(173, 55, 138)",
"enum": "rgb(173, 55, 138)",
"trait": "rgb(110, 79, 201)",
"fn": "rgb(173, 124, 55)",
"type": "rgb(173, 55, 138)",
"union": "rgb(173, 55, 138)",
"keyword": "rgb(56, 115, 173)",
"sidebar": "rgb(53, 109, 164)",
"sidebar_current": "rgb(53, 109, 164)",
"sidebar_current_background": "rgb(255, 255, 255)",
"mod": "#3873ad",
"macro": "#068000",
"struct": "#ad378a",
"enum": "#ad378a",
"trait": "#6e4fc9",
"fn": "#ad7c37",
"type": "#ad378a",
"union": "#ad378a",
"keyword": "#3873ad",
"sidebar": "#356da4",
"sidebar_current": "#356da4",
"sidebar_current_background": "#fff",
},
)
......@@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")]
| |
| help: there is a expected value with a similar name: `"linux"`
|
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted
......
......@@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")]
| |
| help: there is a expected value with a similar name: `"linux"`
|
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
......
// check-fail
// known-bug: #97477
// failure-status: 101
// normalize-stderr-test "note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
// rustc-env:RUST_BACKTRACE=0
// This test used to cause an ICE in rustc_mir::interpret::step::eval_rvalue_into_place
......@@ -27,6 +32,5 @@ pub fn new(val: T) -> Inline<T> {
}
fn main() {
let dst = Inline::<dyn Debug>::new(0); //~ ERROR
//~^ ERROR
let dst = Inline::<dyn Debug>::new(0);
}
error[E0080]: evaluation of `Inline::<dyn Debug>::{constant#0}` failed
error: internal compiler error: compiler/rustc_const_eval/src/interpret/step.rs:272:21: SizeOf MIR operator called for unsized type dyn Debug
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
= note: size_of called on unsized type `dyn Debug`
|
note: inside `std::mem::size_of::<dyn Debug>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
note: inside `Inline::<dyn Debug>::{constant#0}`
--> $DIR/issue-80742.rs:22:10
|
LL | [u8; size_of::<T>() + 1]: ,
| ^^^^^^^^^^^^^^
error[E0599]: the function or associated item `new` exists for struct `Inline<dyn Debug>`, but its trait bounds were not satisfied
--> $DIR/issue-80742.rs:30:36
|
LL | struct Inline<T>
| ---------------- function or associated item `new` not found for this struct
...
LL | let dst = Inline::<dyn Debug>::new(0);
| ^^^ function or associated item cannot be called on `Inline<dyn Debug>` due to unsatisfied trait bounds
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: doesn't satisfy `dyn Debug: Sized`
|
note: trait bound `dyn Debug: Sized` was not satisfied
--> $DIR/issue-80742.rs:20:6
|
LL | impl<T> Inline<T>
| ^ ---------
| |
| unsatisfied trait bound introduced here
help: consider relaxing the type parameter's implicit `Sized` bound
|
LL | impl<T: ?Sized> Inline<T>
| ++++++++
error[E0080]: evaluation of `Inline::<dyn Debug>::{constant#0}` failed
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
= note: size_of called on unsized type `dyn Debug`
|
note: inside `std::mem::size_of::<dyn Debug>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
note: inside `Inline::<dyn Debug>::{constant#0}`
--> $DIR/issue-80742.rs:14:10
|
LL | [u8; size_of::<T>() + 1]: ,
| ^^^^^^^^^^^^^^
error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
--> $DIR/issue-80742.rs:30:15
|
LL | let dst = Inline::<dyn Debug>::new(0);
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Debug`
note: required by a bound in `Inline`
--> $DIR/issue-80742.rs:12:15
|
LL | struct Inline<T>
| ^ required by this bound in `Inline`
help: consider relaxing the implicit `Sized` restriction
|
LL | struct Inline<T: ?Sized>
| ++++++++
error: aborting due to 4 previous errors
Box<dyn Any>
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:25:1: 25:18>::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
end of query stack
error: aborting due to previous error
Some errors have detailed explanations: E0080, E0277, E0599.
For more information about an error, try `rustc --explain E0080`.
......@@ -15,8 +15,7 @@ struct Foo<T: StreamingIterator + 'static> {
// Users can bound parameters by the type constructed by that trait's associated type constructor
// of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid:
//FIXME(#44265): This next line should parse and be valid
//fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(_iter: T) { /* ... */ }
fn _bar<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(_iter: T) { /* ... */ }
fn _foo<T>(_iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
// Full example of enumerate iterator
......
// run-pass
// build-pass
// needs-sanitizer-cfi
// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
// compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
// no-prefer-dynamic
// only-x86_64-unknown-linux-gnu
......
......@@ -2,10 +2,10 @@
// encode_ty and caused the compiler to ICE.
//
// needs-sanitizer-cfi
// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021
// compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021
// no-prefer-dynamic
// only-x86_64-unknown-linux-gnu
// run-pass
// build-pass
use std::future::Future;
......
// Verifies that `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`.
// Verifies that `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`.
//
// needs-sanitizer-cfi
// compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
......
error: `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`
error: `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`
error: aborting due to previous error
// Verifies that `-Zsanitizer=cfi` with `-Clto` or `-Clto=thin` requires `-Ccodegen-units=1`.
//
// needs-sanitizer-cfi
// compile-flags: -Ccodegen-units=2 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
#![feature(no_core)]
#![no_core]
#![no_main]
error: `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`
error: aborting due to previous error
// compile-flags: -Ztrait-solver=next
#![feature(rustc_attrs, trivial_bounds)]
// We have to be careful here:
//
// We either have the provisional result of `A -> B -> A` on the
// stack, which is a fully coinductive cycle. Accessing the
// provisional result for `B` as part of the `A -> C -> B -> A` cycle
// has to make sure we don't just use the result of `A -> B -> A` as the
// new cycle is inductive.
//
// Alternatively, if we have `A -> C -> A` first, then `A -> B -> A` has
// a purely inductive stack, so something could also go wrong here.
#[rustc_coinductive]
trait A {}
#[rustc_coinductive]
trait B {}
trait C {}
impl<T: B + C> A for T {}
impl<T: A> B for T {}
impl<T: B> C for T {}
fn impls_a<T: A>() {}
// The same test with reordered where clauses to make sure we're actually testing anything.
#[rustc_coinductive]
trait AR {}
#[rustc_coinductive]
trait BR {}
trait CR {}
impl<T: CR + BR> AR for T {}
impl<T: AR> BR for T {}
impl<T: BR> CR for T {}
fn impls_ar<T: AR>() {}
fn main() {
impls_a::<()>();
//~^ ERROR overflow evaluating the requirement `(): A`
impls_ar::<()>();
//~^ ERROR overflow evaluating the requirement `(): AR`
}
error[E0275]: overflow evaluating the requirement `(): A`
--> $DIR/inductive-not-on-stack.rs:41:5
|
LL | impls_a::<()>();
| ^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`)
note: required by a bound in `impls_a`
--> $DIR/inductive-not-on-stack.rs:25:15
|
LL | fn impls_a<T: A>() {}
| ^ required by this bound in `impls_a`
error[E0275]: overflow evaluating the requirement `(): AR`
--> $DIR/inductive-not-on-stack.rs:44:5
|
LL | impls_ar::<()>();
| ^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`)
note: required by a bound in `impls_ar`
--> $DIR/inductive-not-on-stack.rs:38:16
|
LL | fn impls_ar<T: AR>() {}
| ^^ required by this bound in `impls_ar`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0275`.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册