Skip to content
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

gnome: Distinguish between internal and external linker flags #3463

Merged
merged 2 commits into from
Jul 1, 2018

Conversation

lantw44
Copy link
Contributor

@lantw44 lantw44 commented Apr 24, 2018

This is a follow-up of #1718 and #1932. It fixes appstream-glib gir generation failure and gst-plugins-base gtk-doc build error for me in JHBuild on FreeBSD.

When an older version of the library being built is installed in the
same prefix as external dependencies, we have to be careful to construct
the linker or compiler command line. If a -L flag from external
dependencoes comes before a -L flag pointing to builddir, it is possible
for the linker to load older libraries from the installation prefix
instead of the newly built ones, which is likely to cause undefined
reference error.

Since the order of dependencies is not significant, we cannot expect
internal dependencies to appear before external dependencies when
recursively iterating the list of dependencies. To make it harder to
make mistakes, linker flags come from internal and external
dependencies are now stored in different order sets. Code using
_get_dependencies_flags are expected to follow the order when
constructing linker command line:

  1. Internal linker flags
  2. LDFLAGS set by users
  3. External linker flags

It is similar to what automake and libtool do for autotools projects.

@lantw44
Copy link
Contributor Author

lantw44 commented Apr 24, 2018

This patch doesn't fix all library path issues on FreeBSD. It is still possible to see build failure caused by wrong library path (#2881). Library path is always hard to get right ...

@lantw44 lantw44 force-pushed the master branch 2 times, most recently from 99fceb1 to 8944571 Compare April 27, 2018 14:48
@lantw44
Copy link
Contributor Author

lantw44 commented Apr 27, 2018

I just fixed the line of code which caused test failure, and I hope my patch is good for review now.

@nirbheek nirbheek added this to the meson-next milestone Apr 28, 2018
@ajacoutot
Copy link
Contributor

This fixes the issue we have building meson projects that bundle libgd when the graphical library libgd (https://libgd.github.io/) is also installed on the system (same name but totally different libs).
e.g. https://bugzilla.gnome.org/show_bug.cgi?id=795503

@lantw44
Copy link
Contributor Author

lantw44 commented May 19, 2018

Ping ... Can we get this reviewed?

@jpakkane
Copy link
Member

If a -L flag from external dependencoes comes before a -L flag pointing to builddir, it is possible for the linker to load older libraries from the installation prefix instead of the newly built ones

This should not happen. When linking built libraries we always link them by their file names. Thus -L never comes into play when resolving them. This already works for libraries and executables. Why is it not working for gir and gtk-doc? What are they doing differently?

@lantw44
Copy link
Contributor Author

lantw44 commented May 19, 2018

_get_link_args in mesonbuild/modules/gnome.py doesn't use file names. It uses -L and -l arguments. There are also --extra-library arguments, which was added to g-ir-scanner to support meson. I guess it was done in this way because g-ir-scanner doesn't seem to provide a way to specify file names directly. The code for gtkdoc-scangobj probably just reuses the code written for g-ir-scanner even if it allows specifying linker flags directly with --ldflags.

@jpakkane
Copy link
Member

I guess it was done in this way because g-ir-scanner doesn't seem to provide a way to specify file names directly.

This seems like a missing feature. -L flags and the like are a reliability and maintenance nightmare. They never work reliably, as demonstrated by this PR.

@lantw44
Copy link
Contributor Author

lantw44 commented May 20, 2018

Yes, everytime a project decided not to use automake and libtool, its gir build is very likely to be broken. It is hard to get right, and it usually takes me several days, or even weeks, to fix it in a reliable way. The solution usually looks like ugly workarounds, including changing the order of -L flags, unsetting LDFLAGS, extracting -L flags from LDFLAGS, prepending things to LD_LIBRARY_PATH. The LDFLAGS and LD_LIBRARY_PATH issues seem to be finally fixed in g-ir-scanner because of the inability of meson to manipulate environment variables, so the remaining problem is that the build system still have to figure out the correct -L order.

By the way, as you can find in mesonbuild/scripts/gtkdochelper.py, gtkdoc-scangobj still depends on the build system to set the correct LD_LIBRARY_PATH for it.

Do you want me to open a gobject-introspection feature request? I don't really understand how g-ir-scanner works, but I think it is not an easy task because g-ir-scanner not only passes -l to the linker but also uses them to find SONAME with ldd. I hope this doesn't make this pull request depend on a feature request.

@lantw44
Copy link
Contributor Author

lantw44 commented May 24, 2018

Hello, what should I do to make progress on this issue?

@nirbheek
Copy link
Member

I think we can get this in, I agree we should not block on gobject-introspection fixing itself.

I believe we need two things:

  1. An upstream feature request so we can fix this properly (please paste it here once you've filed it).
  2. A test that triggers this so we can ensure it doesn't break in the future when someone refactors things.

For the test, you will likely want to write it as a unit test; see run_unittests.py. You should be able to look at other tests in there for inspiration. If you need help, poke again on this issue and I can help you with it.

@nirbheek nirbheek self-assigned this Jun 3, 2018
@nirbheek
Copy link
Member

nirbheek commented Jun 3, 2018

@lantw44 were you able to find time for this?

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 6, 2018

I remember this pull requeset is still open, but I spent most of my free time fixing GLib tests on FreeBSD in the last week.

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 18, 2018

I just updated the commit to include a new project test called frameworks/22 gir link order. It works with the linker flags fix here and it fails with the current master branch, which doesn't handle -L order properly.

@nirbheek
Copy link
Member

I just updated the commit to include a new project test called frameworks/22 gir link order. It works with the linker flags fix here and it fails with the current master branch, which doesn't handle -L order properly.

Thanks! Will do a review soon.

I guess it was done in this way because g-ir-scanner doesn't seem to provide a way to specify file names directly.

Could you open an upstream bug about this too and paste it here? I am optimistic about getting it fixed there too.

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 18, 2018

It looks like that GLib is not available in Windows and macOS test environments, so I should skip the test when GLib cannot be found.

Copy link
Member

@nirbheek nirbheek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rebase against master and see if the pkg-config hack is still needed?

@@ -679,13 +679,18 @@ def detect_system_compiler():
else:
raise RuntimeError("Could not find C compiler.")

def setup_env():
# Required by 'frameworks/22 gir link order' test
os.environ['PKG_CONFIG_SYSTEM_LIBRARY_PATH'] = ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed anymore. We call pkg-config with PKG_CONFIG_ALLOW_SYSTEM_LIBS=1, so it will always have -L flags in it.

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 20, 2018

Could you please rebase against master and see if the pkg-config hack is still needed?

After rebasing on the current master branch, I am no longer able to reproduce build failure in frameworks/22 gir link order test added here. It seems that meson now converts -L and -l arguments returned by pkg-config to absolute paths, so -L order troubles cannot be triggered.

Could you open an upstream bug about this too and paste it here? I am optimistic about getting it fixed there too.

I am surprised to see that g-ir-scanner seems to already support it. The pkg-config change committed to meson recently also affects the GNOME module, and full path to .so files are now passed directly to g-ir-scanner instead of being converted to -L and -l flags. Atk and Pango can be successfully built with meson master branch, and ninja -t commands shows absolute paths such as /home/lantw44/gnome/devinstall/lib/libglib-2.0.so are passed to g-ir-scanner.

However, I cannot test for gtk-doc because of unrelated problems. Pango gtk-doc build fails with 'no such file or directory' and Atk gtk-doc build fails with include path problems.

@nirbheek
Copy link
Member

After rebasing on the current master branch, I am no longer able to reproduce build failure in frameworks/22 gir link order test added here. It seems that meson now converts -L and -l arguments returned by pkg-config to absolute paths, so -L order troubles cannot be triggered.

That was the intention of that PR, and I'm glad to see that it worked here too. Thanks for testing and verifying that!

What's the gtk-doc issue? Could you please investigate a bit more and file an issue about it? We have a release on 1st, and would be good to know about possible regressions.

@nirbheek
Copy link
Member

I'm glad to see that it worked here too. Thanks for testing and verifying that!

Could you please rebase this PR to only include the test then? That should go in so we don't accidentally break that in the future.

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 20, 2018

Could you please rebase this PR to only include the test then? That should go in so we don't accidentally break that in the future.

I am not sure what you meant here. I think the patch to GNOME module here is still nice to have. There are still a few -L flags being used when running g-ir-scanner. Even if all external libraries are referenced with full paths, I think we will still want to make sure that internal libraries come before external ones because sometimes RPATH or RUNPATH set on external libraries can also cause problems.

@nirbheek
Copy link
Member

I am not sure what you meant here. I think the patch to GNOME module here is still nice to have. There are still a few -L flags being used when running g-ir-scanner.

Which ones are those?

Even if all external libraries are referenced with full paths, I think we will still want to make sure that internal libraries come before external ones because sometimes RPATH or RUNPATH set on external libraries can also cause problems.

I am not sure I understand. With that patch, we get rid of -L and -l arguments completely, so ideally there won't be anything to filter.

I also do not understand your concerns about RPATH or RUNPATH, could you expand on that a bit?

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 20, 2018

That was the intention of that PR, and I'm glad to see that it worked here too. Thanks for testing and verifying that!

I just found that I was wrong ... g-ir-scanner seems to consider these .so file arguments as source files. It seems to ignore them and doesn't pass them to the linker. The reason it sometimes works is that these libraries may also be pulled in as dependencies by the library itself.

@nirbheek
Copy link
Member

I just found that I was wrong ... g-ir-scanner seems to consider these .so file arguments as source files. It seems to ignore them and doesn't pass them to the linker

Well that's dumb. I'll test tomorrow how much breakage this is going to cause.

@xclaesse
Copy link
Member

xclaesse commented Jun 20, 2018

As I suggested in issue #3768, I think the best long-term fix here is to let meson/ninja build generated binaries instead of letting external scripts doing it. The code in GNOME module that try to pass the flags to python wrappers is scary, it tries to replicate what meson backends already does to collect the right flags in the right order.

Would be nice if those GNOME scripts could only generate .c files and let meson deal with compilation/execution of them. I started playing with that idea in https://gitlab.gnome.org/GNOME/gtk-doc/merge_requests/1

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 21, 2018

Which ones are those?

generate_gir function in mesonbuild/modules/gnome.py produces -L flags by itself, so it is still possible to see meson-generated -L flags on g-ir-scanner command line.

I am not sure I understand. With that patch, we get rid of -L and -l arguments completely, so ideally there won't be anything to filter.

Yes, ideally it won't cause any problems, but I cannot be sure without testing 200 modules in JHBuild ... As what I said in the previous comment, g-ir-scanner doesn't really support passing libraries with full path. The pkg-config change already causes g-ir-scanner to fail for some modules in my JHBuild environment, including link-time failure (undefined reference to some_fribidi_symbol) and run-time failure (undefined symbol some_colord_symbol).

I also do not understand your concerns about RPATH or RUNPATH, could you expand on that a bit?

Even if we have no -L flags, ld still have to find dependencies of libraries we pass on the command line. The search path of dependent libraries are not constructed from -L flags but made from several command line arguments, environment variables and ELF file headers. If I understand correctly, GNU binutils manual says the search order is:

  1. -rpath-link flags.
  2. -rpath flags.
  3. LD_LIBRARY_PATH environment variable.
  4. DT_RUNPATH or DT_RPATH in libraries.

If we ignore -rpath-link here, the first possible problem is -rpath flags. g-ir-scanner seems to convert each -L flag into a -L flag and a -rpath flag, which means an unexpected -L flag passed to g-ir-scanner can change the search order and causes linking failure.

I think DT_RUNPATH or DT_RPATHis likely a minor issue if we assume users always set LD_LIBRARY_PATH correctly. However, if users forget to set LD_LIBRARY_PATH before running ninja, relying on DT_RUNPATH or DT_RPATH set on external libraries may cause unexpected problems.

I just found gnome-session now fails to link because of the -rpath and -rpath-link issue:

[56/72] Linking target gnome-session/gnome-session-binary.
FAILED: gnome-session/gnome-session-binary
clang  -o gnome-session/gnome-session-binary 'gnome-session/gnome-session@@gnome-session-binary@exe/meson-generated_.._org.gnome.SessionManager.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/meson-generated_.._org.gnome.SessionManager.Client.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/meson-generated_.._org.gnome.SessionManager.ClientPrivate.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/meson-generated_.._org.gnome.SessionManager.App.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/meson-generated_.._org.gnome.SessionManager.Inhibitor.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/meson-generated_.._org.gnome.SessionManager.Presence.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-app.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-autostart-app.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-client.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-dbus-client.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-fail-whale.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-inhibitor.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gdm-log.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-manager.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-presence.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-process-helper.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-session-fill.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-session-save.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-shell-extensions.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-shell.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-store.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-system.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-systemd.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-xsmp-client.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-xsmp-server.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/main.c.o' 'gnome-session/gnome-session@@gnome-session-binary@exe/gsm-consolekit.c.o' -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,--no-undefined -Wl,--as-needed -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og -Wl,--start-group gnome-session/libgsmutil.a -L/home/lantw44/gnome/devinstall/lib /home/lantw44/gnome/devinstall/lib/libgio-2.0.so /home/lantw44/gnome/devinstall/lib/libgobject-2.0.so /home/lantw44/gnome/devinstall/lib/libglib-2.0.so -lintl -Wl,--end-group -L/home/lantw44/gnome/devinstall/lib -lintl -L/home/lantw44/gnome/devinstall/lib /home/lantw44/gnome/devinstall/lib/libgnome-desktop-3.so /home/lantw44/gnome/devinstall/lib/libgtk-3.so /home/lantw44/gnome/devinstall/lib/libgdk-3.so /home/lantw44/gnome/devinstall/lib/libpangocairo-1.0.so /home/lantw44/gnome/devinstall/lib/libpango-1.0.so /home/lantw44/gnome/devinstall/lib/libatk-1.0.so /home/lantw44/gnome/devinstall/lib/libcairo-gobject.so /home/lantw44/gnome/devinstall/lib/libcairo.so /home/lantw44/gnome/devinstall/lib/libgdk_pixbuf-2.0.so -lintl -L/home/lantw44/gnome/devinstall/lib /home/lantw44/gnome/devinstall/lib/libjson-glib-1.0.so -lintl /usr/local/lib/libICE.so /usr/local/lib/libSM.so -L/home/lantw44/gnome/devinstall/lib -lintl /usr/local/lib/libdbus-glib-1.so /usr/local/lib/libdbus-1.so /usr/local/lib/libgobject-2.0.so /usr/local/lib/libglib-2.0.so /usr/local/lib/libintl.so -L/home/lantw44/gnome/devinstall/lib -lintl -L/home/lantw44/gnome/devinstall/lib -lintl -L/home/lantw44/gnome/devinstall/lib -lintl -L/home/lantw44/gnome/devinstall/lib -lintl '-Wl,-rpath,$ORIGIN/../../../../../../local/lib' -Wl,-rpath-link,/usr/local/lib
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_par_embedding_levels_ex'
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_bracket'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 21, 2018

What's the gtk-doc issue? Could you please investigate a bit more and file an issue about it? We have a release on 1st, and would be good to know about possible regressions.

I filed 3 issues for gtk-doc problems:
#3772: missing include paths
#3773: types file not found
#3774: library path order issue

@lantw44
Copy link
Contributor Author

lantw44 commented Jun 24, 2018

Well that's dumb. I'll test tomorrow how much breakage this is going to cause.

I did a test with jhbuild tinderbox yesterday and there were a lot of meson issues. I attached the test result here: meson-0.47.0.dev1-tests.zip. These issues not only affect the GNOME module but also cause undefined reference error when linking executables without using GNOME helpers.

You can find 20 library path issues in the test result.

  • Linking executables (16 issues): gnome-color-manager, libgweather, gnome-settings-daemon, gnome-control-center, gnome-session, gnome-shell, eog, nautilus, file-roller, libgepub, gnome-font-viewer, gnome-screenshot, bijiben, gnome-builder, gnome-recipes, gthumb.
  • GNOME GIR (2 issues): gst-plugins-base, gst-plugins-bad.
  • GNOME GTK-Doc (2 issues): at-spi2-core, gstreamer.

The most common error is:

/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_par_embedding_levels_ex'
/home/lantw44/gnome/devinstall/lib/libpango-1.0.so: undefined reference to `fribidi_get_bracket'

It is likely to be related to the -Wl,-rpath-link,/usr/local/lib argument, which causes the linker to search libfribidi.so in /usr/local/lib instead of path specified with LD_LIBRARY_PATH and LDFLAGS, which is /home/lantw44/gnome/devinstall/lib:/usr/local/lib.

lantw44 and others added 2 commits July 1, 2018 22:17
When an older version of the library being built is installed in the
same prefix as external dependencies, we have to be careful to construct
the linker or compiler command line. If a -L flag from external
dependencoes comes before a -L flag pointing to builddir, it is possible
for the linker to load older libraries from the installation prefix
instead of the newly built ones, which is likely to cause undefined
reference error.

Since the order of dependencies is not significant, we cannot expect
internal dependencies to appear before external dependencies when
recursively iterating the list of dependencies. To make it harder to
make mistakes, linker flags come from internal and external
dependencies are now stored in different order sets. Code using
_get_dependencies_flags are expected to follow the order when
constructing linker command line:

  1. Internal linker flags
  2. LDFLAGS set by users
  3. External linker flags

It is similar to what automake and libtool do for autotools projects.
Those tools use our arguments to build a file and execute it to
introspect it at runtime. However, they do not know that you can pass
the full path to the library to use, and ignore the arguments.

The long-term fix for this is to have them output a .c file that Meson
will build for them, which they can then run, but that will require
upstream changes:
https://gitlab.gnome.org/GNOME/gtk-doc/merge_requests/1

Closes mesonbuild#3774
@nirbheek
Copy link
Member

nirbheek commented Jul 1, 2018

@lantw44 I've added a commit that should revert the change that caused us to return absolute paths to libraries to gtkdoc and generate_gir. I couldn't find a way to write a test for it unfortunately, but I did manually verify that the previous behaviour is now back.

Could you please test if this fixes things for you? I'll be merging this in a few hours, but if you find any issues we can fix it for the stable release.

The long-term fix is to have g-ir-scanner and gtkdoc-scan defer to Meson for the build parts instead of doing it themselves, and @xclaesse is working on it.

@nirbheek nirbheek merged commit 5113eb1 into mesonbuild:master Jul 1, 2018
@lantw44
Copy link
Contributor Author

lantw44 commented Jul 3, 2018

Could you please test if this fixes things for you? I'll be merging this in a few hours, but if you find any issues we can fix it for the stable release.

Unfortunately, it only fixes gst-plugins-bad build. at-spi2-core, gstreamer, gst-plugins-base and issues unrelated to the meson GNOME module are still not fixed. All of these 4 projects mentioned here can be built successfully with meson 0.46.1 if the patch proposed in this pull request is applied.

Building at-spi2-core with meson 0.46.1 + patch:

Running custom install script '/usr/local/bin/python3.6 /usr/local/bin/meson --internal gtkdoc --sourcedir=/usr/home/lantw44/gnome/source/at-spi2-core --builddir=/usr/home/lantw44/gnome/build/at-spi2-core --subdir=doc/libatspi --headerdirs=/usr/home/lantw44/gnome/source/at-spi2-core/atspi@@/usr/home/lantw44/gnome/build/at-spi2-core/atspi --mainfile=libatspi-docs.sgml --modulename=libatspi --mode=auto --scanargs=--rebuild-types --gobjects-types-file=libatspi.types --fixxrefargs=--html-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html@@--extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/glib@@--extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/gobject --mkdbargs=--sgml-mode@@--output-format=xml --content-files= --cflags=-I/usr/home/lantw44/gnome/build/at-spi2-core/. -I/usr/home/lantw44/gnome/source/at-spi2-core/. -I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -D_THREAD_SAFE -pthread -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og --ldflags=-L/usr/home/lantw44/gnome/build/at-spi2-core/atspi -Wl,-rpath,/usr/home/lantw44/gnome/build/at-spi2-core/atspi -latspi -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -ldbus-1 -lgobject-2.0 -lglib-2.0 -lintl -lX11 -lXtst -lXi --cc=clang --ld=clang'
Building documentation for libatspi

Building at-spi2-core with the current meson master branch

Running custom install script '/usr/local/bin/python3 /usr/home/lantw44/gnome/devinstall/bin/meson --internal gtkdoc --sourcedir=/usr/home/lantw44/gnome/source/at-spi2-core --builddir=/usr/home/lantw44/gnome/build/at-spi2-core --subdir=doc/libatspi --headerdirs=/usr/home/lantw44/gnome/source/at-spi2-core/atspi@@/usr/home/lantw44/gnome/build/at-spi2-core/atspi --mainfile=libatspi-docs.sgml --modulename=libatspi --mode=auto --scanargs=--rebuild-types --gobjects-types-file=/usr/home/lantw44/gnome/source/at-spi2-core/doc/libatspi/libatspi.types --fixxrefargs=--html-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html@@--extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/glib@@--extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/gobject --mkdbargs=--sgml-mode@@--output-format=xml --content-files= --cflags=-I/usr/home/lantw44/gnome/build/at-spi2-core/. -I/usr/home/lantw44/gnome/source/at-spi2-core/. -I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -D_THREAD_SAFE -pthread -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og --ldflags=-L/usr/home/lantw44/gnome/build/at-spi2-core/atspi -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/home/lantw44/gnome/build/at-spi2-core/atspi -latspi -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og -L/home/lantw44/gnome/devinstall/lib -ldbus-1 -lgobject-2.0 -lglib-2.0 -lintl -lX11 -lXtst -lXi --cc=clang --ld=clang'
Building documentation for libatspi
ERROR:
Error in gtkdoc helper script:

ERROR: 'gtkdoc-scangobj' failed with status 1
/usr/home/lantw44/gnome/build/at-spi2-core/libatspi-scan: Undefined symbol "atspi_scroll_type_get_type"
2018-07-04 01:47:28,546:scangobj.py:execute_command:1196:WARNING:Running scanner failed: 1, command: ./libatspi-scan

FAILED: meson-install

We can found that -Wl,-rpath,/usr/local/lib comes before -Wl,-rpath,/usr/home/lantw44/gnome/build/at-spi2-core/atspi, so the wrong version of the library is loaded when running libatspi-scan.

The problem of gstreamer is similar:

Building gstreamer with meson 0.46.1 + patch:

Running custom install script '/usr/local/bin/python3.6 /usr/local/bin/meson --internal gtkdoc --sourcedir=/usr/home/lantw44/gnome/source/gstreamer --builddir=/usr/home/lantw44/gnome/build/gstreamer --subdir=docs/gst --headerdirs=/usr/home/lantw44/gnome/source/gstreamer/docs/gst/../../gst --mainfile=gstreamer-docs.sgml --modulename=gstreamer --mode=auto --scanargs=--deprecated-guards=GST_DISABLE_DEPRECATED@@--ignore-decorators=GST_API@@--ignore-headers=gettext.h glib-compat-private.h glib-compat.h gst-i18n-app.h gst-i18n-lib.h gst_private.h gstelementdetails.h gstmacros.h grammar.tab.h grammar.tab.pre.h math-compat.h types.h --scanobjsargs=--type-init-func="gst_init(NULL,NULL)" --gobjects-types-file=/usr/home/lantw44/gnome/build/gstreamer/docs/gst/gstreamer.types --content-files=/usr/home/lantw44/gnome/source/gstreamer/docs/gst/building.xml@@/usr/home/lantw44/gnome/source/gstreamer/docs/gst/running.xml@@/usr/home/lantw44/gnome/build/gstreamer/docs/version.entities --cflags=-I/usr/home/lantw44/gnome/build/gstreamer/. -I/usr/home/lantw44/gnome/source/gstreamer/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og --ldflags=-L/usr/home/lantw44/gnome/build/gstreamer/gst -Wl,-rpath,/usr/home/lantw44/gnome/build/gstreamer/gst -lgstreamer-1.0 -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -lgobject-2.0 -lglib-2.0 -lintl -lgmodule-2.0 -pthread -lm -ldl -lunwind -lexecinfo --cc=clang --ld=clang'
Building documentation for gstreamer
gstreamer-scan.c:122:3: warning: expression result unused [-Wunused-value]
  "gst_init(NULL,NULL)";
  ^~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Building gstreamer with the current meson master branch:

Running custom install script '/usr/local/bin/python3 /usr/home/lantw44/gnome/devinstall/bin/meson --internal gtkdoc --sourcedir=/usr/home/lantw44/gnome/source/gstreamer --builddir=/usr/home/lantw44/gnome/build/gstreamer --subdir=docs/gst --headerdirs=/usr/home/lantw44/gnome/source/gstreamer/docs/gst/../../gst --mainfile=gstreamer-docs.sgml --modulename=gstreamer --mode=auto --scanargs=--deprecated-guards=GST_DISABLE_DEPRECATED@@--ignore-decorators=GST_API@@--ignore-headers=gettext.h glib-compat-private.h glib-compat.h gst-i18n-app.h gst-i18n-lib.h gst_private.h gstelementdetails.h gstmacros.h grammar.tab.h grammar.tab.pre.h math-compat.h types.h --scanobjsargs=--type-init-func="gst_init(NULL,NULL)" --gobjects-types-file=/usr/home/lantw44/gnome/build/gstreamer/docs/gst/gstreamer.types --content-files=/usr/home/lantw44/gnome/source/gstreamer/docs/gst/building.xml@@/usr/home/lantw44/gnome/source/gstreamer/docs/gst/running.xml@@/usr/home/lantw44/gnome/build/gstreamer/docs/version.entities --cflags=-I/usr/home/lantw44/gnome/build/gstreamer/. -I/usr/home/lantw44/gnome/source/gstreamer/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og --ldflags=-L/usr/home/lantw44/gnome/build/gstreamer/gst -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/home/lantw44/gnome/build/gstreamer/gst -lgstreamer-1.0 -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl -lgmodule-2.0 -pthread -lm -ldl -lunwind -lexecinfo --cc=clang --ld=clang'
Building documentation for gstreamer
ERROR:
Error in gtkdoc helper script:

ERROR: 'gtkdoc-scangobj' failed with status 1
gstreamer-scan.c:122:3: warning: expression result unused [-Wunused-value]
  "gst_init(NULL,NULL)";
  ^~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/usr/home/lantw44/gnome/build/gstreamer/gstreamer-scan: Undefined symbol "gst_promise_get_type"
2018-07-04 01:51:09,232:scangobj.py:execute_command:1196:WARNING:Running scanner failed: 1, command: ./gstreamer-scan

FAILED: meson-install

-Wl,-rpath,/usr/local/lib should not come before -Wl,-rpath,/usr/home/lantw44/gnome/build/gstreamer/gst.

I haven't checked why gst-plugins-base fails, but it looks like a library path issue again.

Building gst-plugins-base with meson 0.46.1 + patch:

[246/704] Generating GstAudio-1.0.gir with a custom command.
g-ir-scanner: link: clang -o /usr/home/lantw44/gnome/build/gst-plugins-base/tmp-introspecto5m_pga1/GstAudio-1.0 -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og /usr/home/lantw44/gnome/build/gst-plugins-base/tmp-introspecto5m_pga1/GstAudio-1.0.o -L. -Wl,-rpath,. -Wl,--no-as-needed -lgstaudio-1.0 -lgsttag-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lm -lorc-0.4 -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio -Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -L/home/lantw44/gnome/devinstall/lib -Wl,-rpath,/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/home/lantw44/gnome/devinstall/lib -Wl,-rpath,/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib
source/gst-plugins-base/gst-libs/gst/audio/gstaudiometa.c:379: Warning: GstAudio: gst_buffer_add_audio_meta: return value: Invalid non-constant return of bare structure or union; register as boxed type or (skip)
[323/704] Compiling C object 'gst/adder/gst@adder@@gstadder@sha/meson-generated_.._gstadderorc.c.o'.

Building gst-plugins-base with the current meson master branch:

[245/704] Generating GstAudio-1.0.gir with a custom command.
FAILED: gst-libs/gst/audio/GstAudio-1.0.gir
/home/lantw44/gnome/devinstall/bin/g-ir-scanner -I/home/lantw44/gnome/devinstall/include/gobject-introspection-1.0 -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -I/usr/local/lib/libffi-3.2.1/include --no-libtool --namespace=GstAudio --nsversion=1.0 --warn-all --output gst-libs/gst/audio/GstAudio-1.0.gir '--add-init-section=extern void gst_init(gint*,gchar**);g_setenv("GST_REGISTRY_DISABLE", "yes", TRUE);g_setenv("GST_REGISTRY_1.0", "/usr/home/lantw44/gnome/build/gst-plugins-base/gir_empty_registry.reg", TRUE);g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);gst_init(NULL,NULL);' --c-include=gst/audio/audio.h -I/usr/home/lantw44/gnome/source/gst-plugins-base/gst-libs/gst/audio -I/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio -I./. -I../../source/gst-plugins-base/. -I./gst-libs -I../../source/gst-plugins-base/gst-libs -I./gst-libs -I../../source/gst-plugins-base/gst-libs --filelist=/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/gst-libs@gst@audio@@gstaudio-1.0@sha/GstAudio_1.0_gir_filelist --include=Gst-1.0 --include=GstBase-1.0 --include=GLib-2.0 --include=GObject-2.0 --include=GModule-2.0 --symbol-prefix=gst --identifier-prefix=Gst --pkg-export=gstreamer-audio-1.0 --cflags-begin -fvisibility=hidden -fno-strict-aliasing -Wmissing-declarations -Wredundant-decls -Wundef -Wwrite-strings -Wformat -Wformat-nonliteral -Wformat-security -Winit-self -Wmissing-include-dirs -Waddress -Wno-multichar -Wvla -Wpointer-arith -Wmissing-prototypes -Wdeclaration-after-statement -I./. -I../../source/gst-plugins-base/. -I./gst-libs -I../../source/gst-plugins-base/gst-libs -I/home/lantw44/gnome/devinstall/include/gstreamer-1.0 -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -I/usr/local/include/orc-0.4 -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og --cflags-end -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag --extra-library=gsttag-1.0 --add-include-path=/home/lantw44/gnome/devinstall/share/gir-1.0 --add-include-path=/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -L/usr/local/lib --library gstaudio-1.0 -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -L/home/lantw44/gnome/devinstall/lib --extra-library=gstbase-1.0 --extra-library=gstreamer-1.0 --extra-library=gobject-2.0 --extra-library=glib-2.0 --extra-library=intl --extra-library=m -L/usr/local/lib --extra-library=orc-0.4
g-ir-scanner: link: clang -o /usr/home/lantw44/gnome/build/gst-plugins-base/tmp-introspectz8wvzkal/GstAudio-1.0 -march=corei7 -B/home/lantw44/.local/bin -pipe -g3 -Og /usr/home/lantw44/gnome/build/gst-plugins-base/tmp-introspectz8wvzkal/GstAudio-1.0.o -L. -Wl,-rpath,. -Wl,--no-as-needed -lgstaudio-1.0 -lgsttag-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lm -lorc-0.4 -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio -Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/home/lantw44/gnome/devinstall/lib -Wl,-rpath,/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/home/lantw44/gnome/devinstall/lib -Wl,-rpath,/home/lantw44/gnome/devinstall/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/home/lantw44/gnome/devinstall/lib -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lintl -L/home/lantw44/gnome/devinstall/lib -L/usr/local/lib
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_finish_buffer'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_pad_drop_buffer'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_pad_get_type'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_simple_get_next_time'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_element_foreach_sink_pad'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_set_latency'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_pad_is_eos'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_pad_peek_buffer'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_get_type'
/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio/libgstaudio-1.0.so: undefined reference to `gst_aggregator_get_allocator'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
linking of temporary binary failed: Command '['clang', '-o', '/usr/home/lantw44/gnome/build/gst-plugins-base/tmp-introspectz8wvzkal/GstAudio-1.0', '-march=corei7', '-B/home/lantw44/.local/bin', '-pipe', '-g3', '-Og', '/usr/home/lantw44/gnome/build/gst-plugins-base/tmp-introspectz8wvzkal/GstAudio-1.0.o', '-L.', '-Wl,-rpath,.', '-Wl,--no-as-needed', '-lgstaudio-1.0', '-lgsttag-1.0', '-lgstbase-1.0', '-lgstreamer-1.0', '-lgobject-2.0', '-lglib-2.0', '-lintl', '-lm', '-lorc-0.4', '-L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio', '-Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/audio', '-L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag', '-Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag', '-L/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag', '-Wl,-rpath,/usr/home/lantw44/gnome/build/gst-plugins-base/gst-libs/gst/tag', '-L/usr/local/lib', '-Wl,-rpath,/usr/local/lib', '-L/home/lantw44/gnome/devinstall/lib', '-Wl,-rpath,/home/lantw44/gnome/devinstall/lib', '-L/usr/local/lib', '-Wl,-rpath,/usr/local/lib', '-L/home/lantw44/gnome/devinstall/lib', '-Wl,-rpath,/home/lantw44/gnome/devinstall/lib', '-L/usr/local/lib', '-Wl,-rpath,/usr/local/lib', '-L/home/lantw44/gnome/devinstall/lib', '-lgio-2.0', '-lgobject-2.0', '-Wl,--export-dynamic', '-lgmodule-2.0', '-pthread', '-lglib-2.0', '-lintl', '-L/home/lantw44/gnome/devinstall/lib', '-L/usr/local/lib']' returned non-zero exit status 1.

The long-term fix is to have g-ir-scanner and gtkdoc-scan defer to Meson for the build parts instead of doing it themselves, and @xclaesse is working on it.

Yes, it will be much easier to test and debug if we don't have two ways to generate linker flags. However, it may also be required to find a solution for #1635 because the reason which g-ir-scanner currently works is that it can set LD_LIBRARY_PATH by itself.

@nirbheek
Copy link
Member

nirbheek commented Jul 3, 2018

All of these 4 projects mentioned here can be built successfully with meson 0.46.1 if the patch proposed in this pull request is applied.

The patch in this PR is already merged, but if you can find a fix for these issues, I'll gladly apply it for the 0.47.1 stable release. FWICT these are FreeBSD-specific issues, so I have no way to test it.

@nirbheek
Copy link
Member

nirbheek commented Jul 3, 2018

Another thing that would help, is if you could help us with setting up FreeBSD CI on Travis. I have tried in the past and failed, but Rust has a way to do it. I think for continued stability and regression testing, this is required.

@lantw44
Copy link
Contributor Author

lantw44 commented Jul 4, 2018

The patch in this PR is already merged.

I meant applying the older version of the patch to meson 0.46.1. This is what currently used in FreeBSD ports.

if you could help us with setting up FreeBSD CI on Travis. I have tried in the past and failed, but Rust has a way to do it.

Do you mean running FreeBSD in QEMU, as Travis doesn't support FreeBSD?

@nirbheek
Copy link
Member

nirbheek commented Jul 4, 2018

I meant applying the older version of the patch to meson 0.46.1. This is what currently used in FreeBSD ports.

Yes, I typed 'enter' too soon, my edit tries to make my intent clearer: I can't reproduce this because I don't have a FreeBSD instance to test things on, so if you could figure out what else needs changing we can get this into the 0.47.1 stable release.

Do you mean running FreeBSD in QEMU, as Travis doesn't support FreeBSD?

Yes, Rust seems to do this: https://github.com/nbaksalyar/rust-libc/tree/master/ci#qemu-setup---freebsd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants