From f6484fa9b59585cf0609aa6f047015270f6e1d19 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:34:24 +0000 Subject: [PATCH 1/3] Avoid unnecessary string interning for const_str --- compiler/rustc_codegen_gcc/src/common.rs | 16 ++++---- compiler/rustc_codegen_gcc/src/context.rs | 4 +- compiler/rustc_codegen_gcc/src/lib.rs | 9 ++++- compiler/rustc_codegen_llvm/src/common.rs | 38 ++++++++++--------- compiler/rustc_codegen_llvm/src/context.rs | 3 +- compiler/rustc_codegen_llvm/src/lib.rs | 1 + compiler/rustc_codegen_ssa/src/mir/block.rs | 5 +-- .../rustc_codegen_ssa/src/traits/consts.rs | 3 +- 8 files changed, 45 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs index ce341406eaf45..d156f87443497 100644 --- a/compiler/rustc_codegen_gcc/src/common.rs +++ b/compiler/rustc_codegen_gcc/src/common.rs @@ -12,7 +12,6 @@ use rustc_middle::mir::Mutability; use rustc_middle::ty::ScalarInt; use rustc_middle::ty::layout::{TyAndLayout, LayoutOf}; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; -use rustc_span::Symbol; use rustc_target::abi::{self, HasDataLayout, Pointer, Size}; use crate::consts::const_alloc_to_gcc; @@ -125,12 +124,15 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { self.context.new_rvalue_from_double(typ, val) } - fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) { - let s_str = s.as_str(); - let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| { - self.global_string(s_str) - }); - let len = s_str.len(); + fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) { + let str_global = *self + .const_str_cache + .borrow_mut() + .raw_entry_mut() + .from_key(s) + .or_insert_with(|| (s.to_owned(), self.global_string(s))) + .1; + let len = s.len(); let cs = self.const_ptrcast(str_global.get_address(None), self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)), ); diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index 44f36cfa4cad4..478f6d893dd0f 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -13,7 +13,7 @@ use rustc_middle::mir::mono::CodegenUnit; use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}; use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, TyAndLayout, LayoutOfHelpers}; use rustc_session::Session; -use rustc_span::{Span, Symbol}; +use rustc_span::Span; use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx}; use rustc_target::spec::{HasTargetSpec, Target, TlsModel}; @@ -101,7 +101,7 @@ pub struct CodegenCx<'gcc, 'tcx> { pub global_lvalues: RefCell, LValue<'gcc>>>, /// Cache of constant strings, - pub const_str_cache: RefCell>>, + pub const_str_cache: RefCell>>, /// Cache of globals. pub globals: RefCell>>, diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 5bfdeb8b93a48..399830de84cb9 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -6,7 +6,14 @@ * TODO(antoyo): remove the patches. */ -#![feature(rustc_private, decl_macro, associated_type_bounds, never_type, trusted_len)] +#![feature( + rustc_private, + decl_macro, + associated_type_bounds, + never_type, + trusted_len, + hash_raw_entry +)] #![allow(broken_intra_doc_links)] #![recursion_limit="256"] #![warn(rust_2018_idioms)] diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index b69d7a000ee9a..8a9902eed876e 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -14,7 +14,6 @@ use rustc_middle::bug; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::ScalarInt; -use rustc_span::symbol::Symbol; use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer, Size}; use libc::{c_char, c_uint}; @@ -181,22 +180,27 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { unsafe { llvm::LLVMConstReal(t, val) } } - fn const_str(&self, s: Symbol) -> (&'ll Value, &'ll Value) { - let s_str = s.as_str(); - let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| { - let sc = self.const_bytes(s_str.as_bytes()); - let sym = self.generate_local_symbol_name("str"); - let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| { - bug!("symbol `{}` is already defined", sym); - }); - unsafe { - llvm::LLVMSetInitializer(g, sc); - llvm::LLVMSetGlobalConstant(g, True); - llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage); - } - g - }); - let len = s_str.len(); + fn const_str(&self, s: &str) -> (&'ll Value, &'ll Value) { + let str_global = *self + .const_str_cache + .borrow_mut() + .raw_entry_mut() + .from_key(s) + .or_insert_with(|| { + let sc = self.const_bytes(s.as_bytes()); + let sym = self.generate_local_symbol_name("str"); + let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| { + bug!("symbol `{}` is already defined", sym); + }); + unsafe { + llvm::LLVMSetInitializer(g, sc); + llvm::LLVMSetGlobalConstant(g, True); + llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage); + } + (s.to_owned(), g) + }) + .1; + let len = s.len(); let cs = consts::ptrcast( str_global, self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)), diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index c007728095f79..55e4a4a7255b5 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -26,7 +26,6 @@ use rustc_session::config::{BranchProtection, CFGuard, CFProtection}; use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet}; use rustc_session::Session; use rustc_span::source_map::Span; -use rustc_span::symbol::Symbol; use rustc_target::abi::{ call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx, }; @@ -56,7 +55,7 @@ pub struct CodegenCx<'ll, 'tcx> { pub vtables: RefCell, Option>), &'ll Value>>, /// Cache of constant strings, - pub const_str_cache: RefCell>, + pub const_str_cache: RefCell>, /// Reverse-direction for const ptrs cast from globals. /// diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 6713a75673550..a7dd8e16d28eb 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -5,6 +5,7 @@ //! This API is completely unstable and subject to change. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] +#![feature(hash_raw_entry)] #![feature(let_chains)] #![feature(let_else)] #![feature(extern_types)] diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index db348f2bdd507..96a859992e980 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -481,8 +481,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { (LangItem::PanicBoundsCheck, vec![index, len, location]) } _ => { - let msg_str = Symbol::intern(msg.description()); - let msg = bx.const_str(msg_str); + let msg = bx.const_str(msg.description()); // It's `pub fn panic(expr: &str)`, with the wide reference being passed // as two arguments, and `#[track_caller]` adds an implicit third argument. (LangItem::Panic, vec![msg.0, msg.1, location]) @@ -563,7 +562,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } }) }); - let msg = bx.const_str(Symbol::intern(&msg_str)); + let msg = bx.const_str(&msg_str); let location = self.get_caller_location(bx, source_info).immediate(); // Obtain the panic entry point. diff --git a/compiler/rustc_codegen_ssa/src/traits/consts.rs b/compiler/rustc_codegen_ssa/src/traits/consts.rs index c3519a24d5325..fdc7a30e841ed 100644 --- a/compiler/rustc_codegen_ssa/src/traits/consts.rs +++ b/compiler/rustc_codegen_ssa/src/traits/consts.rs @@ -2,7 +2,6 @@ use super::BackendTypes; use crate::mir::place::PlaceRef; use rustc_middle::mir::interpret::{ConstAllocation, Scalar}; use rustc_middle::ty::layout::TyAndLayout; -use rustc_span::Symbol; use rustc_target::abi::{self, Size}; pub trait ConstMethods<'tcx>: BackendTypes { @@ -21,7 +20,7 @@ pub trait ConstMethods<'tcx>: BackendTypes { fn const_u8(&self, i: u8) -> Self::Value; fn const_real(&self, t: Self::Type, val: f64) -> Self::Value; - fn const_str(&self, s: Symbol) -> (Self::Value, Self::Value); + fn const_str(&self, s: &str) -> (Self::Value, Self::Value); fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value; fn const_to_opt_uint(&self, v: Self::Value) -> Option; From de57dbcefd50da2d512929a6fb8e205751793f7d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:34:52 +0000 Subject: [PATCH 2/3] Use pre-interned symbols in import recovery --- compiler/rustc_parse/src/parser/item.rs | 3 +-- compiler/rustc_span/src/symbol.rs | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index bf685aa8cadc3..87bc0d9762ea5 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -271,8 +271,7 @@ impl<'a> Parser<'a> { // MACRO_RULES ITEM self.parse_item_macro_rules(vis, has_bang)? } else if self.isnt_macro_invocation() - && (self.token.is_ident_named(Symbol::intern("import")) - || self.token.is_ident_named(Symbol::intern("using"))) + && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using)) { return self.recover_import_as_use(); } else if self.isnt_macro_invocation() && vis.kind.is_pub() { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 48766c6791096..2fcce0d9f5b0c 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -782,6 +782,7 @@ symbols! { impl_lint_pass, impl_macros, impl_trait_in_bindings, + import, import_shadowing, imported_main, in_band_lifetimes, @@ -1519,6 +1520,7 @@ symbols! { use_nested_groups, used, used_with_arg, + using, usize, v1, va_arg, From f688f4d1e4753ca0a83a1413a7b98fb8727c04a2 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:47:33 +0000 Subject: [PATCH 3/3] Reduce usage of Symbol in the linker code Interning here doesn't save us anything. It rather costs a bit of time. --- .../rustc_codegen_ssa/src/back/archive.rs | 3 +- .../rustc_codegen_ssa/src/back/command.rs | 6 -- compiler/rustc_codegen_ssa/src/back/link.rs | 9 +- compiler/rustc_codegen_ssa/src/back/linker.rs | 97 +++++++++---------- 4 files changed, 55 insertions(+), 60 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 553486ae8ec65..1cb8d34238129 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -1,13 +1,12 @@ use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_session::cstore::DllImport; use rustc_session::Session; -use rustc_span::symbol::Symbol; use std::io; use std::path::{Path, PathBuf}; pub(super) fn find_library( - name: Symbol, + name: &str, verbatim: bool, search_paths: &[PathBuf], sess: &Session, diff --git a/compiler/rustc_codegen_ssa/src/back/command.rs b/compiler/rustc_codegen_ssa/src/back/command.rs index 6c29692bd3bfe..9b0ba34135c11 100644 --- a/compiler/rustc_codegen_ssa/src/back/command.rs +++ b/compiler/rustc_codegen_ssa/src/back/command.rs @@ -7,7 +7,6 @@ use std::io; use std::mem; use std::process::{self, Output}; -use rustc_span::symbol::Symbol; use rustc_target::spec::LldFlavor; #[derive(Clone)] @@ -47,11 +46,6 @@ impl Command { self } - pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command { - self.arg(arg.as_str()); - self - } - pub fn args(&mut self, args: I) -> &mut Command where I: IntoIterator>, diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 72aa790c36357..697a27b9879c6 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -354,7 +354,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>( } if let Some(name) = lib.name { let location = - find_library(name, lib.verbatim.unwrap_or(false), &lib_search_paths, sess); + find_library(name.as_str(), lib.verbatim.unwrap_or(false), &lib_search_paths, sess); ab.add_archive(&location, |_| false).unwrap_or_else(|e| { sess.fatal(&format!( "failed to add native library {}: {}", @@ -1117,7 +1117,7 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) { let path = find_sanitizer_runtime(&sess, &filename); let rpath = path.to_str().expect("non-utf8 component in path"); linker.args(&["-Wl,-rpath", "-Xlinker", rpath]); - linker.link_dylib(Symbol::intern(&filename), false, true); + linker.link_dylib(&filename, false, true); } else { let filename = format!("librustc{}_rt.{}.a", channel, name); let path = find_sanitizer_runtime(&sess, &filename).join(&filename); @@ -2199,6 +2199,7 @@ fn add_local_native_libraries( let Some(name) = lib.name else { continue; }; + let name = name.as_str(); // Skip if this library is the same as the last. last = if (lib.name, lib.kind, lib.verbatim) == last { @@ -2362,6 +2363,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>( let Some(name) = lib.name else { continue; }; + let name = name.as_str(); if !relevant_lib(sess, lib) { continue; } @@ -2519,7 +2521,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>( } let filestem = cratepath.file_stem().unwrap().to_str().unwrap(); cmd.link_rust_dylib( - Symbol::intern(&unlib(&sess.target, filestem)), + &unlib(&sess.target, filestem), parent.unwrap_or_else(|| Path::new("")), ); } @@ -2551,6 +2553,7 @@ fn add_upstream_native_libraries( let Some(name) = lib.name else { continue; }; + let name = name.as_str(); if !relevant_lib(sess, &lib) { continue; } diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index b5b63942e2c6e..955ee245b28ae 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -16,7 +16,6 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, S use rustc_middle::ty::TyCtxt; use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; use rustc_session::Session; -use rustc_span::symbol::Symbol; use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor}; use cc::windows_registry; @@ -163,13 +162,13 @@ pub fn get_linker<'a>( pub trait Linker { fn cmd(&mut self) -> &mut Command; fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path); - fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool); - fn link_rust_dylib(&mut self, lib: Symbol, path: &Path); - fn link_framework(&mut self, framework: Symbol, as_needed: bool); - fn link_staticlib(&mut self, lib: Symbol, verbatim: bool); + fn link_dylib(&mut self, lib: &str, verbatim: bool, as_needed: bool); + fn link_rust_dylib(&mut self, lib: &str, path: &Path); + fn link_framework(&mut self, framework: &str, as_needed: bool); + fn link_staticlib(&mut self, lib: &str, verbatim: bool); fn link_rlib(&mut self, lib: &Path); fn link_whole_rlib(&mut self, lib: &Path); - fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, search_path: &[PathBuf]); + fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]); fn include_path(&mut self, path: &Path); fn framework_path(&mut self, path: &Path); fn output_filename(&mut self, path: &Path); @@ -423,8 +422,8 @@ impl<'a> Linker for GccLinker<'a> { } } - fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool) { - if self.sess.target.os == "illumos" && lib.as_str() == "c" { + fn link_dylib(&mut self, lib: &str, verbatim: bool, as_needed: bool) { + if self.sess.target.os == "illumos" && lib == "c" { // libc will be added via late_link_args on illumos so that it will // appear last in the library search order. // FIXME: This should be replaced by a more complete and generic @@ -454,7 +453,7 @@ impl<'a> Linker for GccLinker<'a> { } } } - fn link_staticlib(&mut self, lib: Symbol, verbatim: bool) { + fn link_staticlib(&mut self, lib: &str, verbatim: bool) { self.hint_static(); self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib)); } @@ -484,20 +483,20 @@ impl<'a> Linker for GccLinker<'a> { self.linker_arg("-znorelro"); } - fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) { + fn link_rust_dylib(&mut self, lib: &str, _path: &Path) { self.hint_dynamic(); self.cmd.arg(format!("-l{}", lib)); } - fn link_framework(&mut self, framework: Symbol, as_needed: bool) { + fn link_framework(&mut self, framework: &str, as_needed: bool) { self.hint_dynamic(); if !as_needed { // FIXME(81490): ld64 as of macOS 11 supports the -needed_framework // flag but we have no way to detect that here. - // self.cmd.arg("-needed_framework").sym_arg(framework); + // self.cmd.arg("-needed_framework").arg(framework); self.sess.warn("`as-needed` modifier not implemented yet for ld64"); } - self.cmd.arg("-framework").sym_arg(framework); + self.cmd.arg("-framework").arg(framework); } // Here we explicitly ask that the entire archive is included into the @@ -506,7 +505,7 @@ impl<'a> Linker for GccLinker<'a> { // don't otherwise explicitly reference them. This can occur for // libraries which are just providing bindings, libraries with generic // functions, etc. - fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, search_path: &[PathBuf]) { + fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]) { self.hint_static(); let target = &self.sess.target; if !target.is_like_osx { @@ -836,11 +835,11 @@ impl<'a> Linker for MsvcLinker<'a> { self.cmd.arg("/OPT:NOREF,NOICF"); } - fn link_dylib(&mut self, lib: Symbol, verbatim: bool, _as_needed: bool) { + fn link_dylib(&mut self, lib: &str, verbatim: bool, _as_needed: bool) { self.cmd.arg(format!("{}{}", lib, if verbatim { "" } else { ".lib" })); } - fn link_rust_dylib(&mut self, lib: Symbol, path: &Path) { + fn link_rust_dylib(&mut self, lib: &str, path: &Path) { // When producing a dll, the MSVC linker may not actually emit a // `foo.lib` file if the dll doesn't actually export any symbols, so we // check to see if the file is there and just omit linking to it if it's @@ -851,7 +850,7 @@ impl<'a> Linker for MsvcLinker<'a> { } } - fn link_staticlib(&mut self, lib: Symbol, verbatim: bool) { + fn link_staticlib(&mut self, lib: &str, verbatim: bool) { self.cmd.arg(format!("{}{}", lib, if verbatim { "" } else { ".lib" })); } @@ -890,11 +889,11 @@ impl<'a> Linker for MsvcLinker<'a> { fn framework_path(&mut self, _path: &Path) { bug!("frameworks are not supported on windows") } - fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) { + fn link_framework(&mut self, _framework: &str, _as_needed: bool) { bug!("frameworks are not supported on windows") } - fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) { + fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, _search_path: &[PathBuf]) { self.cmd.arg(format!("/WHOLEARCHIVE:{}{}", lib, if verbatim { "" } else { ".lib" })); } fn link_whole_rlib(&mut self, path: &Path) { @@ -1047,8 +1046,8 @@ impl<'a> Linker for EmLinker<'a> { self.cmd.arg("-L").arg(path); } - fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) { - self.cmd.arg("-l").sym_arg(lib); + fn link_staticlib(&mut self, lib: &str, _verbatim: bool) { + self.cmd.arg("-l").arg(lib); } fn output_filename(&mut self, path: &Path) { @@ -1059,12 +1058,12 @@ impl<'a> Linker for EmLinker<'a> { self.cmd.arg(path); } - fn link_dylib(&mut self, lib: Symbol, verbatim: bool, _as_needed: bool) { + fn link_dylib(&mut self, lib: &str, verbatim: bool, _as_needed: bool) { // Emscripten always links statically self.link_staticlib(lib, verbatim); } - fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) { + fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, _search_path: &[PathBuf]) { // not supported? self.link_staticlib(lib, verbatim); } @@ -1074,7 +1073,7 @@ impl<'a> Linker for EmLinker<'a> { self.link_rlib(lib); } - fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) { + fn link_rust_dylib(&mut self, lib: &str, _path: &Path) { self.link_dylib(lib, false, true); } @@ -1098,7 +1097,7 @@ impl<'a> Linker for EmLinker<'a> { bug!("frameworks are not supported on Emscripten") } - fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) { + fn link_framework(&mut self, _framework: &str, _as_needed: bool) { bug!("frameworks are not supported on Emscripten") } @@ -1237,12 +1236,12 @@ impl<'a> Linker for WasmLd<'a> { } } - fn link_dylib(&mut self, lib: Symbol, _verbatim: bool, _as_needed: bool) { - self.cmd.arg("-l").sym_arg(lib); + fn link_dylib(&mut self, lib: &str, _verbatim: bool, _as_needed: bool) { + self.cmd.arg("-l").arg(lib); } - fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) { - self.cmd.arg("-l").sym_arg(lib); + fn link_staticlib(&mut self, lib: &str, _verbatim: bool) { + self.cmd.arg("-l").arg(lib); } fn link_rlib(&mut self, lib: &Path) { @@ -1271,16 +1270,16 @@ impl<'a> Linker for WasmLd<'a> { fn no_relro(&mut self) {} - fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) { - self.cmd.arg("-l").sym_arg(lib); + fn link_rust_dylib(&mut self, lib: &str, _path: &Path) { + self.cmd.arg("-l").arg(lib); } - fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) { + fn link_framework(&mut self, _framework: &str, _as_needed: bool) { panic!("frameworks not supported") } - fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) { - self.cmd.arg("-l").sym_arg(lib); + fn link_whole_staticlib(&mut self, lib: &str, _verbatim: bool, _search_path: &[PathBuf]) { + self.cmd.arg("-l").arg(lib); } fn link_whole_rlib(&mut self, lib: &Path) { @@ -1360,10 +1359,10 @@ pub struct L4Bender<'a> { } impl<'a> Linker for L4Bender<'a> { - fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) { + fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) { bug!("dylibs are not supported on L4Re"); } - fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) { + fn link_staticlib(&mut self, lib: &str, _verbatim: bool) { self.hint_static(); self.cmd.arg(format!("-PC{}", lib)); } @@ -1404,15 +1403,15 @@ impl<'a> Linker for L4Bender<'a> { fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {} - fn link_rust_dylib(&mut self, _: Symbol, _: &Path) { + fn link_rust_dylib(&mut self, _: &str, _: &Path) { panic!("Rust dylibs not supported"); } - fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) { + fn link_framework(&mut self, _framework: &str, _as_needed: bool) { bug!("frameworks not supported on L4Re"); } - fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) { + fn link_whole_staticlib(&mut self, lib: &str, _verbatim: bool, _search_path: &[PathBuf]) { self.hint_static(); self.cmd.arg("--whole-archive").arg(format!("-l{}", lib)); self.cmd.arg("--no-whole-archive"); @@ -1617,19 +1616,19 @@ impl<'a> Linker for PtxLinker<'a> { self.cmd.arg("-o").arg(path); } - fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) { + fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) { panic!("external dylibs not supported") } - fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) { + fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) { panic!("external dylibs not supported") } - fn link_staticlib(&mut self, _lib: Symbol, _verbatim: bool) { + fn link_staticlib(&mut self, _lib: &str, _verbatim: bool) { panic!("staticlibs not supported") } - fn link_whole_staticlib(&mut self, _lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) { + fn link_whole_staticlib(&mut self, _lib: &str, _verbatim: bool, _search_path: &[PathBuf]) { panic!("staticlibs not supported") } @@ -1637,7 +1636,7 @@ impl<'a> Linker for PtxLinker<'a> { panic!("frameworks not supported") } - fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) { + fn link_framework(&mut self, _framework: &str, _as_needed: bool) { panic!("frameworks not supported") } @@ -1717,19 +1716,19 @@ impl<'a> Linker for BpfLinker<'a> { self.cmd.arg("-o").arg(path); } - fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) { + fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) { panic!("external dylibs not supported") } - fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) { + fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) { panic!("external dylibs not supported") } - fn link_staticlib(&mut self, _lib: Symbol, _verbatim: bool) { + fn link_staticlib(&mut self, _lib: &str, _verbatim: bool) { panic!("staticlibs not supported") } - fn link_whole_staticlib(&mut self, _lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) { + fn link_whole_staticlib(&mut self, _lib: &str, _verbatim: bool, _search_path: &[PathBuf]) { panic!("staticlibs not supported") } @@ -1737,7 +1736,7 @@ impl<'a> Linker for BpfLinker<'a> { panic!("frameworks not supported") } - fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) { + fn link_framework(&mut self, _framework: &str, _as_needed: bool) { panic!("frameworks not supported") }