Build glob patterns for finding this allocator's shared libraries.
(&self)
| 4 | impl AllocatorKind { |
| 5 | /// Build glob patterns for finding this allocator's shared libraries. |
| 6 | fn search_patterns(&self) -> Vec<String> { |
| 7 | const LIB_DIRS: &[&str] = &[ |
| 8 | // Debian, Ubuntu: multiarch paths |
| 9 | "/lib/*-linux-gnu", |
| 10 | "/usr/lib/*-linux-gnu", |
| 11 | // RHEL, Fedora, CentOS, Arch |
| 12 | "/lib*", |
| 13 | "/usr/lib*", |
| 14 | // Local installs |
| 15 | "/usr/local/lib*", |
| 16 | ]; |
| 17 | |
| 18 | let (filenames, nix_hints): (&[&str], &[&str]) = match self { |
| 19 | AllocatorKind::Libc => (&["libc.so.6"], &["glibc"]), |
| 20 | AllocatorKind::LibCpp => (&["libstdc++.so*"], &["gcc"]), |
| 21 | AllocatorKind::Jemalloc => (&["libjemalloc.so*"], &["jemalloc"]), |
| 22 | AllocatorKind::Mimalloc => (&["libmimalloc.so*"], &["mimalloc"]), |
| 23 | AllocatorKind::Tcmalloc => (&["libtcmalloc*.so*"], &["tcmalloc", "gperftools"]), |
| 24 | }; |
| 25 | |
| 26 | let mut patterns = Vec::new(); |
| 27 | |
| 28 | for dir in LIB_DIRS { |
| 29 | for filename in filenames { |
| 30 | patterns.push(format!("{dir}/{filename}")); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | for hint in nix_hints { |
| 35 | for filename in filenames { |
| 36 | patterns.push(format!("/nix/store/*{hint}*/lib/{filename}")); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | patterns |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /// Find dynamically linked allocator libraries on the system. |