Skip to content

Commit

Permalink
Clean up cfgs for crate includes.
Browse files Browse the repository at this point in the history
The existing dependency cfgs are a mess. Rework them based on a few principles.

1. Windows targets use PDBs if compiled with MSVC, or DWARF if compiled with the GNU toolchain. Gate addr2line and object, which is only used with addr2line, on not(msvc).
2. Windows targets never use ELF. Gate miniz_oxide and zstd, which are used for ELF compression, on not(windows).
3. libc is used by the addr2line code, Fuschia specific code (which implies DWARF), and libunwind specific code (which implies DWARF), so gate it on not(msvc) as well.
4. The Windows UWP target only allows a reduced set of APIs. That set of APIs excludes some used by addr2line, so additionally gate all the DWARF related crates on not(uwp).
  • Loading branch information
khuey committed May 25, 2024
1 parent 78167bb commit eda500c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ cpp_demangle = { default-features = false, version = "0.4.0", optional = true, f
"alloc",
] }

[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies]
miniz_oxide = { version = "0.7.0", default-features = false }
# MSVC uses PDB, not DWARF. But UWP doesn't allow for APIs gimli (via addr2line) uses,
# so skip that too.
[target.'cfg(not(any(target_env = "msvc", target_vendor = "uwp")))'.dependencies]
addr2line = { version = "0.22.0", default-features = false }
libc = { version = "0.2.146", default-features = false }

[target.'cfg(not(any(all(windows, target_env = "msvc", not(target_vendor = "uwp")), target_os = "illumos")))'.dependencies]
# Windows uses PE, not ELF, so libraries for ELF compression are unnecessary.
[target.'cfg(not(windows))'.dependencies]
miniz_oxide = { version = "0.7.0", default-features = false }

# Also used for ELF compression, but doesn't build on illumos in CI.
[target.'cfg(not(any(windows, target_os = "illumos")))'.dependencies]
zstd = { version = "= 0.13.0", default-features = false }

[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies.object]
[target.'cfg(not(any(target_env = "msvc", target_vendor = "uwp")))'.dependencies.object]
version = "0.35.0"
default-features = false
features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive']
Expand Down
10 changes: 6 additions & 4 deletions crates/as-if-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ bench = false
[dependencies]
cfg-if = "1.0"
rustc-demangle = "0.1.21"

[target.'cfg(not(any(target_env = "msvc", target_vendor = "uwp")))'.dependencies]
libc = { version = "0.2.146", default-features = false }
addr2line = { version = "0.22.0", optional = true, default-features = false }

[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies]
[target.'cfg(not(windows))'.dependencies]
miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
addr2line = { version = "0.22.0", optional = true, default-features = false }

[target.'cfg(not(any(all(windows, target_env = "msvc", not(target_vendor = "uwp")), target_os = "illumos")))'.dependencies]
[target.'cfg(not(any(windows, target_os = "illumos")))'.dependencies]
zstd = { version = "= 0.13.0", optional = true, default-features = false }

[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies.object]
[target.'cfg(not(any(target_env = "msvc", target_vendor = "uwp")))'.dependencies.object]
version = "0.35.0"
default-features = false
optional = true
Expand Down

0 comments on commit eda500c

Please sign in to comment.