meson: Fixes the ninjatool issue that E$$: are generated in Makefile.ninja
PATCH v5 1/6 meson: Fixes the ninjatool issue that E$$: are generated in Makefile.ninja
From: Yonggang Luo <[email protected]>
SIMPLE_PATH_RE should match the full path token.
Or the $ and : contained in path would not matched if the path are start with C:/ and E:/
--- scripts/ninjatool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/ninjatool.py +1 -1
@@ -55,7 +55,7 @@ else: PATH_RE = r"[^$\s:|]+|\$[$ :]|\$[a-zA-Z0-9_-]+|\$\{[a-zA-Z0-9_.-]+\}" -SIMPLE_PATH_RE = re.compile(r"[^$\s:|]+") +SIMPLE_PATH_RE = re.compile(r"^[^$\s:|]+$") IDENT_RE = re.compile(r"[a-zA-Z0-9_.-]+$") STRING_RE = re.compile(r"(" + PATH_RE + r"|[\s:|])(?:\r?\n)?|.") TOPLEVEL_RE = re.compile(r"([=:#]|\|\|?|^ +|(?:" + PATH_RE + r")+)\s*|.")
Signature · 1 line
2.27.0.windows.1
PATCH v5 2/6 meson: fixes relpath may fail on win32.
From: Yonggang Luo <[email protected]>
On win32, os.path.relpath would raise exception when do the following relpath:
C:/msys64/mingw64/x.exe relative to E:/path/qemu-build would fail. So we try catch it for stopping it from raise exception on msys2
--- scripts/mtest2make.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
scripts/mtest2make.py +9 -2
@@ -53,9 +53,16 @@ i = 0 for test in json.load(sys.stdin): env = ' '.join(('%s=%s' % (shlex.quote(k), shlex.quote(v)) for k, v in test['env'].items())) - executable = os.path.relpath(test['cmd'][0]) + executable = test['cmd'][0] + try: + executable = os.path.relpath(executable) + except: + pass if test['workdir'] is not None: - test['cmd'][0] = os.path.relpath(test['cmd'][0], test['workdir']) + try: + test['cmd'][0] = os.path.relpath(executable, test['workdir']) + except: + test['cmd'][0] = executable else: test['cmd'][0] = executable cmd = '$(.test.env) %s %s' % (env, ' '.join((shlex.quote(x) for x in test['cmd'])))
Signature · 1 line
2.27.0.windows.1
PATCH v5 3/6 meson: Mingw64 gcc doesn't recognize system include_type for sdl2
In reply to [email protected]From: Yonggang Luo <[email protected]>
Fixes this for msys2/mingw64 by remove the include_type for sdl2 discovery in meson
--- meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
meson.build +1 -2
@@ -224,8 +224,7 @@ if 'CONFIG_BRLAPI' in config_host brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split()) endif -sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static, - include_type: 'system') +sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static) sdl_image = not_found if sdl.found() # work around 2.0.8 bug
Signature · 1 line
2.27.0.windows.1
PATCH v5 4/6 configure: Fix include and linkage issue on msys2
In reply to [email protected]From: Yonggang Luo <[email protected]>
On msys2, the -I/e/path/to/qemu -L/e/path/to/qemu are not recognized by the compiler Cause $PWD are result posix style path such as /e/path/to/qemu that can not be recognized by mingw gcc, and pwd -W are result Windows style path such as E:/path/to/qemu that can be recognized by the mingw gcc. So we replace all $PWD with $build_path that can building qemu under msys2/mingw environment.
--- configure | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
configure +19 -9
@@ -13,8 +13,13 @@ export CCACHE_RECACHE=yes # make source path absolute source_path=$(cd "$(dirname -- "$0")"; pwd) +build_path=$PWD +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then +source_path=$(cd "$(dirname -- "$0")"; pwd -W) +build_path=`pwd -W` +fi -if test "$PWD" = "$source_path" +if test "$build_path" = "$source_path" then echo "Using './build' as the directory for build output"
@@ -346,7 +351,12 @@ ld_has() { $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 } -if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; +check_valid_build_path="[[:space:]:]" +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then +check_valid_build_path="[[:space:]]" +fi + +if printf %s\\n "$source_path" "$build_path" | grep -q "$check_valid_build_path"; then error_exit "main directory cannot contain spaces nor colons" fi
@@ -942,7 +952,7 @@ Linux) linux="yes" linux_user="yes" kvm="yes" - QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES" + QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I${build_path}/linux-headers $QEMU_INCLUDES" libudev="yes" ;; esac
@@ -4283,7 +4293,7 @@ EOF symlink "$source_path/dtc/Makefile" "dtc/Makefile" fi fdt_cflags="-I${source_path}/dtc/libfdt" - fdt_ldflags="-L$PWD/dtc/libfdt" + fdt_ldflags="-L${build_path}/dtc/libfdt" fdt_libs="$fdt_libs" elif test "$fdt" = "yes" ; then # Not a git build & no libfdt found, prompt for system install
@@ -5268,7 +5278,7 @@ case "$capstone" in else LIBCAPSTONE=libcapstone.a fi - capstone_libs="-L$PWD/capstone -lcapstone" + capstone_libs="-L${build_path}/capstone -lcapstone" capstone_cflags="-I${source_path}/capstone/include" ;;
@@ -6268,8 +6278,8 @@ case "$slirp" in git_submodules="${git_submodules} slirp" fi mkdir -p slirp - slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src" - slirp_libs="-L$PWD/slirp -lslirp" + slirp_cflags="-I${source_path}/slirp/src -I${build_path}/slirp/src" + slirp_libs="-L${build_path}/slirp -lslirp" if test "$mingw32" = "yes" ; then slirp_libs="$slirp_libs -lws2_32 -liphlpapi" fi
@@ -8212,7 +8222,7 @@ fi mv $cross config-meson.cross rm -rf meson-private meson-info meson-logs -NINJA=$PWD/ninjatool $meson setup \ +NINJA="${build_path}/ninjatool" $meson setup \ --prefix "${pre_prefix}$prefix" \ --libdir "${pre_prefix}$libdir" \ --libexecdir "${pre_prefix}$libexecdir" \
@@ -8232,7 +8242,7 @@ NINJA=$PWD/ninjatool $meson setup \ -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \ -Dgettext=$gettext -Dxkbcommon=$xkbcommon \ $cross_arg \ - "$PWD" "$source_path" + "$build_path" "$source_path" if test "$?" -ne 0 ; then error_exit "meson setup failed"
Signature · 1 line
2.27.0.windows.1
Re: [PATCH v5 4/6] configure: Fix include and linkage issue on msys2
I'm a bit wary of this patch, the effects are quite wide-ranging. If we move all the detection of dependencies to meson, it will take a while but we should get a similar effect.
However, I'm testing and queuing patches 1 to 3.
Paolo
Quoted 106 lines · On Wed, Aug 26, 2020 at 5:13 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
On msys2, the -I/e/path/to/qemu -L/e/path/to/qemu are not recognized by the compiler Cause $PWD are result posix style path such as /e/path/to/qemu that can not be recognized by mingw gcc, and
pwd -Ware result Windows style path such as E:/path/to/qemu that can be recognized by the mingw gcc. So we replace all $PWD with $build_path that can building qemu under msys2/mingw environment.Signed-off-by Yonggang Luo <[email protected]>--- configure | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)configure +19
-10@@ -13,8 +13,13 @@ export CCACHE_RECACHE=yes # make source path absolute source_path=$(cd "$(dirname -- "$0")"; pwd) +build_path=$PWD +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then +source_path=$(cd "$(dirname -- "$0")"; pwd -W) +build_path=`pwd -W` +fi -if test "$PWD" = "$source_path" +if test "$build_path" = "$source_path" then echo "Using './build' as the directory for build output"@@ -346,7 +351,12 @@ ld_has() { $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 } -if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; +check_valid_build_path="[[:space:]:]" +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then +check_valid_build_path="[[:space:]]" +fi + +if printf %s\\n "$source_path" "$build_path" | grep -q "$check_valid_build_path"; then error_exit "main directory cannot contain spaces nor colons" fi@@ -942,7 +952,7 @@ Linux) linux="yes" linux_user="yes" kvm="yes" - QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES" + QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I${build_path}/linux-headers $QEMU_INCLUDES" libudev="yes" ;; esac@@ -4283,7 +4293,7 @@ EOF symlink "$source_path/dtc/Makefile" "dtc/Makefile" fi fdt_cflags="-I${source_path}/dtc/libfdt" - fdt_ldflags="-L$PWD/dtc/libfdt" + fdt_ldflags="-L${build_path}/dtc/libfdt" fdt_libs="$fdt_libs" elif test "$fdt" = "yes" ; then # Not a git build & no libfdt found, prompt for system install@@ -5268,7 +5278,7 @@ case "$capstone" in else LIBCAPSTONE=libcapstone.a fi - capstone_libs="-L$PWD/capstone -lcapstone" + capstone_libs="-L${build_path}/capstone -lcapstone" capstone_cflags="-I${source_path}/capstone/include" ;;@@ -6268,8 +6278,8 @@ case "$slirp" in git_submodules="${git_submodules} slirp" fi mkdir -p slirp - slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src" - slirp_libs="-L$PWD/slirp -lslirp" + slirp_cflags="-I${source_path}/slirp/src -I${build_path}/slirp/src" + slirp_libs="-L${build_path}/slirp -lslirp" if test "$mingw32" = "yes" ; then slirp_libs="$slirp_libs -lws2_32 -liphlpapi" fi@@ -8212,7 +8222,7 @@ fi mv $cross config-meson.cross rm -rf meson-private meson-info meson-logs -NINJA=$PWD/ninjatool $meson setup \ +NINJA="${build_path}/ninjatool" $meson setup \ --prefix "${pre_prefix}$prefix" \ --libdir "${pre_prefix}$libdir" \ --libexecdir "${pre_prefix}$libexecdir" \@@ -8232,7 +8242,7 @@ NINJA=$PWD/ninjatool $meson setup \ -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \ -Dgettext=$gettext -Dxkbcommon=$xkbcommon \ $cross_arg \ - "$PWD" "$source_path" + "$build_path" "$source_path" if test "$?" -ne 0 ; then error_exit "meson setup failed" --2.27.0.windows.1
Re: [PATCH v5 4/6] configure: Fix include and linkage issue on msys2
Quoted 4 lines · Paolo Bonzini
I'm a bit wary of this patch, the effects are quite wide-ranging. If we move all the detection of dependencies to meson, it will take a while but we should get a similar effect.
Only on MINGW the $PWD sematic are changed, so I don't think there is side effect of this patch.
Quoted 122 lines
However, I'm testing and queuing patches 1 to 3.
Paolo
Quoted 4 lines · On Wed, Aug 26, 2020 at 5:13 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
On msys2, the -I/e/path/to/qemu -L/e/path/to/qemu are not recognized by
the compiler
Quoted 1 line
Cause $PWD are result posix style path such as /e/path/to/qemu that can
not be recognized
Quoted 1 line
by mingw gcc, and
pwd -Ware result Windows style path such asE:/path/to/qemu that can
Quoted 1 line
be recognized by the mingw gcc. So we replace all $PWD with $build_path
that can
Quoted 27 lines
building qemu under msys2/mingw environment.
Signed-off-by Yonggang Luo <[email protected]>--- configure | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)configure +6
-1@@ -13,8 +13,13 @@ export CCACHE_RECACHE=yes # make source path absolute source_path=$(cd "$(dirname -- "$0")"; pwd) +build_path=$PWD +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then +source_path=$(cd "$(dirname -- "$0")"; pwd -W) +build_path=`pwd -W` +fi -if test "$PWD" = "$source_path" +if test "$build_path" = "$source_path" then echo "Using './build' as the directory for build output"configure ld_has() { · line 359
Quoted 10 lines
configure +6
-1@@ -346,7 +351,12 @@ ld_has() { $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 } -if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; +check_valid_build_path="[[:space:]:]" +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then +check_valid_build_path="[[:space:]]" +fi + +if printf %s\\n "$source_path" "$build_path" | grep -q"$check_valid_build_path";
configure Linux) · line 945
Quoted 8 lines
configure +0
-1then error_exit "main directory cannot contain spaces nor colons" fi@@ -942,7 +952,7 @@ Linux) linux="yes" linux_user="yes" kvm="yes" - QEMU_INCLUDES="-isystem ${source_path}/linux-headers-I$PWD/linux-headers $QEMU_INCLUDES"
configure Linux) · line 955
Quoted 1 line
configure +1
-0+ QEMU_INCLUDES="-isystem ${source_path}/linux-headers-I${build_path}/linux-headers $QEMU_INCLUDES"
Quoted 42 lines
configure +5
-5libudev="yes" ;; esac@@ -4283,7 +4293,7 @@ EOF symlink "$source_path/dtc/Makefile" "dtc/Makefile" fi fdt_cflags="-I${source_path}/dtc/libfdt" - fdt_ldflags="-L$PWD/dtc/libfdt" + fdt_ldflags="-L${build_path}/dtc/libfdt" fdt_libs="$fdt_libs" elif test "$fdt" = "yes" ; then # Not a git build & no libfdt found, prompt for system install@@ -5268,7 +5278,7 @@ case "$capstone" in else LIBCAPSTONE=libcapstone.a fi - capstone_libs="-L$PWD/capstone -lcapstone" + capstone_libs="-L${build_path}/capstone -lcapstone" capstone_cflags="-I${source_path}/capstone/include" ;;@@ -6268,8 +6278,8 @@ case "$slirp" in git_submodules="${git_submodules} slirp" fi mkdir -p slirp - slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src" - slirp_libs="-L$PWD/slirp -lslirp" + slirp_cflags="-I${source_path}/slirp/src -I${build_path}/slirp/src" + slirp_libs="-L${build_path}/slirp -lslirp" if test "$mingw32" = "yes" ; then slirp_libs="$slirp_libs -lws2_32 -liphlpapi" fi@@ -8212,7 +8222,7 @@ fi mv $cross config-meson.cross rm -rf meson-private meson-info meson-logs -NINJA=$PWD/ninjatool $meson setup \ +NINJA="${build_path}/ninjatool" $meson setup \ --prefix "${pre_prefix}$prefix" \ --libdir "${pre_prefix}$libdir" \ --libexecdir "${pre_prefix}$libexecdir" \configure NINJA=$PWD/ninjatool $meson setup \ · line 8242
Quoted 1 line
configure +0
-0@@ -8232,7 +8242,7 @@ NINJA=$PWD/ninjatool $meson setup \ -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg-Dvnc_png=$vnc_png \
Quoted 10 lines
configure +1
-2-Dgettext=$gettext -Dxkbcommon=$xkbcommon \ $cross_arg \ - "$PWD" "$source_path" + "$build_path" "$source_path" if test "$?" -ne 0 ; then error_exit "meson setup failed" --2.27.0.windows.1
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoRe: [PATCH v5 4/6] configure: Fix include and linkage issue on msys2
Quoted 8 lines · 罗勇刚(Yonggang Luo)
Quoted 3 lines · Paolo Bonzini
I'm a bit wary of this patch, the effects are quite wide-ranging. If we move all the detection of dependencies to meson, it will take a while but we should get a similar effect.
Only on MINGW the $PWD sematic are changed, so I don't think there is side effect of this patch.
Yes the side effect is only on MINGW but the affected variables are used everywhere so it's a rather hard to review change.
Paolo
Re: [PATCH v5 4/6] configure: Fix include and linkage issue on msys2
Quoted 10 lines · Paolo Bonzini
Quoted 3 lines · 罗勇刚(Yonggang Luo)
On Wed, Aug 26, 2020 at 11:24 PM Paolo Bonzini <[email protected]>
Quoted 4 lines · wrote:
Quoted 3 lines
I'm a bit wary of this patch, the effects are quite wide-ranging. If we move all the detection of dependencies to meson, it will take a while but we should get a similar effect.
Quoted 6 lines
Quoted 1 line
Only on MINGW the $PWD sematic are changed, so I don't think there is
side effect of this patch.
Yes the side effect is only on MINGW but the affected variables are used everywhere so it's a rather hard to review change.
Gotcha, review it carefully
Quoted 4 lines
Paolo
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoRe: [PATCH v5 4/6] configure: Fix include and linkage issue on msys2
In reply to [email protected]Quoted 18 lines · On 26/08/2020 16:10, [email protected] wrote:
From: Yonggang Luo <[email protected]>
On msys2, the -I/e/path/to/qemu -L/e/path/to/qemu are not recognized by the compiler Cause $PWD are result posix style path such as /e/path/to/qemu that can not be recognized by mingw gcc, and
pwd -Ware result Windows style path such as E:/path/to/qemu that can be recognized by the mingw gcc. So we replace all $PWD with $build_path that can building qemu under msys2/mingw environment.Signed-off-by Yonggang Luo <[email protected]>--- configure | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)configure +0
-0
configure export CCACHE_RECACHE=yes · line 17
Quoted 5 lines
configure +2
-0@@ -13,8 +13,13 @@ export CCACHE_RECACHE=yes # make source path absolute source_path=$(cd "$(dirname -- "$0")"; pwd) +build_path=$PWD +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then
This still doesn't match the existing indentation as per my previous comment.
Quoted 10 lines
configure +4
-1+source_path=$(cd "$(dirname -- "$0")"; pwd -W) +build_path=`pwd -W` +fi -if test "$PWD" = "$source_path" +if test "$build_path" = "$source_path" then echo "Using './build' as the directory for build output"
configure ld_has() { · line 355
Quoted 6 lines
configure +2
-1@@ -346,7 +351,12 @@ ld_has() { $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 } -if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; +check_valid_build_path="[[:space:]:]" +if [ "$MSYSTEM" = "MINGW64" -o "$MSYSTEM" = "MINGW32" ]; then
Same again here too.
Quoted 55 lines
configure +10
-6+check_valid_build_path="[[:space:]]" +fi + +if printf %s\\n "$source_path" "$build_path" | grep -q "$check_valid_build_path"; then error_exit "main directory cannot contain spaces nor colons" fi@@ -942,7 +952,7 @@ Linux) linux="yes" linux_user="yes" kvm="yes" - QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES" + QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I${build_path}/linux-headers $QEMU_INCLUDES" libudev="yes" ;; esac@@ -4283,7 +4293,7 @@ EOF symlink "$source_path/dtc/Makefile" "dtc/Makefile" fi fdt_cflags="-I${source_path}/dtc/libfdt" - fdt_ldflags="-L$PWD/dtc/libfdt" + fdt_ldflags="-L${build_path}/dtc/libfdt" fdt_libs="$fdt_libs" elif test "$fdt" = "yes" ; then # Not a git build & no libfdt found, prompt for system install@@ -5268,7 +5278,7 @@ case "$capstone" in else LIBCAPSTONE=libcapstone.a fi - capstone_libs="-L$PWD/capstone -lcapstone" + capstone_libs="-L${build_path}/capstone -lcapstone" capstone_cflags="-I${source_path}/capstone/include" ;;@@ -6268,8 +6278,8 @@ case "$slirp" in git_submodules="${git_submodules} slirp" fi mkdir -p slirp - slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src" - slirp_libs="-L$PWD/slirp -lslirp" + slirp_cflags="-I${source_path}/slirp/src -I${build_path}/slirp/src" + slirp_libs="-L${build_path}/slirp -lslirp" if test "$mingw32" = "yes" ; then slirp_libs="$slirp_libs -lws2_32 -liphlpapi" fi@@ -8212,7 +8222,7 @@ fi mv $cross config-meson.cross rm -rf meson-private meson-info meson-logs -NINJA=$PWD/ninjatool $meson setup \ +NINJA="${build_path}/ninjatool" $meson setup \ --prefix "${pre_prefix}$prefix" \ --libdir "${pre_prefix}$libdir" \ --libexecdir "${pre_prefix}$libexecdir" \
configure NINJA=$PWD/ninjatool $meson setup \ · line 8248
Quoted 8 lines
configure +1
-1@@ -8232,7 +8242,7 @@ NINJA=$PWD/ninjatool $meson setup \ -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \ -Dgettext=$gettext -Dxkbcommon=$xkbcommon \ $cross_arg \ - "$PWD" "$source_path" + "$build_path" "$source_path" if test "$?" -ne 0 ; then error_exit "meson setup failed"
Is the change to this last section for the NINJA variable really required to fix linking? It would be useful to keep the NINJA variable and executable detection fix as a separate patch if possible.
ATB,
Mark.
PATCH v5 5/6 meson: Fixes ninjatool can not be recognized as script under Window/MSYS2
In reply to [email protected]From: Yonggang Luo <[email protected]>
use ninja instead ${build_path}/ninjatool
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -8222,7 +8222,7 @@ fi mv $cross config-meson.cross rm -rf meson-private meson-info meson-logs -NINJA="${build_path}/ninjatool" $meson setup \ +NINJA="ninja" $meson setup \ --prefix "${pre_prefix}$prefix" \ --libdir "${pre_prefix}$libdir" \ --libexecdir "${pre_prefix}$libexecdir" \
Signature · 1 line
2.27.0.windows.1
PATCH v5 6/6 meson: Convert undefsym.sh to undefsym.py
In reply to [email protected]From: Yonggang Luo <[email protected]>
undefsym.sh are not msys2 compatible, convert it to python script
--- meson.build | 2 +- scripts/undefsym.py | 56 +++++++++++++++++++++++++++++++++++++++++++++ scripts/undefsym.sh | 20 ---------------- 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 scripts/undefsym.py delete mode 100755 scripts/undefsym.sh
meson.build +1 -1
@@ -845,7 +845,7 @@ foreach d, list : modules endforeach nm = find_program('nm') -undefsym = find_program('scripts/undefsym.sh') +undefsym = find_program('scripts/undefsym.py') block_syms = custom_target('block.syms', output: 'block.syms', input: [libqemuutil, block_mods], capture: true,
scripts/undefsym.py new file +56 -0
56 lines not on this page · raw message
scripts/undefsym.sh deleted +0 -20
@@ -1,20 +0,0 @@ -#! /usr/bin/env bash - -# Before a shared module's DSO is produced, a static library is built for it -# and passed to this script. The script generates -Wl,-u options to force -# the inclusion of symbol from libqemuutil.a if the shared modules need them, -# This is necessary because the modules may use functions not needed by the -# executable itself, which would cause the function to not be linked in. -# Then the DSO loading would fail because of the missing symbol. - -if test $# -le 2; then - exit 0 -fi - -NM=$1 -staticlib=$2 -shift 2 -# Find symbols defined in static libraries and undefined in shared modules -comm -12 \ - <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \ - <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u)
Signature · 1 line
2.27.0.windows.1
Re: [PATCH v5 6/6] meson: Convert undefsym.sh to undefsym.py
Careful, the original script:
-comm -12 \
- <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \
- <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u)
looks for lines that *are* U in the modules. So using filter_lines_set is correct for static libraries but wrong for modules.
Paolo
Quoted 118 lines · On Wed, Aug 26, 2020 at 5:13 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
undefsym.share not msys2 compatible, convert it to python scriptSigned-off-by Yonggang Luo <[email protected]>--- meson.build | 2 +- scripts/undefsym.py | 56 +++++++++++++++++++++++++++++++++++++++++++++ scripts/undefsym.sh | 20 ---------------- 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 scripts/undefsym.py delete mode 100755 scripts/undefsym.shmeson.build +1
-1@@ -845,7 +845,7 @@ foreach d, list : modules endforeach nm = find_program('nm') -undefsym = find_program('scripts/undefsym.sh') +undefsym = find_program('scripts/undefsym.py') block_syms = custom_target('block.syms', output: 'block.syms', input: [libqemuutil, block_mods], capture: true,scripts/undefsym.py new file +56
-0@@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Before a shared module's DSO is produced, a static library is built for it +# and passed to this script. The script generates -Wl,-u options to force +# the inclusion of symbol from libqemuutil.a if the shared modules need them, +# This is necessary because the modules may use functions not needed by the +# executable itself, which would cause the function to not be linked in. +# Then the DSO loading would fail because of the missing symbol. + + +""" +Compare the static library for compute the symbol duplication +""" + +import sys +import subprocess + +def filter_lines_set(stdout): + linesSet = set() + for line in stdout.splitlines(): + tokens = line.split(b' ') + if len(tokens) >= 1: + if len(tokens) > 1 and tokens[1] == b'U': + continue + new_line = b'-Wl,-u,' + tokens[0] + if not new_line in linesSet: + linesSet.add(new_line) + return linesSet + +def main(args): + global _SCRIPT + print(" ".join(args), file=sys.stderr) + if len(args) <= 3: + sys.exit(0) + + nm = args[1] + staticlib = args[2] + pc = subprocess.run([nm, "-P", "-g", staticlib], stdout=subprocess.PIPE) + if pc.returncode != 0: + sys.exit(-1) + lines_set_left = filter_lines_set(pc.stdout) + + shared_modules = args[3:] + pc = subprocess.run([nm, "-P", "-g"] + shared_modules, stdout=subprocess.PIPE) + if pc.returncode != 0: + sys.exit(-1) + lines_set_right = filter_lines_set(pc.stdout) + lines = [] + for line in sorted(list(lines_set_right)): + if line in lines_set_left: + lines.append(line) + sys.stdout.write(b'\n'.join(lines).decode()) + +if __name__ == "__main__": + main(sys.argv)scripts/undefsym.sh deleted +0
-21@@ -1,20 +0,0 @@ -#! /usr/bin/env bash - -# Before a shared module's DSO is produced, a static library is built for it -# and passed to this script. The script generates -Wl,-u options to force -# the inclusion of symbol from libqemuutil.a if the shared modules need them, -# This is necessary because the modules may use functions not needed by the -# executable itself, which would cause the function to not be linked in. -# Then the DSO loading would fail because of the missing symbol. - -if test $# -le 2; then - exit 0 -fi - -NM=$1 -staticlib=$2 -shift 2 -# Find symbols defined in static libraries and undefined in shared modules -comm -12 \ - <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \ - <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u) --2.27.0.windows.1
Re: [PATCH v5 6/6] meson: Convert undefsym.sh to undefsym.py
Gotcha, I am confusing about submitting a patch, This is my script to submit patch, but didn't got the things work.
https://wiki.qemu.org/Contribute/SubmitAPatch#Base_patches_against_current_git_master
Are very long, but I still didn't got the way how to submit patches properly....
Windows bat for submit patch:
``` rd /s /q v2 git format-patch --subject-prefix="PATCH v5" HEAD~6 -o v2/ git send-email [email protected] ^ "--cc=Paolo Bonzini ^<[email protected]^>,Daniel P. Berrangé ^< [email protected]^>" v2 :: git send-email --annotate [email protected] --cc=QEMU Developers <[email protected]> Paolo Bonzini <[email protected]> v2 pause ```
Quoted 144 lines · Paolo Bonzini
Careful, the original script:
scripts/undefsym.sh deleted +0
-3-comm -12 \ - <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \ - <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u)looks for lines that *are* U in the modules. So using
filter_lines_setis correct for static libraries but wrong for modules.Paolo
Quoted 33 lines · On Wed, Aug 26, 2020 at 5:13 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
undefsym.share not msys2 compatible, convert it to python scriptSigned-off-by Yonggang Luo <[email protected]>--- meson.build | 2 +- scripts/undefsym.py | 56 +++++++++++++++++++++++++++++++++++++++++++++ scripts/undefsym.sh | 20 ---------------- 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 scripts/undefsym.py delete mode 100755 scripts/undefsym.shmeson.build +1
-1@@ -845,7 +845,7 @@ foreach d, list : modules endforeach nm = find_program('nm') -undefsym = find_program('scripts/undefsym.sh') +undefsym = find_program('scripts/undefsym.py') block_syms = custom_target('block.syms', output: 'block.syms', input: [libqemuutil, block_mods], capture: true,scripts/undefsym.py new file +0
-0scripts/undefsym.py line 4
Quoted 4 lines
scripts/undefsym.py new file +4
-0@@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Before a shared module's DSO is produced, a static library is builtfor it
scripts/undefsym.py line 5
Quoted 1 line
scripts/undefsym.py new file +1
-0+# and passed to this script. The script generates -Wl,-u options toforce
scripts/undefsym.py line 6
Quoted 1 line
scripts/undefsym.py new file +1
-0+# the inclusion of symbol from libqemuutil.a if the shared modules needthem,
scripts/undefsym.py line 7
Quoted 1 line
scripts/undefsym.py new file +1
-0+# This is necessary because the modules may use functions not needed bythe
Quoted 22 lines
scripts/undefsym.py new file +22
-0+# executable itself, which would cause the function to not be linked in. +# Then the DSO loading would fail because of the missing symbol. + + +""" +Compare the static library for compute the symbol duplication +""" + +import sys +import subprocess + +def filter_lines_set(stdout): + linesSet = set() + for line in stdout.splitlines(): + tokens = line.split(b' ') + if len(tokens) >= 1: + if len(tokens) > 1 and tokens[1] == b'U': + continue + new_line = b'-Wl,-u,' + tokens[0] + if not new_line in linesSet: + linesSet.add(new_line) + return linesSetscripts/undefsym.py
Quoted 10 lines
scripts/undefsym.py new file +10
-0+ +def main(args): + global _SCRIPT + print(" ".join(args), file=sys.stderr) + if len(args) <= 3: + sys.exit(0) + + nm = args[1] + staticlib = args[2] + pc = subprocess.run([nm, "-P", "-g", staticlib],stdout=subprocess.PIPE)
scripts/undefsym.py
Quoted 6 lines
scripts/undefsym.py new file +6
-0+ if pc.returncode != 0: + sys.exit(-1) + lines_set_left = filter_lines_set(pc.stdout) + + shared_modules = args[3:] + pc = subprocess.run([nm, "-P", "-g"] + shared_modules,stdout=subprocess.PIPE)
Quoted 17 lines
scripts/undefsym.py new file +11
-0+ if pc.returncode != 0: + sys.exit(-1) + lines_set_right = filter_lines_set(pc.stdout) + lines = [] + for line in sorted(list(lines_set_right)): + if line in lines_set_left: + lines.append(line) + sys.stdout.write(b'\n'.join(lines).decode()) + +if __name__ == "__main__": + main(sys.argv)scripts/undefsym.sh deleted +0
-0scripts/undefsym.sh line 3
Quoted 3 lines
scripts/undefsym.sh deleted +0
-3@@ -1,20 +0,0 @@ -#! /usr/bin/env bash - -# Before a shared module's DSO is produced, a static library is builtfor it
scripts/undefsym.sh line 4
Quoted 1 line
scripts/undefsym.sh deleted +0
-1-# and passed to this script. The script generates -Wl,-u options toforce
scripts/undefsym.sh line 5
Quoted 1 line
scripts/undefsym.sh deleted +0
-1-# the inclusion of symbol from libqemuutil.a if the shared modules needthem,
scripts/undefsym.sh line 6
Quoted 1 line
scripts/undefsym.sh deleted +0
-1-# This is necessary because the modules may use functions not needed bythe
scripts/undefsym.sh
Quoted 11 lines
scripts/undefsym.sh deleted +0
-11-# executable itself, which would cause the function to not be linked in. -# Then the DSO loading would fail because of the missing symbol. - -if test $# -le 2; then - exit 0 -fi - -NM=$1 -staticlib=$2 -shift 2 -# Find symbols defined in static libraries and undefined in sharedmodules
scripts/undefsym.sh line 19
Quoted 2 lines
scripts/undefsym.sh deleted +0
-2-comm -12 \ - <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort-u) \
Quoted 4 lines
scripts/undefsym.sh deleted +0
-2- <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u) --2.27.0.windows.1
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoQuoted 5 lines · On Wed, Aug 26, 2020 at 5:12 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
SIMPLE_PATH_REshould match the full path token.
Or the $ and : contained in path would not matched if the path are start with C:/ and E:/
I don't understand this, SIMPLE_PATH_RE is used with re.match which only matches at the beginning of the string. Can you send me your build.ninja file offlist?
Thanks,
Paolo
I can tell you build.ninja can contains $: symbol, that's the escape for Ninja,
when ninjatool parse it, it will convert $: -> :, so that's not a problem. This is part of the build.ninja on my computer
``` build version.rc_version.o: CUSTOM_COMMAND_DEP ../qemu.org/version.rc | C$:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE ../ qemu.org/pc-bios/qemu-nsis.ico DEPFILE = "version.rc_version.o.d" DEPFILE_UNQUOTED = version.rc_version.o.d COMMAND = "C:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE" "-I./." "-I../qemu.org/." "../qemu.org/version.rc" "version.rc_version.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQversion.rc_version.o" "--preprocessor-arg=-MFversion.rc_version.o.d" description = Generating$ Windows$ resource$ for$ file$ 'version.rc'$ with$ a$ custom$ command ```
Quoted 17 lines · Paolo Bonzini
Quoted 5 lines · On Wed, Aug 26, 2020 at 5:12 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
SIMPLE_PATH_REshould match the full path token.
Or the $ and : contained in path would not matched if the path are startwith C:/ and E:/
I don't understand this,
SIMPLE_PATH_REis used with re.match which only matches at the beginning of the string. Can you send me your build.ninja file offlist?Thanks,
Paolo
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoQuoted 4 lines · 罗勇刚(Yonggang Luo)
I can tell you build.ninja can contains $: symbol, that's the escape for Ninja, when ninjatool parse it, it will convert $: -> :, so that's not a problem. This is part of the build.ninja on my computer
Ok, that's useful. But can you just send the whole file (it's huge but you can gzip it or something similar)?
Paolo
Quoted 34 lines
``` build version.rc_version.o: CUSTOM_COMMAND_DEP ../qemu.org/version.rc | C$:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE ../qemu.org/pc-bios/qemu-nsis.ico DEPFILE = "version.rc_version.o.d" DEPFILE_UNQUOTED = version.rc_version.o.d COMMAND = "C:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE" "-I./." "-I../qemu.org/." "../qemu.org/version.rc" "version.rc_version.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQversion.rc_version.o" "--preprocessor-arg=-MFversion.rc_version.o.d" description = Generating$ Windows$ resource$ for$ file$ 'version.rc'$ with$ a$ custom$ command ```Quoted 8 lines · Paolo Bonzini
Quoted 5 lines · On Wed, Aug 26, 2020 at 5:12 PM <[email protected]> wrote:
From: Yonggang Luo <[email protected]>
SIMPLE_PATH_REshould match the full path token.
Or the $ and : contained in path would not matched if the path are start with C:/ and E:/Quoted 8 lines
I don't understand this,
SIMPLE_PATH_REis used with re.match which only matches at the beginning of the string. Can you send me your build.ninja file offlist?Thanks,
Paolo
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
Quoted 5 lines · Paolo Bonzini
Quoted 2 lines · 罗勇刚(Yonggang Luo)
I can tell you build.ninja can contains $: symbol, that's the escape for
Ninja,
Quoted 9 lines
Quoted 1 line
when ninjatool parse it, it will convert $: -> :, so that's not a
problem.
Quoted 1 line
This is part of the build.ninja on my computer
Ok, that's useful. But can you just send the whole file (it's huge but you can gzip it or something similar)?
Paolo
I am OK with that, but where should I post
Quoted 46 lines
Quoted 3 lines
```
build version.rc_version.o:CUSTOM_COMMAND_DEP../qemu.org/version.rc |C$:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE ../ qemu.org/pc-bios/qemu-nsis.ico
Quoted 3 lines
DEPFILE = "version.rc_version.o.d"
DEPFILE_UNQUOTED= version.rc_version.o.d
COMMAND ="C:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE" "-I./." "-I../qemu.org/." "../qemu.org/version.rc" "version.rc_version.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQversion.rc_version.o" "--preprocessor-arg=-MFversion.rc_version.o.d"
Quoted 1 line
description = Generating$ Windows$ resource$ for$ file$ 'version.rc'$
with$ a$ custom$ command
Quoted 3 lines
```
On Wed, Aug 26, 2020 at 11:28 PM Paolo Bonzini <[email protected]>
Quoted 7 lines · wrote:
Quoted 7 lines · On Wed, Aug 26, 2020 at 5:12 PM <[email protected]> wrote:
Quoted 5 lines
From: Yonggang Luo <[email protected]>
SIMPLE_PATH_REshould match the full path token.
Or the $ and : contained in path would not matched if the path arestart with C:/ and E:/
Quoted 18 lines
Quoted 9 lines
I don't understand this,
SIMPLE_PATH_REis used with re.match which only matches at the beginning of the string. Can you send me your build.ninja file offlist?Thanks,
Paolo
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoQuoted 6 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines
Ok, that's useful. But can you just send the whole file (it's huge but you can gzip it or something similar)?
Paolo
I am OK with that, but where should I post
Just [email protected].
Regarding the version.rc_version.o target in build.ninja, I see it translated to
version.rc_version.o: private .var.command := "C:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE" "-I./." "-I../qemu.org/." "../qemu.org/version.rc" "version.rc_version.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQversion.rc_version.o" "--preprocessor-arg=-MFversion.rc_version.o.d" version.rc_version.o: private .var.description := Generating Windows resource for file 'version.rc' with a custom command version.rc_version.o: private .var.out := version.rc_version.o
Is this wrong?
Paolo
Quoted 26 lines · Paolo Bonzini
Quoted 6 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines
Ok, that's useful. But can you just send the whole file (it's huge but you can gzip it or something similar)?
Paolo
I am OK with that, but where should I post
Just [email protected].
Regarding the version.rc_version.o target in build.ninja, I see it translated to
version.rc_version.o: private .var.command := "C:/CI-Tools/msys64/mingw64/bin/x86_64-w64-mingw32-windres.EXE" "-I./." "-I../qemu.org/." "../qemu.org/version.rc" "version.rc_version.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQversion.rc_version.o" "--preprocessor-arg=-MFversion.rc_version.o.d" version.rc_version.o: private .var.description := Generating Windows resource for file 'version.rc' with a custom command version.rc_version.o: private .var.out := version.rc_version.o
Quoted 2 lines
Is this wrong?
This is fine
Quoted 6 lines
Paolo
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoHow about enabling github actions to enable MSYS2 builds in CI. So we won't break msys2 silently.
Yes that would be great. We are tracking all CI "holes" that we didn't catch before committing the Meson transition, and MSYS is certainly one of them.
You can send a patch and it will be reviewed and included.
Thanks,
Paolo
Quoted 3 lines · 罗勇刚(Yonggang Luo)
How about enabling github actions to enable MSYS2 builds in CI. So we won't break msys2 silently.
Quoted 8 lines · Paolo Bonzini
Yes that would be great. We are tracking all CI "holes" that we didn't catch before committing the Meson transition, and MSYS is certainly one of them.
You can send a patch and it will be reviewed and included.
Thanks,
After these patches merged, I'll do that
Quoted 10 lines
Paolo
Quoted 3 lines · 罗勇刚(Yonggang Luo)
How about enabling github actions to enable MSYS2 builds in CI. So we won't break msys2 silently.
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang LuoStill very big, I zip it for you. seems meson are not generating build.ninja in a stable very
Quoted 34 lines · 罗勇刚(Yonggang Luo)
Quoted 8 lines · Paolo Bonzini
Yes that would be great. We are tracking all CI "holes" that we didn't catch before committing the Meson transition, and MSYS is certainly one of them.
You can send a patch and it will be reviewed and included.
Thanks,
After these patches merged, I'll do that
Quoted 10 lines
Paolo
Quoted 3 lines · 罗勇刚(Yonggang Luo)
How about enabling github actions to enable MSYS2 builds in CI. So we won't break msys2 silently.
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
Signature · 6 lines
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo