Re: Classic confinement and core_dynamic_linker

2017-01-18 Thread Joseph Rushton Wakeling

On 18/01/17 13:12, Sergio Schvezov wrote:

After a quick but thorough conversation with Gustavo we agreed that this is the 
wrong path to take as it might not be deterministic or people might get 
surprised about things included that shouldn't have been.

There needs to be a clear line between `build-packages` and `stage-packages`. 
With that in mind snapcraft (even for `strict` snaps) will still crawl all the 
libraries and error on missing ones with a list of those that are missing. This 
should be something one can disable and set to ignore as some of the missing 
libraries might be provided by a content interface slot from another snap.


Well, I'm glad that my question may have led to a more rigorous and consistent 
definition of desired snapcraft behaviour, even if it means a slightly longer 
snapcraft.yaml ... :-)


--
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-18 Thread Joseph Rushton Wakeling

On 18/01/17 02:21, Sergio Schvezov wrote:

The logic is still run, but the resulting binary in classic uses rpath and no 
dynamic loading so there is no resolution to a on-system library we can pick 
up. I guess we can do some magic, but it feels it might be either fragile or 
make the build process a lot slower. We will need to look into it, but not 
short term.


OK -- thanks for the explanation.  Completely understand the preference to 
require explicit staging of packages over potentially fragile automation.


Anyway, I had a go at tweaking my snap package as defined here:
https://github.com/WebDrake/ldc2.snap/pull/1/files
https://github.com/WebDrake/ldc2.snap/blob/a437ec17d50bdd767febebf5b617d7d3a716716b/snapcraft.yaml

... to use `classic` confinement and staging packages necessary for linking. 
I've posted the resulting `snapcraft.yaml` below.  The major diff apart from the 
`confinement` setting is the addition of these lines to the `ldc` part of the file:


stage-packages:
- libconfig++-dev
- libphobos2-ldc-dev

When I run `snapcraft build`, however, everything builds and links fine, but 
_nothing_ gets staged (the `stage/` and `prime/` directories both remain empty). 
 I've tried the same thing while removing the `gcc`, `gcc-wrapper`, `libc6` and 
`libc6-dev` parts, with the same result.


Any thoughts on what could be the problem here?


--- snapcraft.yaml --

name: ldc2
version: "1.1.0-beta6"
summary: D compiler with LLVM backend
description: |
LDC is a portable compiler for the D programming Language, with
modern optimization and code generation capabilities.  It uses
the official DMD compiler frontend to support the latest version
of D2, and uses the LLVM Core libraries for code generation.
confinement: classic
grade: devel

apps:
  ldc2:
command: ldc2
plugs: [home]
  ldmd2:
command: ldmd2
plugs: [home]
  ldc-profdata:
command: ldc-profdata
plugs: [home]

parts:
  ldc:
source: git://github.com/ldc-developers/ldc.git
source-tag: v1.1.0-beta6
plugin: cmake
stage:
- -etc/ldc2.conf
build-packages:
- build-essential
- ldc
- llvm-dev
- libconfig++-dev
- libedit-dev
- zlib1g-dev
stage-packages:
- libconfig++-dev
- libphobos2-ldc-dev
  ldc-config:
plugin: dump
source: ldc-config
organize:
  ldc2.conf: etc/ldc2.conf

  gcc:
plugin: nil
stage-packages: [gcc]
organize:
  usr/bin/gcc: usr/bin/gcc.real
  gcc-wrapper:
plugin: dump
source: gcc-wrapper
organize:
  gcc.wrapper: usr/bin/gcc
  libc6:
plugin: nil
stage-packages: [libc6]
  libc6-dev:
plugin: nil
stage-packages: [libc6-dev]

--
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-18 Thread Sergio Schvezov
On Tue, 17 Jan 2017 23:17:27 +0100, Joseph Rushton Wakeling wrote:
> On 17/01/17 22:22, Sergio Schvezov wrote:
> >
>  
>
> Is that a work in progress constraint, or is it the intended long term 
> behaviour?  (I'll try it out shortly in any case.)
>
> I ask because currently, if a package is explicitly stated as a build 
> dependency, then with `strict` confinement it's automatically 
> included in the 
> final snap where necessary.  What makes `classic` confinement unable to 
> automatically handle the inclusion of build dependencies in the same way?

After a quick but thorough conversation with Gustavo we agreed that this is the 
wrong path to take as it might not be deterministic or people might get 
surprised about things included that shouldn't have been.

There needs to be a clear line between `build-packages` and `stage-packages`. 
With that in mind snapcraft (even for `strict` snaps) will still crawl all the 
libraries and error on missing ones with a list of those that are missing. This 
should be something one can disable and set to ignore as some of the missing 
libraries might be provided by a content interface slot from another snap.

-- 
Sent using Dekko from my Ubuntu device

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-18 Thread Sergio Schvezov
On Wed, 18 Jan 2017 08:58:00 -0200, Gustavo Niemeyer wrote:
> Hi Sergio,
>
> The question asked was actually how to get snapcraft to include
> dependencies *inside the snap* so that it works as it does with strict
> snaps, bundling the dependencies.
>
> Your response was about system libraries rather than bundled
> in-snap libraries, I believe.
>
> This should definitely work fine, right?

Yes, there is a gotcha though wrt the question asked. Using `build-packages`, 
which install on the host -the usual `-dev` ones- means that the libraries they 
bring in need to be added as `stage-packages`. We added an optimization here 
where we crawl all elf files in `prime` and `ldd` them to see if anything would 
resolve outside the snap and bring those libraries in. This is not as easy with 
classic confinement as all those elf files are runpathed. I have slept on it 
though and think there is a way to do it, but it won't be as straightforward.

-- 
Sent using Dekko from my Ubuntu device

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-18 Thread Gustavo Niemeyer
Hi Sergio,

The question asked was actually how to get snapcraft to include
dependencies *inside the snap* so that it works as it does with strict
snaps, bundling the dependencies.

Your response was about system libraries rather than bundled
in-snap libraries, I believe.

This should definitely work fine, right?



On Tue, Jan 17, 2017 at 11:21 PM, Sergio Schvezov <
sergio.schve...@canonical.com> wrote:

> On Tue, 17 Jan 2017 23:17:27 +0100, Joseph Rushton Wakeling wrote:
> > On 17/01/17 22:22, Sergio Schvezov wrote:
> 
> 
> >
> >
> > Is that a work in progress constraint, or is it the intended long term
> > behaviour?  (I'll try it out shortly in any case.)
> >
> > I ask because currently, if a package is explicitly stated as a build
> > dependency, then with `strict` confinement it's automatically
> > included in the
> > final snap where necessary.  What makes `classic` confinement unable to
> > automatically handle the inclusion of build dependencies in the same way?
>
> The logic is still run, but the resulting binary in classic uses rpath and
> no dynamic loading so there is no resolution to a on-system library we can
> pick up. I guess we can do some magic, but it feels it might be either
> fragile or make the build process a lot slower. We will need to look into
> it, but not short term.
>
> --
> Sent using Dekko from my Ubuntu device
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>



-- 

gustavo @ http://niemeyer.net
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-17 Thread Joseph Rushton Wakeling

On 17/01/17 22:22, Sergio Schvezov wrote:

For classic confined snaps to link, they either need to be part of core or 
staged into your snap. On system libraries are ignored completely to ensure you 
have a working snap in the end.


Is that a work in progress constraint, or is it the intended long term 
behaviour?  (I'll try it out shortly in any case.)


I ask because currently, if a package is explicitly stated as a build 
dependency, then with `strict` confinement it's automatically included in the 
final snap where necessary.  What makes `classic` confinement unable to 
automatically handle the inclusion of build dependencies in the same way?


--
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-17 Thread Sergio Schvezov
On Tue, 17 Jan 2017 22:11:57 +0100, Joseph Rushton Wakeling wrote:
> On 14/01/17 03:26, Sergio Schvezov wrote:
>> A generic solution for build systems and CI is being worked on.
>>
>> Thanks for taking notice.
>
> Ah, OK, thanks.  Please do ping me if there is work-in-progress 
> I can help to 
> test.  I'd be happy to help out if I can.
>
> Can you shed light on the reason for the linker errors I get when trying to 
> build a `classic` snap using regular `snapcraft build`?  See:
> https://lists.ubuntu.com/archives/snapcraft/2017-January/002483.html
>
> ... for details.  Do I assume right here that the problem is 
> along the lines 
> that the libraries concerned are not part of the core snap, and 
> therefore the 
> core_dynamic_linker cannot access them, even though they are 
> installed on my 
> machine via apt?

For classic confined snaps to link, they either need to be part of core or 
staged into your snap. On system libraries are ignored completely to ensure you 
have a working snap in the end.

The `core_dynamic_linker` error  message has been improved in 2.25 which is 
making its way into the -updates' pockets for the current supported series in 
Ubuntu.

-- 
Sent using Dekko from my Ubuntu device

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-13 Thread Sergio Schvezov
El 13 ene. 2017 10:47 PM, "Joseph Rushton Wakeling" <
joseph.wakel...@webdrake.net> escribió:

Hello all,

Hearing about classic confinement was rather exciting given that it seems
tailor-made for the use-cases of my current WiP snaps for the ldc2 D
compiler and the dub D build system:
https://github.com/WebDrake/ldc2.snap/pull/1
https://github.com/WebDrake/dub.snap/pull/1

However, I'm running into difficulties every time I try to do a `snapcraft
cleanbuild`: part-way through the build process I invariably get an error:

classic confinement requires the core_dynamic_linker to be set

I've discovered and tried the proposed workaround here:
https://bugs.launchpad.net/snapcraft/+bug/1650946/comments/11

... but it seems to make no difference.  Can anyone advise what else needs
to be done to build a package with `classic` confinement?


A generic solution for build systems and CI is being worked on.

Thanks for taking notice.
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: Classic confinement and core_dynamic_linker

2017-01-13 Thread Joseph Rushton Wakeling

On 13/01/17 23:18, Kyle Fazzari wrote:

Since you're using cleanbuild, you would actually need the core snap
installed in the lxc container being used, which I don't think is
currently possible in lxc (though maybe it is nowadays, I know work was
being done in that area).

Have you tried _not_ doing this in cleanbuild, on a system with the core
snap installed?


Ah, thanks.  I did consider that but thought it would be a bit odd for a new 
feature to come without a cleanbuild of it being possible.


Anyway, doing a regular `snapcraft build` means the `core_dynamic_linker` error 
vanishes, but this time I get linker errors when building LDC:


   error while loading shared libraries: libconfig.so.9: cannot open shared
   object file: No such file or directory

`libconfig++-dev` and `libconfig-dev` are both installed along with their 
dependencies (libconfig++-dev is specified as a build dependency), and I _don't_ 
get this linker error when confinement is set to `strict`.


--
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Classic confinement and core_dynamic_linker

2017-01-13 Thread Joseph Rushton Wakeling

Hello all,

Hearing about classic confinement was rather exciting given that it seems 
tailor-made for the use-cases of my current WiP snaps for the ldc2 D compiler 
and the dub D build system:

https://github.com/WebDrake/ldc2.snap/pull/1
https://github.com/WebDrake/dub.snap/pull/1

However, I'm running into difficulties every time I try to do a `snapcraft 
cleanbuild`: part-way through the build process I invariably get an error:


classic confinement requires the core_dynamic_linker to be set

I've discovered and tried the proposed workaround here:
https://bugs.launchpad.net/snapcraft/+bug/1650946/comments/11

... but it seems to make no difference.  Can anyone advise what else needs to be 
done to build a package with `classic` confinement?


My system is Ubuntu 16.04 with snapcraft 2.24 and snapd 2.20.1 (both installed 
from the normal Ubuntu apt repos).


Thanks & best wishes,

-- Joe

--
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft