[v3,1/1] buildtools: avoid break due to failure to cleanup temporary directory

Message ID 1746627671-28659-2-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series avoid break due to failure to cleanup temporary directory |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing pending Testing pending
ci/iol-unit-arm64-testing success Testing PASS
ci/aws-unit-testing success Unit Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Andre Muezerie May 7, 2025, 2:21 p.m. UTC
When compiling drivers on Windows, instances have been seen where a
temporary directory fails to get cleaned up due to
ERROR_SHARING_VIOLATION (32).

This issue was not seen on operating systems other than Windows.

This patch eliminates the use of tempfile.TemporaryDirectory, which
was triggering the issue.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 buildtools/gen-pmdinfo-cfile.py | 26 +++++++++++++-------------
 buildtools/meson.build          |  2 +-
 drivers/meson.build             |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)
  

Comments

Dmitry Kozlyuk May 7, 2025, 3:32 p.m. UTC | #1
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
  
David Marchand May 16, 2025, 9:34 a.m. UTC | #2
Hello Andre,

On Wed, May 7, 2025 at 4:21 PM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
>
> When compiling drivers on Windows, instances have been seen where a
> temporary directory fails to get cleaned up due to
> ERROR_SHARING_VIOLATION (32).
>
> This issue was not seen on operating systems other than Windows.
>
> This patch eliminates the use of tempfile.TemporaryDirectory, which
> was triggering the issue.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

How does this change interact (except a merge conflict) with the other
series that adds pmdinfo for MSVC?
https://patchwork.dpdk.org/project/dpdk/list/?series=35065&state=%2A&archive=both
  
Andre Muezerie May 16, 2025, 1:14 p.m. UTC | #3
On Fri, May 16, 2025 at 11:34:10AM +0200, David Marchand wrote:
> Hello Andre,
> 
> On Wed, May 7, 2025 at 4:21 PM Andre Muezerie
> <andremue@linux.microsoft.com> wrote:
> >
> > When compiling drivers on Windows, instances have been seen where a
> > temporary directory fails to get cleaned up due to
> > ERROR_SHARING_VIOLATION (32).
> >
> > This issue was not seen on operating systems other than Windows.
> >
> > This patch eliminates the use of tempfile.TemporaryDirectory, which
> > was triggering the issue.
> >
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> 
> How does this change interact (except a merge conflict) with the other
> series that adds pmdinfo for MSVC?
> https://patchwork.dpdk.org/project/dpdk/list/?series=35065&state=%2A&archive=both
> 

I suggest applying this patch as early as possible. I can rebase the other patch
which will merge conflict with it after if needed.

On my dev machine I'm building the drivers folder, and that doesn't succeed without
this patch. I want to enable that on the official branch as well, but can't until
this patch is merged.

> 
> -- 
> David Marchand
  

Patch

diff --git a/buildtools/gen-pmdinfo-cfile.py b/buildtools/gen-pmdinfo-cfile.py
index 5fbd51658a..8ffc192c40 100644
--- a/buildtools/gen-pmdinfo-cfile.py
+++ b/buildtools/gen-pmdinfo-cfile.py
@@ -5,17 +5,17 @@ 
 import os
 import subprocess
 import sys
-import tempfile
 
-_, tmp_root, ar, archive, output, *pmdinfogen = sys.argv
-with tempfile.TemporaryDirectory(dir=tmp_root) as temp:
-    paths = []
-    for name in subprocess.run([ar, "t", archive], stdout=subprocess.PIPE,
-                               check=True).stdout.decode().splitlines():
-        if os.path.exists(name):
-            paths.append(name)
-        else:
-            subprocess.run([ar, "x", os.path.abspath(archive), name],
-                           check=True, cwd=temp)
-            paths.append(os.path.join(temp, name))
-    subprocess.run(pmdinfogen + paths + [output], check=True)
+_, ar, tmp_dir, archive, output, *pmdinfogen = sys.argv
+paths = []
+for name in subprocess.run([ar, "t", archive], stdout=subprocess.PIPE,
+                            check=True).stdout.decode().splitlines():
+    if os.path.exists(name):
+        paths.append(name)
+    else:
+        if not os.path.exists(tmp_dir):
+            os.makedirs(tmp_dir)
+        subprocess.run([ar, "x", os.path.abspath(archive), name],
+                        check=True, cwd=tmp_dir)
+        paths.append(os.path.join(tmp_dir, name))
+subprocess.run(pmdinfogen + paths + [output], check=True)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 1cd1ce02fd..e7c53c9a84 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -34,7 +34,7 @@  install_data([
         install_dir: 'bin')
 
 # select library and object file format
-pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
+pmdinfo = py3 + files('gen-pmdinfo-cfile.py')
 pmdinfogen = py3 + files('pmdinfogen.py')
 if host_machine.system() == 'windows'
     if cc.get_id() == 'gcc'
diff --git a/drivers/meson.build b/drivers/meson.build
index caee1e3b79..8aad099c40 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -274,7 +274,7 @@  foreach subpath:subdirs
                 c_args: cflags)
         objs += tmp_lib.extract_all_objects(recursive: true)
         sources_pmd_info = custom_target(out_filename,
-                command: [pmdinfo, tmp_lib.full_path(), '@OUTPUT@', pmdinfogen],
+                command: [pmdinfo, '@PRIVATE_DIR@', tmp_lib.full_path(), '@OUTPUT@', pmdinfogen],
                 output: out_filename,
                 depends: [tmp_lib])