diff options
| author | Max Bernstein <tekknolagi@gmail.com> | 2025-08-26 13:57:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-26 20:57:14 +0000 |
| commit | d133ae9ca6861e979b2508b46b38da0afc579038 (patch) | |
| tree | 0837d51feaa39f1778b0d574d3d22419faee1118 | |
| parent | fb6e3a80009a744a4e0b75660f1ce6da65e20e6c (diff) | |
ZJIT: Canonicalize --zjit-log-compiled-iseqs filename (#14352)
This fixes issues related to the process changing directory and not
having only a relative path.
Thanks, Alan.
| -rw-r--r-- | zjit/src/options.rs | 5 | ||||
| -rw-r--r-- | zjit/src/state.rs | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/zjit/src/options.rs b/zjit/src/options.rs index 94a6988a4f..0c35aad0a4 100644 --- a/zjit/src/options.rs +++ b/zjit/src/options.rs @@ -59,7 +59,7 @@ pub struct Options { pub allowed_iseqs: Option<HashSet<String>>, /// Path to a file where compiled ISEQs will be saved. - pub log_compiled_iseqs: Option<String>, + pub log_compiled_iseqs: Option<std::path::PathBuf>, } impl Default for Options { @@ -242,7 +242,8 @@ fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { .open(opt_val) .map_err(|e| eprintln!("Failed to open file '{}': {}", opt_val, e)) .ok(); - options.log_compiled_iseqs = Some(opt_val.into()); + let opt_val = std::fs::canonicalize(opt_val).unwrap_or_else(|_| opt_val.into()); + options.log_compiled_iseqs = Some(opt_val); } _ => return None, // Option name not recognized diff --git a/zjit/src/state.rs b/zjit/src/state.rs index 194b02fc8d..948204a1e6 100644 --- a/zjit/src/state.rs +++ b/zjit/src/state.rs @@ -155,12 +155,12 @@ impl ZJITState { let mut file = match std::fs::OpenOptions::new().create(true).append(true).open(filename) { Ok(f) => f, Err(e) => { - eprintln!("ZJIT: Failed to create file '{}': {}", filename, e); + eprintln!("ZJIT: Failed to create file '{}': {}", filename.display(), e); return; } }; if let Err(e) = writeln!(file, "{}", iseq_name) { - eprintln!("ZJIT: Failed to write to file '{}': {}", filename, e); + eprintln!("ZJIT: Failed to write to file '{}': {}", filename.display(), e); } } |
