diff --git a/src/bin/bpf-linker.rs b/src/bin/bpf-linker.rs index 59b40d1d..16d90a4b 100644 --- a/src/bin/bpf-linker.rs +++ b/src/bin/bpf-linker.rs @@ -141,7 +141,7 @@ struct CommandLine { export: Vec, /// Whether to treat LLVM errors as fatal. - #[clap(long, action = clap::ArgAction::Set, default_value_t = false)] + #[clap(long, action = clap::ArgAction::Set, default_value_t = true)] fatal_errors: bool, // The options below are for wasm-ld compatibility diff --git a/src/linker.rs b/src/linker.rs index 3a389c18..adbc7378 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -516,8 +516,24 @@ impl Linker { impl llvm::LLVMDiagnosticHandler for Linker { fn handle_diagnostic(&mut self, severity: llvm_sys::LLVMDiagnosticSeverity, message: &str) { + // TODO(https://reviews.llvm.org/D155894): Remove this when LLVM no longer emits these + // errors. + // + // See https://github.com/rust-lang/compiler-builtins/blob/a61823f/src/mem/mod.rs#L22-L68. + const MATCHERS: &[&str] = &[ + "A call to built-in function 'memcpy' is not supported.\n", + "A call to built-in function 'memmove' is not supported.\n", + "A call to built-in function 'memset' is not supported.\n", + "A call to built-in function 'memcmp' is not supported.\n", + "A call to built-in function 'bcmp' is not supported.\n", + "A call to built-in function 'strlen' is not supported.\n", + ]; + match severity { llvm_sys::LLVMDiagnosticSeverity::LLVMDSError => { + if MATCHERS.iter().any(|matcher| message.ends_with(matcher)) { + return; + } self.has_errors = true; error!("llvm: {}", message) diff --git a/tests/assembly/auxiliary/dep.rs b/tests/assembly/auxiliary/dep.rs index ab4d963a..1d55fb17 100644 --- a/tests/assembly/auxiliary/dep.rs +++ b/tests/assembly/auxiliary/dep.rs @@ -5,4 +5,4 @@ #[no_mangle] fn some_dep() -> u8 { 42 -} \ No newline at end of file +} diff --git a/tests/assembly/auxiliary/loop-panic-handler.rs b/tests/assembly/auxiliary/loop-panic-handler.rs index e7977e93..76953359 100644 --- a/tests/assembly/auxiliary/loop-panic-handler.rs +++ b/tests/assembly/auxiliary/loop-panic-handler.rs @@ -6,4 +6,3 @@ fn panic_impl(_: &core::panic::PanicInfo) -> ! { loop {} } - diff --git a/tests/assembly/elf-sections.rs b/tests/assembly/elf-sections.rs index 5c3095fe..3ff43f97 100644 --- a/tests/assembly/elf-sections.rs +++ b/tests/assembly/elf-sections.rs @@ -22,4 +22,4 @@ static mut COUNTER: u32 = 0; // CHECK: .section "uprobe/connect","ax" // CHECK: .section "uprobe/dep","ax" -// CHECK: .section "maps/counter","aw" \ No newline at end of file +// CHECK: .section "maps/counter","aw" diff --git a/tests/assembly/re-export-symbols.rs b/tests/assembly/re-export-symbols.rs index 003641e1..3a98e4c9 100644 --- a/tests/assembly/re-export-symbols.rs +++ b/tests/assembly/re-export-symbols.rs @@ -15,4 +15,4 @@ fn connect() { } // CHECK: .globl connect -// CHECK: .globl some_dep \ No newline at end of file +// CHECK: .globl some_dep