build: fix symlink of drivers for Windows
PATCH 1/1 build: fix symlink of drivers for Windows
The symlink-drivers-solibs.sh script was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory.
Replace the shell script with a python script to perform the symbolic linking to improve cross platform support. On Linux the functionality is unchanged.
On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
--- buildtools/symlink-drivers-solibs.py | 49 ++++++++++++++++++++++++++++ buildtools/symlink-drivers-solibs.sh | 13 -------- config/meson.build | 7 ++-- 3 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 buildtools/symlink-drivers-solibs.py delete mode 100644 buildtools/symlink-drivers-solibs.sh
buildtools/symlink-drivers-solibs.py new file +49 -0
@@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +import os +import sys +import glob +import shutil + +# post-install script for meson/ninja builds to symlink the PMDs stored in +# $libdir/dpdk/pmds-*/ to $libdir. This is needed as some PMDs depend on +# others, e.g. PCI device PMDs depending on the PCI bus driver. + +# parameters to script are paths relative to install prefix: +# 1. directory for installed regular libs e.g. lib64 +# 2. subdirectory of libdir where the pmds are +# 3. directory for installed regular binaries e.g. bin + +os.chdir(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) + +lib_dir = sys.argv[1] +pmd_subdir = sys.argv[2] +bin_dir = sys.argv[3] +pmd_dir = os.path.join(lib_dir, pmd_subdir) + +# copy Windows PMDs to avoid any issues with symlinks since the +# build could be a cross-compilation under WSL, Msys or Cygnus. +# the filenames are dependent upon the specific toolchain in use. + +def copy_pmd_files(pattern, to_dir): + for file in glob.glob(os.path.join(pmd_dir, pattern)): + to = os.path.join(to_dir, os.path.basename(file)) + shutil.copy2(file, to) + print(to + ' -> ' + file) + +copy_pmd_files('*rte_*.dll', bin_dir) +copy_pmd_files('*rte_*.pdb', bin_dir) +copy_pmd_files('*rte_*.lib', lib_dir) +copy_pmd_files('*rte_*.dll.a', lib_dir) + +# symlink shared objects + +os.chdir(lib_dir) +for file in glob.glob(os.path.join(pmd_subdir, 'librte_*.so*')): + to = os.path.basename(file) + if os.path.exists(to): + os.remove(to) + os.symlink(file, to) + print(to + ' -> ' + file)
buildtools/symlink-drivers-solibs.sh deleted +0 -13
@@ -1,13 +0,0 @@ -#! /bin/sh -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation - -# post-install script for meson/ninja builds to symlink the PMDs stored in -# $libdir/dpdk/drivers/ to $libdir. This is needed as some PMDs depend on -# others, e.g. PCI device PMDs depending on the PCI bus driver. - -# parameters to script are paths relative to install prefix: -# 1. directory for installed regular libs e.g. lib64 -# 2. subdirectory of libdir where the pmds are - -cd ${MESON_INSTALL_DESTDIR_PREFIX}/$1 && ln -sfv $2/librte_*.so* .
config/meson.build +2 -5
@@ -57,11 +57,8 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) # driver .so files often depend upon the bus drivers for their connect bus, # e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need # to be in the library path, so symlink the drivers from the main lib directory. -if not is_windows - meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', - get_option('libdir'), - pmd_subdir_opt) -endif +meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) # set the machine type and cflags for it if meson.is_cross_build()
Signature · 1 line
2.25.1
2021-04-01 13:27 (UTC+0100), Nick Connolly:
[...]
buildtools/symlink-drivers-solibs.py line 37
Quoted 8 lines
buildtools/symlink-drivers-solibs.py new file +8
-0+def copy_pmd_files(pattern, to_dir): + for file in glob.glob(os.path.join(pmd_dir, pattern)): + to = os.path.join(to_dir, os.path.basename(file)) + shutil.copy2(file, to) + print(to + ' -> ' + file) + +copy_pmd_files('*rte_*.dll', bin_dir) +copy_pmd_files('*rte_*.pdb', bin_dir)
PDB (debuginfo) files can be quite large, do we want to install them?
[...]
Quoted 8 lines
config/meson.build +0
-0@@ -57,11 +57,8 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) # driver .so files often depend upon the bus drivers for their connect bus, # e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need # to be in the library path, so symlink the drivers from the main lib directory.
config/meson.build eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) · line 64
Quoted 10 lines
config/meson.build +2
-5-if not is_windows - meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', - get_option('libdir'), - pmd_subdir_opt) -endif +meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) # set the machine type and cflags for it if meson.is_cross_build()
As you may have seen, build fails because find_program() result cannot be used in meson.add_install_script() until 0.55. Since your script has Unix-specific part anyway and Windows recommends Meson 0.56, maybe Unices should continue using shell variant and Python script can be Windows-only.
Quoted 2 lines
PDB (debuginfo) files can be quite large, do we want to install them?
The script copies will only copy the .pdb files if they have already been installed into lib/dpdk/pmds-*/. If they haven't, we'll just skip the step.
Whether they should be installed is a different question :-) Installing them seems to be a deliberate choice by meson (https://github.com/mesonbuild/meson/issues/1442).
In my opinion, it's probably best to have them there.
I looked at options apart from copying (including hard links) but in the end decided to keep it as simple as possible so it will 'just work' for cross builds from Linux, WSL-1, WSL-2, Msys, Cygnus etc.
Quoted 9 lines
config/meson.build +2
-0+meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) # set the machine type and cflags for it if meson.is_cross_build()As you may have seen, build fails because
find_program()result cannot be used inmeson.add_install_script()until 0.55. Since your script has Unix-specific part anyway and Windows recommends Meson 0.56, maybe Unices should continue using shell variant and Python script can be Windows-only.
Yes, I 'd been thinking about the best way to handle this. Your suggestion of having both scripts may well be the best option in the short term.
Thanks,
Nick
PATCH v2 1/1 build: fix symlink of drivers for Windows
In reply to Nick ConnollyThe symlink-drivers-solibs.sh script was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory. Add a python script to perform the install and use it for Windows if the version of meson supports using an external program with add_install_script (>= 0.55.0).
On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
On Linux the functionality is unchanged, but could be replaced with the python script once the required minimum version of meson is >= 0.55.0.
--- buildtools/symlink-drivers-solibs.py | 49 ++++++++++++++++++++++++++++ config/meson.build | 4 +++ 2 files changed, 53 insertions(+) create mode 100644 buildtools/symlink-drivers-solibs.py
buildtools/symlink-drivers-solibs.py new file +49 -0
@@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +import os +import sys +import glob +import shutil + +# post-install script for meson/ninja builds to symlink the PMDs stored in +# $libdir/dpdk/pmds-*/ to $libdir. This is needed as some PMDs depend on +# others, e.g. PCI device PMDs depending on the PCI bus driver. + +# parameters to script are paths relative to install prefix: +# 1. directory for installed regular libs e.g. lib64 +# 2. subdirectory of libdir where the pmds are +# 3. directory for installed regular binaries e.g. bin + +os.chdir(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) + +lib_dir = sys.argv[1] +pmd_subdir = sys.argv[2] +bin_dir = sys.argv[3] +pmd_dir = os.path.join(lib_dir, pmd_subdir) + +# copy Windows PMDs to avoid any issues with symlinks since the +# build could be a cross-compilation under WSL, Msys or Cygnus. +# the filenames are dependent upon the specific toolchain in use. + +def copy_pmd_files(pattern, to_dir): + for file in glob.glob(os.path.join(pmd_dir, pattern)): + to = os.path.join(to_dir, os.path.basename(file)) + shutil.copy2(file, to) + print(to + ' -> ' + file) + +copy_pmd_files('*rte_*.dll', bin_dir) +copy_pmd_files('*rte_*.pdb', bin_dir) +copy_pmd_files('*rte_*.lib', lib_dir) +copy_pmd_files('*rte_*.dll.a', lib_dir) + +# symlink shared objects + +os.chdir(lib_dir) +for file in glob.glob(os.path.join(pmd_subdir, 'librte_*.so*')): + to = os.path.basename(file) + if os.path.exists(to): + os.remove(to) + os.symlink(file, to) + print(to + ' -> ' + file)
config/meson.build +4 -0
@@ -61,6 +61,10 @@ if not is_windows meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', get_option('libdir'), pmd_subdir_opt) +elif meson.version().version_compare('>=0.55.0') + # 0.55.0 is required to use external program with add_install_script + meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) endif # set the machine type and cflags for it
Signature · 1 line
2.25.1
buildtools/symlink-drivers-solibs.py
Quoted 32 lines · Nick Connolly
The
symlink-drivers-solibs.shscript was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory. Add a python script to perform the install and use it for Windows if the version of meson supports using an external program withadd_install_script(>= 0.55.0).On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
On Linux the functionality is unchanged, but could be replaced with the python script once the required minimum version of meson is >= 0.55.0.
Fixes 5c7d86948764 ("build: fix install on Windows")Signed-off-by Nick Connolly <[email protected]>--- buildtools/symlink-drivers-solibs.py | 49 ++++++++++++++++++++++++++++ config/meson.build | 4 +++ 2 files changed, 53 insertions(+) create mode 100644 buildtools/symlink-drivers-solibs.pybuildtools/symlink-drivers-solibs.py +0
-0
Note that it needs rebasing.
PATCH v3 1/1 build: fix symlink of drivers for Windows
In reply to Nick ConnollyThe symlink-drivers-solibs.sh script was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory. Add a python script to perform the install and use it for Windows if the version of meson supports using an external program with add_install_script (>= 0.55.0).
On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
On Linux the functionality is unchanged, but could be replaced with the python script once the required minimum version of meson is >= 0.55.0.
---
v3:
* rebase
v2:
* 0.55.0 is required to use external program with add_install_script
buildtools/symlink-drivers-solibs.py | 49 ++++++++++++++++++++++++++++ config/meson.build | 4 +++ 2 files changed, 53 insertions(+) create mode 100644 buildtools/symlink-drivers-solibs.py
buildtools/symlink-drivers-solibs.py new file +49 -0
@@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +import os +import sys +import glob +import shutil + +# post-install script for meson/ninja builds to symlink the PMDs stored in +# $libdir/dpdk/pmds-*/ to $libdir. This is needed as some PMDs depend on +# others, e.g. PCI device PMDs depending on the PCI bus driver. + +# parameters to script are paths relative to install prefix: +# 1. directory for installed regular libs e.g. lib64 +# 2. subdirectory of libdir where the pmds are +# 3. directory for installed regular binaries e.g. bin + +os.chdir(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) + +lib_dir = sys.argv[1] +pmd_subdir = sys.argv[2] +bin_dir = sys.argv[3] +pmd_dir = os.path.join(lib_dir, pmd_subdir) + +# copy Windows PMDs to avoid any issues with symlinks since the +# build could be a cross-compilation under WSL, Msys or Cygnus. +# the filenames are dependent upon the specific toolchain in use. + +def copy_pmd_files(pattern, to_dir): + for file in glob.glob(os.path.join(pmd_dir, pattern)): + to = os.path.join(to_dir, os.path.basename(file)) + shutil.copy2(file, to) + print(to + ' -> ' + file) + +copy_pmd_files('*rte_*.dll', bin_dir) +copy_pmd_files('*rte_*.pdb', bin_dir) +copy_pmd_files('*rte_*.lib', lib_dir) +copy_pmd_files('*rte_*.dll.a', lib_dir) + +# symlink shared objects + +os.chdir(lib_dir) +for file in glob.glob(os.path.join(pmd_subdir, 'librte_*.so*')): + to = os.path.basename(file) + if os.path.exists(to): + os.remove(to) + os.symlink(file, to) + print(to + ' -> ' + file)
config/meson.build +4 -0
@@ -59,6 +59,10 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) if not is_windows meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', get_option('libdir'), pmd_subdir_opt) +elif meson.version().version_compare('>=0.55.0') + # 0.55.0 is required to use external program with add_install_script + meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) endif # init disable/enable driver lists that will be populated in different places
Signature · 1 line
2.25.1
Hi Bruce,
Would you have some time to take a look at this? It's a replacement for the symlink-drivers-solibs.sh script for windows builds.
Thanks,
Nick
Quoted 109 lines · Nick Connolly
The
symlink-drivers-solibs.shscript was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory. Add a python script to perform the install and use it for Windows if the version of meson supports using an external program withadd_install_script(>= 0.55.0).On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
On Linux the functionality is unchanged, but could be replaced with the python script once the required minimum version of meson is >= 0.55.0.
Fixes 5c7d86948764 ("build: fix install on Windows")Signed-off-by Nick Connolly <[email protected]>Tested-by Narcisa Vasile <[email protected]>Acked-by Narcisa Vasile <[email protected]>---
v3:
* rebasev2:
* 0.55.0 is required to use external program withadd_install_scriptbuildtools/symlink-drivers-solibs.py | 49 ++++++++++++++++++++++++++++ config/meson.build | 4 +++ 2 files changed, 53 insertions(+)create mode 100644
buildtools/symlink-drivers-solibs.pybuildtools/symlink-drivers-solibs.py new file +49
-0@@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +import os +import sys +import glob +import shutil + +# post-install script for meson/ninja builds to symlink the PMDs stored in +# $libdir/dpdk/pmds-*/ to $libdir. This is needed as some PMDs depend on +# others, e.g. PCI device PMDs depending on the PCI bus driver. + +# parameters to script are paths relative to install prefix: +# 1. directory for installed regular libs e.g. lib64 +# 2. subdirectory of libdir where the pmds are +# 3. directory for installed regular binaries e.g. bin + +os.chdir(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) + +lib_dir = sys.argv[1] +pmd_subdir = sys.argv[2] +bin_dir = sys.argv[3] +pmd_dir = os.path.join(lib_dir, pmd_subdir) + +# copy Windows PMDs to avoid any issues with symlinks since the +# build could be a cross-compilation under WSL, Msys or Cygnus. +# the filenames are dependent upon the specific toolchain in use. + +def copy_pmd_files(pattern, to_dir): + for file in glob.glob(os.path.join(pmd_dir, pattern)): + to = os.path.join(to_dir, os.path.basename(file)) + shutil.copy2(file, to) + print(to + ' -> ' + file) + +copy_pmd_files('*rte_*.dll', bin_dir) +copy_pmd_files('*rte_*.pdb', bin_dir) +copy_pmd_files('*rte_*.lib', lib_dir) +copy_pmd_files('*rte_*.dll.a', lib_dir) + +# symlink shared objects + +os.chdir(lib_dir) +for file in glob.glob(os.path.join(pmd_subdir, 'librte_*.so*')): + to = os.path.basename(file) + if os.path.exists(to): + os.remove(to) + os.symlink(file, to) + print(to + ' -> ' + file)config/meson.build +4
-0@@ -59,6 +59,10 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) if not is_windows meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', get_option('libdir'), pmd_subdir_opt) +elif meson.version().version_compare('>=0.55.0') + # 0.55.0 is required to use external program with add_install_script + meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) endif # init disable/enable driver lists that will be populated in different places
Quoted 8 lines · Nick Connolly
Hi Bruce,
Would you have some time to take a look at this? It's a replacement for the
symlink-drivers-solibs.shscript for windows builds.Thanks,
Nick
I've reviewed it now and it looks good. Couldn't even find anything to nit-pick in it! :-)
Quoted 2 lines
I've reviewed it now and it looks good. Couldn't even find anything to nit-pick in it! :-)
Thanks Bruce - appreciated :-)
Nick
Quoted 21 lines · Nick Connolly
The
symlink-drivers-solibs.shscript was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory. Add a python script to perform the install and use it for Windows if the version of meson supports using an external program withadd_install_script(>= 0.55.0).On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
On Linux the functionality is unchanged, but could be replaced with the python script once the required minimum version of meson is >= 0.55.0.
Quoted 7 lines
Fixes 5c7d86948764 ("build: fix install on Windows")Signed-off-by Nick Connolly <[email protected]>Tested-by Narcisa Vasile <[email protected]>Acked-by Narcisa Vasile <[email protected]>---
Thomas Monjalon
Applied28/05/2021 10:19, Bruce Richardson:
Quoted 22 lines · Nick Connolly
Quoted 21 lines
The
symlink-drivers-solibs.shscript was disabled as part of 'install' for Windows because there is no support for shell scripts. However, this means that driver related DLLs are not present in the installed 'libdir' directory. Add a python script to perform the install and use it for Windows if the version of meson supports using an external program withadd_install_script(>= 0.55.0).On Windows, symbolic links are somewhat problematic since the SeCreateSymbolicLinkPrivilege is required to be able to create them. In addition, different cross-compilation environments handle symbolic links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to distinguish these scenarios, the python script will perform a file copy for any Windows specific names.
On Windows, the shared library outputs have different names depending upon which toolset has been used to build them. The script currently handles Clang and GCC.
On Linux the functionality is unchanged, but could be replaced with the python script once the required minimum version of meson is >= 0.55.0.
Quoted 8 lines
Quoted 7 lines
Fixes 5c7d86948764 ("build: fix install on Windows")Signed-off-by Nick Connolly <[email protected]>Tested-by Narcisa Vasile <[email protected]>Acked-by Narcisa Vasile <[email protected]>---
Reviewed-by Bruce Richardson <[email protected]>
Added the new file in MAINTAINERS.
Applied, thanks.