Skip to content

Commit 4b68882

Browse files
committed
fix(flow): use portable cp + touch -r for cached netlist copy
cp --preserve=timestamps is GNU-only and fails on macOS/BSD cp. Plain cp followed by touch -r keeps the nanosecond mtime on Linux (verified identical to --preserve=timestamps) and works on all supported platforms. Signed-off-by: Joao Luis Sombrio <sombrio@sombrasoft.dev>
1 parent ead9a54 commit 4b68882

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎flow/scripts/synth_preamble.tcl‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@ erase_non_stage_variables synth
77
# preserve timestamps flag set. If you don't, subsequent runs will cause the
88
# floorplan step to be re-executed.
99
#
10-
# --preserve=timestamps rather than -p: -p also preserves mode, which makes
10+
# Plain cp + touch -r rather than cp -p: -p also preserves mode, which makes
1111
# cp copy ACLs. That fails with EOPNOTSUPP when the source is on an NFSv4
1212
# mount (every file there carries a system.nfs4_acl xattr) and the
1313
# destination filesystem, e.g. ext4 or tmpfs, cannot store it. Only the
14-
# timestamps matter for make's up-to-date checks.
14+
# timestamps matter for make's up-to-date checks; touch -r preserves them
15+
# with nanosecond precision and, unlike cp --preserve=timestamps, is
16+
# portable to macOS/BSD.
1517
if { [env_var_exists_and_non_empty SYNTH_NETLIST_FILES] } {
1618
if { [llength $::env(SYNTH_NETLIST_FILES)] == 1 } {
17-
log_cmd exec cp --preserve=timestamps $::env(SYNTH_NETLIST_FILES) \
19+
log_cmd exec cp $::env(SYNTH_NETLIST_FILES) $::env(RESULTS_DIR)/1_2_yosys.v
20+
log_cmd exec touch -r $::env(SYNTH_NETLIST_FILES) \
1821
$::env(RESULTS_DIR)/1_2_yosys.v
1922
} else {
2023
# The date should be the most recent date of the files, but to
2124
# keep things simple we just use the creation date
2225
log_cmd exec cat {*}$::env(SYNTH_NETLIST_FILES) > $::env(RESULTS_DIR)/1_2_yosys.v
2326
}
2427
if { [env_var_exists_and_non_empty CACHED_REPORTS] } {
25-
log_cmd exec cp --preserve=timestamps {*}$::env(CACHED_REPORTS) \
26-
$::env(REPORTS_DIR)/.
28+
foreach report $::env(CACHED_REPORTS) {
29+
set dst $::env(REPORTS_DIR)/[file tail $report]
30+
log_cmd exec cp $report $dst
31+
log_cmd exec touch -r $report $dst
32+
}
2733
}
2834
exit
2935
}

0 commit comments

Comments
 (0)