getting $LDFLAGS for a classic snap build in the plugin

Sergio Schvezov sergio.schvezov at canonical.com
Sun Mar 5 22:24:05 UTC 2017


On Mon, 6 Mar 2017 10:05:07 +1300, Michael Hudson-Doyle wrote:
> On 6 March 2017 at 02:48, Sergio Schvezov <sergio.schvezov at canonical.com>
> wrote:
>
>> On Tue, Feb 28, 2017 at 6:11 PM, Michael Hudson-Doyle <
>> michael.hudson at canonical.com> wrote:
>>
>>> Hi,
>>>
>>> The magic of classic confinement snaps is all in passing special flags
>>> when linking an executable. If I've read things right, 
>>> snapcraft does this
>>> by wrapping any command you execute with BasePlugin.run() with some shell
>>> code that sets LDFLAGS.
>>>
>>> Unfortunately, for the go classic snap the underlying tool does not care
>>> at all about LDFLAGS. What I do is create a wrapper:
>>>
>>> #!/bin/sh
>>> exec gcc $LDFLAGS "$@"
>>>
>>> and point the go tool at that. This works but it would be a lot cleaner
>>> if I could just get at the linker flags in my snap's plugin. Any chance
>>> that could be added?
>>>
>>
>> Hi there, I am sort of confused by the wording here, can you expand a bit
>> on what you want. When you say "snap's plugin", what do you mean?
>>
>> I fear I am being dull but I honestly don't understand the question and
>> given that it has gone unanswered for a couple of days maybe others are
>> having issues parsing this as well (or maybe discussed on IRC and already
>> taken care of).
>>
>
>
> My snap uses a custom plugin to build, so by "my snap's plugin" I mean
> https://git.launchpad.net/~mwhudson/+git/gosnap/tree/snap/plugins/x_gobuild.py?h=go1.8.
> In that code, I want to access the flags that need to be passed to the
> linker to make classic snaps link against the core snap rather than the
> usual path (-Wl,-z,nodefib, -Wl,-rpath,xxx, etc). Currently, as I read
> things, it can't (well not without very silly hacks).

We can certainly add support for this. Please log me a bug and I'll get to it.

-- 
Sent using Dekko from my Ubuntu device




More information about the Snapcraft mailing list