-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
both_libraries don't work with vala generated sources #6960
Comments
Doesn't work with the |
same problem with frida-core when i replace all build error
there exists a similar target in build.ninja: - build src/libfrida-helper-backend.so.p/meson-generated_frida-helper-backend.c.o
+ build src/libfrida-helper-backend.so.p/meson-generated_linux_frida-helper-backend.c.o a million detailsso patch versus frida/frida-core@310ff06 diff --git a/lib/base/meson.build b/lib/base/meson.build
index 2a3b3e3..5b6325b 100644
--- a/lib/base/meson.build
+++ b/lib/base/meson.build
@@ -15,13 +15,12 @@ if host_os_family != 'windows'
extra_deps += [gio_unix_dep]
endif
-base = static_library('frida-base-' + api_version, base_sources,
+base = library('frida-base-' + api_version, base_sources,
c_args: frida_component_cflags,
vala_header: 'frida-base.h',
vala_vapi: f'frida-base-@api_version@.vapi',
dependencies: [glib_dep, gobject_dep, gio_dep, libsoup_dep, nice_dep, usrsctp_dep, gee_dep, json_glib_dep, gum_dep, openssl_dep] + extra_deps,
install: true,
- install_dir: [true, header_install_dir, true],
)
base_dep = declare_dependency(
diff --git a/lib/payload/meson.build b/lib/payload/meson.build
index dff3f8d..8065a69 100644
--- a/lib/payload/meson.build
+++ b/lib/payload/meson.build
@@ -36,14 +36,13 @@ if host_os_family == 'linux'
extra_vala_args += ['--pkg=linux']
endif
-payload = static_library('frida-payload-' + api_version, payload_sources,
+payload = library('frida-payload-' + api_version, payload_sources,
c_args: frida_component_cflags,
vala_args: extra_vala_args,
vala_header: 'frida-payload.h',
vala_vapi: f'frida-payload-@api_version@.vapi',
dependencies: [gio_dep, gee_dep, json_glib_dep, gum_dep, gumjs_dep, base_dep],
install: true,
- install_dir: [true, header_install_dir, true],
)
payload_dep = declare_dependency(
diff --git a/lib/pipe/meson.build b/lib/pipe/meson.build
index e11e8d6..4354dfb 100644
--- a/lib/pipe/meson.build
+++ b/lib/pipe/meson.build
@@ -27,7 +27,7 @@ if host_os == 'android'
vala_args += frida_selinux_vala_args
endif
-pipe = static_library('frida-pipe', pipe_sources,
+pipe = library('frida-pipe', pipe_sources,
c_args: frida_component_cflags,
vala_args: vala_args,
vala_header: 'frida-pipe.h',
diff --git a/lib/selinux/meson.build b/lib/selinux/meson.build
index f317db5..42a5187 100644
--- a/lib/selinux/meson.build
+++ b/lib/selinux/meson.build
@@ -2,7 +2,7 @@ frida_selinux_incdir = include_directories('.')
install_headers('frida-selinux.h', subdir: 'frida-' + api_version)
-frida_selinux = static_library('frida-selinux', 'patch.c',
+frida_selinux = library('frida-selinux', 'patch.c',
c_args: frida_component_cflags,
dependencies: [glib_dep, libselinux_dep, libsepol_dep],
)
diff --git a/src/api/merge.sh b/src/api/merge.sh
deleted file mode 100755
index 5729f5a..0000000
--- a/src/api/merge.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-
-ar_binary="$1"
-libtool_binary="$2"
-build_dir="$3"
-output_lib="$4"
-shift 4
-
-if [ -n "$libtool_binary" ]; then
- exec "$libtool_binary" -static -o "$output_lib" "$@"
-else
- priv_dir="$build_dir/frida-core-library@mrg"
- mri_script="$priv_dir/merge.mri"
-
- mkdir -p "$priv_dir"
-
- echo "create $output_lib" > "$mri_script"
- while [[ $# > 0 ]]; do
- echo "addlib $1" >> "$mri_script"
- shift
- done
- echo "save" >> "$mri_script"
- echo "end" >> "$mri_script"
-
- exec "$ar_binary" -M < "$mri_script"
-fi
diff --git a/src/api/meson.build b/src/api/meson.build
index e268c71..42265e2 100644
--- a/src/api/meson.build
+++ b/src/api/meson.build
@@ -38,17 +38,7 @@ custom_target('frida-core-vapi',
install_dir: join_paths(get_option('datadir'), 'vala', 'vapi'),
)
-custom_target('frida-core-library',
- input: [core] + internal_libs,
- output: 'libfrida-core-@0@.a'.format(api_version),
- command: [
- files('merge.sh'),
- ar,
- libtool,
- meson.current_build_dir(),
- '@OUTPUT@',
- '@INPUT@'
- ],
+library('frida-core-' + api_version, [core] + internal_libs,
install: true,
install_dir: get_option('libdir'),
)
diff --git a/src/meson.build b/src/meson.build
index fe4ed80..84cc0c9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -85,7 +85,7 @@ if host_os_family == 'darwin'
'darwin/substituted2-client.c',
]
endif
- helper_backend = static_library('frida-helper-backend', helper_backend_sources,
+ helper_backend = library('frida-helper-backend', helper_backend_sources,
c_args: frida_component_cflags,
vala_args: ['--pkg=frida-gum-darwin-1.0', '--pkg=posix'],
dependencies: [gmodule_dep, gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep, pipe_dep],
@@ -216,7 +216,7 @@ if host_os_family == 'linux'
if host_os == 'android'
helper_backend_extra_deps += [frida_selinux_dep]
endif
- helper_backend = static_library('frida-helper-backend', helper_backend_sources,
+ helper_backend = library('frida-helper-backend', helper_backend_sources,
c_args: frida_component_cflags,
vala_args: ['--pkg=posix', '--pkg=frida-gum-linux-1.0'],
dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep] + helper_backend_extra_deps,
diff --git a/tests/meson.build b/tests/meson.build
index 987c857..0fe92e2 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -26,7 +26,7 @@ else
system_vala_args += ['--pkg=posix']
endif
-frida_tests = static_library('frida-tests', test_sources + [labrats_stamp],
+frida_tests = library('frida-tests', test_sources + [labrats_stamp],
vala_args: system_vala_args,
dependencies: [gmodule_dep, json_glib_dep, core_dep],
) helper_backend_sources = [
'linux/frida-helper-backend.vala',
'linux/frida-helper-backend-glue.c',
'linux/frida-helper-types.vala',
]
helper_backend_extra_deps = []
if host_os == 'android'
helper_backend_extra_deps += [frida_selinux_dep]
endif
# original with "static_library" -> build works
#helper_backend = static_library('frida-helper-backend', helper_backend_sources,
# patched with "library" -> build breaks
helper_backend = library('frida-helper-backend', helper_backend_sources,
c_args: frida_component_cflags,
vala_args: ['--pkg=posix', '--pkg=frida-gum-linux-1.0'],
dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep] + helper_backend_extra_deps,
) there exists a similar target in build.ninja: - build src/libfrida-helper-backend.so.p/meson-generated_frida-helper-backend.c.o
+ build src/libfrida-helper-backend.so.p/meson-generated_linux_frida-helper-backend.c.o so the problem is the prefix - meson-generated_ # wrong
+ meson-generated_linux_ # expected, because its more specific debug
def object_filename_from_source(self, target: build.BuildTarget, source: 'FileOrString') -> str:
assert isinstance(source, mesonlib.File)
if isinstance(target, build.CompileTarget):
return target.sources_map[source]
build_dir = self.environment.get_build_dir()
rel_src = source.rel_to_builddir(self.build_to_src)
# foo.vala files compile down to foo.c and then foo.c.o, not foo.vala.o
if rel_src.endswith(('.vala', '.gs')):
# See description in generate_vala_compile for this logic.
if source.is_built:
if os.path.isabs(rel_src):
rel_src = rel_src[len(build_dir) + 1:]
rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
else:
rel_src = os.path.basename(rel_src)
# A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
gen_source = 'meson-generated_' + rel_src[:-5] + '.c'
elif source.is_built:
if os.path.isabs(rel_src):
rel_src = rel_src[len(build_dir) + 1:]
targetdir = self.get_target_private_dir(target)
# A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
gen_source = 'meson-generated_' + os.path.relpath(rel_src, targetdir) --- /a/nix/store/1d96iljign9rczdgdrnyg2r9svfl16hj-meson-0.64.1/lib/python3.10/site-packages/mesonbuild/backend/backends.py 1970-01-01 01:00:01.000000000 +0100
+++ /b/nix/store/1d96iljign9rczdgdrnyg2r9svfl16hj-meson-0.64.1/lib/python3.10/site-packages/mesonbuild/backend/backends.py 2023-02-14 15:59:02.459275030 +0100
@@ -812,25 +812,63 @@
if isinstance(target, build.CompileTarget):
return target.sources_map[source]
build_dir = self.environment.get_build_dir()
+ print("mesonbuild/backend/backends.py: build_dir:", build_dir)
rel_src = source.rel_to_builddir(self.build_to_src)
+ print("mesonbuild/backend/backends.py: rel_src:", rel_src)
+
+ rel_src_1 = rel_src
# foo.vala files compile down to foo.c and then foo.c.o, not foo.vala.o
if rel_src.endswith(('.vala', '.gs')):
+ print("mesonbuild/backend/backends.py: rel_src.endswith(('.vala', '.gs'): yes")
# See description in generate_vala_compile for this logic.
if source.is_built:
+ print("mesonbuild/backend/backends.py: source.is_built: yes")
if os.path.isabs(rel_src):
+ print("mesonbuild/backend/backends.py: os.path.isabs(rel_src): yes")
+ print("mesonbuild/backend/backends.py: build_dir:", build_dir)
+ print("mesonbuild/backend/backends.py: rel_src 1:", rel_src)
rel_src = rel_src[len(build_dir) + 1:]
+ print("mesonbuild/backend/backends.py: rel_src 2:", rel_src)
+ else:
+ print("mesonbuild/backend/backends.py: os.path.isabs(rel_src): no")
+ print("mesonbuild/backend/backends.py: priv_dir: ", self.get_target_private_dir(target))
+ targetdir = self.get_target_private_dir(target)
+ print("mesonbuild/backend/backends.py: targetdir:", targetdir)
+ print("mesonbuild/backend/backends.py: rel_src 2:", rel_src)
rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
+ print("mesonbuild/backend/backends.py: rel_src 3:", rel_src)
else:
+ print("mesonbuild/backend/backends.py: source.is_built: no")
+ print("mesonbuild/backend/backends.py: rel_src 1:", rel_src)
rel_src = os.path.basename(rel_src)
+ print("mesonbuild/backend/backends.py: rel_src 4:", rel_src)
+ targetdir = self.get_target_private_dir(target)
+ print("mesonbuild/backend/backends.py: targetdir:", targetdir)
+ print("mesonbuild/backend/backends.py: rel_src 1:", rel_src_1)
+ print("mesonbuild/backend/backends.py: rel_src 4a", os.path.relpath(rel_src_1, targetdir))
+ print("mesonbuild/backend/backends.py: rel_src 5:", rel_src)
# A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
gen_source = 'meson-generated_' + rel_src[:-5] + '.c'
+ print("mesonbuild/backend/backends.py: gen_source:", gen_source)
elif source.is_built:
+ print("mesonbuild/backend/backends.py: rel_src.endswith(('.vala', '.gs'): no")
+ print("mesonbuild/backend/backends.py: source.is_built: yes")
if os.path.isabs(rel_src):
+ print("mesonbuild/backend/backends.py: os.path.isabs(rel_src): yes")
+ print("mesonbuild/backend/backends.py: build_dir:", build_dir)
+ print("mesonbuild/backend/backends.py: rel_src 1:", rel_src)
rel_src = rel_src[len(build_dir) + 1:]
+ print("mesonbuild/backend/backends.py: rel_src 6:", rel_src)
+ else:
+ print("mesonbuild/backend/backends.py: os.path.isabs(rel_src): no")
+ print("mesonbuild/backend/backends.py: rel_src 7:", rel_src)
targetdir = self.get_target_private_dir(target)
+ print("mesonbuild/backend/backends.py: targetdir:", targetdir)
+ print("mesonbuild/backend/backends.py: relpath(rel_src, targetdir):", os.path.relpath(rel_src, targetdir))
# A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
gen_source = 'meson-generated_' + os.path.relpath(rel_src, targetdir)
+ print("mesonbuild/backend/backends.py: gen_source:", gen_source)
else:
if os.path.isabs(rel_src):
# Use the absolute path directly to avoid file name conflicts c file →
vala file →
this is wrong if source.is_built:
if os.path.isabs(rel_src):
rel_src = rel_src[len(build_dir) + 1:]
rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
else:
# wrong
rel_src = os.path.basename(rel_src) fix:
- rel_src = os.path.basename(rel_src)
+ rel_src = source.fname next error, same problem
src/compiler/meson.build compiler_sources = files(
'compiler.vala',
) src/meson.build core_sources = base_sources + local_sources + remote_sources + compiler_sources
core = library('frida-core', core_sources, so the relative source path is actual vs expected target + build src/libfrida-core.so.p/meson-generated_compiler_compiler.c.o
- build src/libfrida-core.so.p/meson-generated_compiler.c.o good
bad
so instead, we need
mesonbuild/backend/backends.py def object_filename_from_source(self, target: build.BuildTarget, source: 'FileOrString') -> str:
# ...
# FIXME this is wrong
#rel_src = os.path.basename(rel_src)
# fix? no
#rel_src = source.fname
# fix!
# note: source.relative_name() =! rel_src
# source.relative_name() is relative to the source tree
# rel_src is relative to the build tree
# note: os.path.basename(targetdir) is a generated folder like libfrida-core.so.p
targetdir = self.get_target_private_dir(target)
rel_src = os.path.relpath(source.relative_name(), os.path.dirname(targetdir)) todo? also fix todo? also fix other backends (cmake?) AttributeError: 'SharedLibrary' object has no attribute 'split'different error, but also with vala passing a payload = shared_library('frida-payload-' + api_version, payload_sources,
# ...
)
agent_payload_modulated = custom_target('frida-agent-payload-modulated-' + api_version,
input: payload, mesonbuild/backend/ninjabackend.py def determine_dep_vapis(self, target):
"""
Peek into the sources of BuildTargets we're linking with, and if any of
them was built with Vala, assume that it also generated a .vapi file of
the same name as the BuildTarget and return the path to it relative to
the build directory.
"""
result = OrderedSet()
for dep in itertools.chain(target.link_targets, target.link_whole_targets):
if not dep.is_linkable_target():
continue
for i in dep.sources:
if hasattr(i, 'fname'):
i = i.fname
# FIXME AttributeError: 'SharedLibrary' object has no attribute 'split'
print("mesonbuild/backend/ninjabackend.py: i =", i)
#if i.split('.')[-1] in compilers.lang_suffixes['vala']:
# fix: cast i to string
if str(i).split('.')[-1] in compilers.lang_suffixes['vala']:
im giving up at this point, because |
Bug
When trying to build some vala based library with meson 0.53.x or 0.54, configuring with --default-libraries=both, I'm hitting numerous issues:
because object paths are generated differently for files generated by vala from sources in subdir.
How To Reproduce
My testcase is:
http://ftp.gnome.org/pub/GNOME/sources/libgnome-games-support/1.6/libgnome-games-support-1.6.1.tar.xz
Just cd into project directory, then:
For quick preview, library is defined as (in games/meson.build):
Expected behavior
Build succeeds with both libgnome-games-support.so.3.0.3 and libgnome-games-support.a built.
system parameters
Linux, Python 3.8.2
meson 0.54.0 (tried also last release of 0.53.x), ninja 1.10.0
The text was updated successfully, but these errors were encountered: