Remove .la files generated by autotools #670

Merged
merged 7 commits into from Aug 18, 2016

Conversation

Projects
None yet
3 participants
Contributor

robert-ancell commented Jul 19, 2016

If you build a part that depends on a library part, e.g.

parts:
glib:
plugin: autotools
source: https://download.gnome.org/core/3.20/3.20.2/sources/glib-2.48.1.tar.xz
glib-networking:
plugin: autotools
source: https://download.gnome.org/core/3.20/3.20.2/sources/glib-networking-2.48.2.tar.xz
after:
- glib

Then the dependant part fails to link due to the .la files being moved around:

CCLD glib-pacrunner
libtool: warning: library '/home/bob/bzr/gnome-3-20-snap/stage/lib/libgio-2.0.la' was moved.
libtool: error: cannot find the library '/lib/libgobject-2.0.la' or unhandled argument '/lib/libgobject-2.0.la'

.la files aren't commonly used (they are removed in Debian) and removing them fixes this issue. See discussion http://stackoverflow.com/questions/7104494/building-so-module-with-autotools-libtool-without-la-and-a-variants-being-ins

Can one of the admins verify this patch?

Can one of the admins verify this patch?

Contributor

robert-ancell commented Jul 19, 2016

I'm not sure if we should allow the user to keep the .la files or not. The current patch makes it impossible to keep them. I think they should be removed by default though as this is what most people will want and it avoids the original issue with building against them.

Contributor

robert-ancell commented Jul 19, 2016

$ cat ./stage/lib/libgio-2.0.la
# libgio-2.0.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-0.1
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libgio-2.0.so.0'

# Names of this library.
library_names='libgio-2.0.so.0.4800.1 libgio-2.0.so.0 libgio-2.0.so'

# The name of the static archive.
old_library=''

# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''

# Libraries that this one depends upon.
dependency_libs=' /lib/libgobject-2.0.la -lffi /lib/libgmodule-2.0.la -ldl /lib/libglib-2.0.la -lpcre -lpthread -lz -lselinux -lresolv'

# Names of additional weak libraries provided by this library
weak_library_names=''

# Version information for libgio-2.0.
current=4800
age=4800
revision=1

# Is this an already installed library?
installed=yes

# Should we warn about portability when linking against -modules?
shouldnotlink=no

# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''

# Directory that this library needs to be installed in:
libdir='/lib'`

Contributor

robert-ancell commented Jul 19, 2016

The above file shows a generated .la file with the absolute /lib paths that don't work.

Contributor

robert-ancell commented Jul 19, 2016

Didier pointed out this can be achieved using:

parts:
  stage: [ -*.la ]
  snap: [ -*.la ]

However this PR is probably still worth considering as this is tedious to add everywhere and it's unlikely the .la files will be useful / work anyway.

Contributor

robert-ancell commented Jul 19, 2016

Actually, now I'm not sure that the stage filter is working..

snapcraft/plugins/autotools.py
@@ -117,3 +118,6 @@ def build(self):
self.run(configure_command + self.options.configflags)
self.run(['make', '-j{}'.format(self.project.parallel_build_count)])
self.run(make_install_command)
+
+ # Remove .la files which don't work when they are moved around
+ subprocess.check_call("find . -name '*.la' | xargs rm", shell=True, cwd=self.installdir)
@sergiusens

sergiusens Jul 20, 2016

Collaborator

can you change this to use os.walk please?

robert-ancell added some commits Jul 20, 2016

Collaborator

sergiusens commented Aug 3, 2016

ok to test

Collaborator

sergiusens commented Aug 10, 2016

@robert-ancell so bad luck:

snapcraft/plugins/autotools.py:92:1: C901 'AutotoolsPlugin.build' is too complex (11)
Collaborator

sergiusens commented Aug 10, 2016

maybe just separate the new code into a helper method of the class or private method of the module or in snapcraft.internal.common

AutotoolsPlugin._remove_la()
autotools._remove_la(directory)
snapcraft.internal.common.remove_files(base_directory, patterns)

robert-ancell added some commits Aug 17, 2016

Collaborator

sergiusens commented Aug 18, 2016

snapcraft/plugins/autotools.py:128:30: E211 whitespace before '('

Collaborator

sergiusens commented Aug 18, 2016

retest this please

@sergiusens sergiusens merged commit 5e864d6 into snapcore:master Aug 18, 2016

3 of 4 checks passed

coverage/coveralls Coverage decreased (-0.02%) to 97.457%
Details
autopkgtest integration Success
Details
autopkgtest snaps Success
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@robert-ancell robert-ancell deleted the robert-ancell:no-la-files branch Mar 28, 2017

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment