GNOME Bugzilla – Bug 773656
Fix various g-ir-scanner failures after switching to cmake
Last modified: 2016-10-31 14:04:56 UTC
I know Bug 773360 is already resolved, but there are still many other cases that can cause g-ir-scanner to fail to link or run the temporary executable. I will upload several patches here to fix all problems I found.
Created attachment 338759 [details] [review]
Remove unused INTROSPECTION_SCANNER_FLAGS variable
Created attachment 338760 [details] [review]
Fix mixed indent in GObjectIntrospection.cmake
Created attachment 338761 [details] [review]
Fix undefined reference error when g-ir-scanner links the temporary executable
When running g-ir-scanner with --no-libtool, g-ir-scanner automatically
adds arguments from CFLAGS, CPPFLAGS and LDFLAGS environment variables
before adding arguments supplied from the command line. This is fine
for CFLAGS and CPPFLAGS because arguments listed later can be used to
override the same or opposite arguments listed earlier.
However, LDFLAGS is usually a list of -L arguments, which are used to
specify an ordered list of directories to be searched by the linker.
Thie means arguments listed earlier have precedence over arguments
listed later, so it is not possible to change the order by adding more
Therefore, if an old version of evolution-data-server is already
installed in the prefix, it will be used when linking the temporary
executable, instead of the newly built one. This causes linking error
to happen if the new version adds new functions:
EBookContacts-1.2.o: undefined reference to `e_name_western_get_type'
EBookContacts-1.2.o: undefined reference to `e_address_western_get_type'
In order to resolve the linking issue, LDFLAGS is unset before running
g-ir-scanner, and required -L arguments are specified on g-ir-scanner
command line instead.
Created attachment 338762 [details] [review]
Fix undefined symbol error when g-ir-scanner runs the temporary executable
When running g-ir-scanner with --no-libtool, g-ir-scanner uses python
distutils instead of libtool to link the temporary executable. Unlike
libtool, which generates a wrapper script to setup the environment for
running the uninstalled executable, python distutils puts the output
executable at the specified location directly, without knowing how to
run the file. To keep the executable runnable without setting
additional environment variables, g-ir-scanner uses -rpath option to
hardcode the library search path into the executable.
It is fine if the path is hardcoded with DT_RPATH attribute in dynamic
section because it cannot be overrided by the environment. However,
python distutils automatically passes --enable-new-dtags option to the
linker on some systems, so DT_RUNPATH attribute is used instead of
DT_RPATH on these systems.
Therefore, when running the build in a JHBuild environment, which
always has LD_LIBRARY_PATH environment variable set, DT_RUNPATH written
in the executable is overrided by LD_LIBRARY_PATH set in the
environment. This means the old version of libraries installed in the
prefix will be found first, instead of the newly built ones. This
causes the executable to fail to run if the new version requires newly
EBookContacts-1.2: undefined symbol: e_name_western_get_type
EBookContacts-1.2: undefined symbol: e_address_western_get_type
To keep the executable runnable regardless of additional flags added by
python distutils, directories used for searching libraries specified on
g-ir-scanner command line are prepended to LD_LIBRARY_PATH environment
variable before running g-ir-scanner. The code used here is largely
based on file Source/WebKit2/PlatformGTK.cmake of WebKit project.
Created attachment 338763 [details] [review]
Add missing dependencies listed in gir_libdirs
If not all dependent libraries are listed, the linker will use the old
version of libraries installed in the prefix instead of newly built
ones, causing undefined reference error to be shown.
Created attachment 338764 [details] [review]
Remove useless _INCLUDE_DIRS arguments in gir_cflags
Since _INCLUDE_DIRS arguments are not prefixed with -I, GCC ignores
them and shows a lot of warnings.
These arguments also cause problems when compiling with Clang, which
doesn't seem to ignore them and show error messages:
clang-cpp: error: cannot specify -o when generating multiple output files
Thanks for a bug report and patches. They didn't break anything here, and I hope they will fix things elsewhere, thus I'm going to commit them.
As a side note, I do not like many small patches, thus I merged them into one. It's a headache to change status of the all patches in the bugzilla to refreck the right state. All your notes are here, which is fine (that's one of the reasons why there is the bug reference in the commit message, from my point of view).
Created commit 69e54a3 in eds master (3.23.2+)