diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2019-05-25 19:01:44 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-05-28 20:25:37 +0300 |
commit | 20eb948b974a96b3933d42db524fd584cb60c8b7 (patch) | |
tree | cb2f852c349b661b827e803a661d45e74a40368a /test cases | |
parent | 949187868196edc4fa3ba21b033f8a08a2b391d6 (diff) | |
download | meson-20eb948b974a96b3933d42db524fd584cb60c8b7.zip meson-20eb948b974a96b3933d42db524fd584cb60c8b7.tar.gz meson-20eb948b974a96b3933d42db524fd584cb60c8b7.tar.bz2 |
gnome: make sure the target build directory is passed first for linking
determine_rpath_dirs() can return paths to external dependencies not
in the build dir and passing them first as a link path leads to
g-ir-scanner for example linking against the already installed library
instead of the just built one.
This was reported in g-i: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/272
and comes up quite often when a library adds some new symbols which aren't present in the
system library, which then makes linking fail.
The first place where the order is changed is _scan_gir_targets(), which looks like an unintentional
change in the refactoring in 8377ea45aa61efbe8e1a75b74
The second place in _get_link_args() has always been that way and only the rpath order is changed,
but it looks to me as if the same rules should apply here too.
Diffstat (limited to 'test cases')
4 files changed, 99 insertions, 0 deletions
diff --git a/test cases/frameworks/28 gir link order 2/meson-sample.c b/test cases/frameworks/28 gir link order 2/meson-sample.c new file mode 100644 index 0000000..d743b2d --- /dev/null +++ b/test cases/frameworks/28 gir link order 2/meson-sample.c @@ -0,0 +1,42 @@ +#include "meson-sample.h" + +struct _MesonSample { + GObject parent_instance; +}; + +G_DEFINE_TYPE (MesonSample, meson_sample, G_TYPE_OBJECT) + +/** + * meson_sample_new: + * + * Allocates a new #MesonSample. + * + * Returns: (transfer full): a #MesonSample. + */ +MesonSample * +meson_sample_new (void) +{ + return g_object_new (MESON_TYPE_SAMPLE, NULL); +} + +static void +meson_sample_class_init (MesonSampleClass *klass) +{ +} + +static void +meson_sample_init (MesonSample *self) +{ +} + +/** + * meson_sample_print_message: + * @self: a #MesonSample. + * + * Prints a message. + */ +void +meson_sample_print_message (MesonSample *self) +{ + g_return_if_fail (MESON_IS_SAMPLE (self)); +} diff --git a/test cases/frameworks/28 gir link order 2/meson-sample.h b/test cases/frameworks/28 gir link order 2/meson-sample.h new file mode 100644 index 0000000..2c28401 --- /dev/null +++ b/test cases/frameworks/28 gir link order 2/meson-sample.h @@ -0,0 +1,17 @@ +#ifndef MESON_SAMPLE_H +#define MESON_SAMPLE_H + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MESON_TYPE_SAMPLE (meson_sample_get_type()) + +G_DECLARE_FINAL_TYPE (MesonSample, meson_sample, MESON, SAMPLE, GObject) + +MesonSample *meson_sample_new (void); +void meson_sample_print_message (MesonSample *self); + +G_END_DECLS + +#endif /* MESON_SAMPLE_H */ diff --git a/test cases/frameworks/28 gir link order 2/meson.build b/test cases/frameworks/28 gir link order 2/meson.build new file mode 100644 index 0000000..5465a5b --- /dev/null +++ b/test cases/frameworks/28 gir link order 2/meson.build @@ -0,0 +1,35 @@ +project('gir link order 2', 'c') + +if not dependency('gobject-2.0', required : false).found() + error('MESON_SKIP_TEST gobject not found.') +endif + +gnome = import('gnome') +gobject = dependency('gobject-2.0') + +# This builds a dummy libsample under samelibname that's not really used +subdir('samelibname') + +# This builds the real libsample +meson_sample_sources = ['meson-sample.c', 'meson-sample.h'] +meson_sample_lib = shared_library( + 'sample', + sources : meson_sample_sources, + dependencies : [gobject], + link_with: [samelibname], + install : false, +) + +# g-ir-scanner should get the linker paths in the right order so it links first +# against the target libsample and not the dummy one that's just a dependency +# https://github.com/mesonbuild/meson/pull/5423 +gnome.generate_gir( + meson_sample_lib, + sources : meson_sample_sources, + nsversion : '1.0', + namespace : 'Meson', + symbol_prefix : 'meson', + identifier_prefix : 'Meson', + install : false, + build_by_default: true, +) diff --git a/test cases/frameworks/28 gir link order 2/samelibname/meson.build b/test cases/frameworks/28 gir link order 2/samelibname/meson.build new file mode 100644 index 0000000..8850372 --- /dev/null +++ b/test cases/frameworks/28 gir link order 2/samelibname/meson.build @@ -0,0 +1,5 @@ +samelibname = shared_library( + 'sample', + sources : [], + install : false, +) |