@@ -3138,23 +3138,26 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
31383138
31393139 // Work around windows `AccessDenied` if any files within this
31403140 // directory are open by closing and reopening the file handles.
3141+ // While this need is only documented on windows, there are some
3142+ // niche scenarios, such as WSL on ReFS, where it may be required
3143+ // on other platforms. As the workaround is low-cost, just
3144+ // use it on all platforms rather than trying to isolate every
3145+ // specific case where it's needed.
31413146 const need_writable_dance : enum { no , lf_only , lf_and_debug } = w : {
3142- if (builtin .os .tag == .windows ) {
3143- if (comp .bin_file ) | lf | {
3144- // We cannot just call `makeExecutable` as it makes a false
3145- // assumption that we have a file handle open only when linking
3146- // an executable file. This used to be true when our linkers
3147- // were incapable of emitting relocatables and static archive.
3148- // Now that they are capable, we need to unconditionally close
3149- // the file handle and re-open it in the follow up call to
3150- // `makeWritable`.
3151- if (lf .file ) | f | {
3152- f .close ();
3153- lf .file = null ;
3154-
3155- if (lf .closeDebugInfo ()) break :w .lf_and_debug ;
3156- break :w .lf_only ;
3157- }
3147+ if (comp .bin_file ) | lf | {
3148+ // We cannot just call `makeExecutable` as it makes a false
3149+ // assumption that we have a file handle open only when linking
3150+ // an executable file. This used to be true when our linkers
3151+ // were incapable of emitting relocatables and static archive.
3152+ // Now that they are capable, we need to unconditionally close
3153+ // the file handle and re-open it in the follow up call to
3154+ // `makeWritable`.
3155+ if (lf .file ) | f | {
3156+ f .close ();
3157+ lf .file = null ;
3158+
3159+ if (lf .closeDebugInfo ()) break :w .lf_and_debug ;
3160+ break :w .lf_only ;
31583161 }
31593162 }
31603163 break :w .no ;
@@ -3188,7 +3191,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
31883191 .root_dir = comp .dirs .local_cache ,
31893192 .sub_path = try fs .path .join (arena , &.{ o_sub_path , comp .emit_bin .? }),
31903193 };
3191- const result : (link .File .OpenError || error {HotSwapUnavailableOnHostOperatingSystem })! void = switch (need_writable_dance ) {
3194+ const result : (link .File .OpenError || error {HotSwapUnavailableOnHostOperatingSystem , RenameAcrossMountPoints , InvalidFileName })! void = switch (need_writable_dance ) {
31923195 .no = > {},
31933196 .lf_only = > lf .makeWritable (),
31943197 .lf_and_debug = > res : {
0 commit comments