<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">Wiadomość napisana przez Joseph Rushton Wakeling <<a href="mailto:joseph.wakeling@webdrake.net" class="">joseph.wakeling@webdrake.net</a>> w dniu 27.08.2016, o godz. 22:45:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello all,<br class=""><br class="">I thought I'd have a go at making a snap of LDC, the LLVM-based compiler for the D programming language.  I recognize that snapping a compiler might be jumping ahead of the current intended use-case(s), but it's fun to see what could be possible -- and besides, D's compilers are updated fairly often, so it would be great to be able to package them easily in a truly cross-distro form.<br class=""><br class="">It's been very exciting to see how straightforward most things are to get set up, but I ran into a few issues that are blockers to finalizing the snap, so I thought I'd ask here for advice on how to address them.<br class=""><br class="">First things first: LDC is built using cmake, and getting the essentials of the `snapcraft.yaml` file set up was super-simple:<br class=""><br class="">-----------------------------------------<br class="">name: ldc<br class="">version: "1.0.0"<br class="">summary: D compiler with LLVM backend<br class="">description: LDC is a compiler for the D programming Language.<br class="">             It is based on the latest DMD frontend and uses LLVM as backend.<br class="">confinement: devmode<br class=""><br class="">apps:<br class="">  ldc2:<br class="">    command: ldc2<br class="">    plugs: [home]<br class="">  ldmd2:<br class="">    command: ldmd2<br class="">    plugs: [home]<br class=""><br class="">parts:<br class="">  ldc:<br class="">    plugin: cmake<br class="">    source: <a href="git://github.com/ldc-developers/ldc.git" class="">git://github.com/ldc-developers/ldc.git</a><br class="">    source-tag: v1.0.0<br class="">    build-packages:<br class="">    - ldc<br class="">    - llvm-dev<br class="">    - libconfig++-dev<br class="">    - libcurl4-gnutls-dev<br class="">    - libedit-dev<br class="">    - zlib1g-dev<br class="">-----------------------------------------<br class=""><br class="">This happily builds and generates a snap, and so far as I can tell from the install, all the usual required files are there.  (By the way, I really do mean to have ldc in the `build-packages`; LDC now requires a D compiler to build it, so it's necessary to have the older ubuntu-packaged ldc 0.17.1 to build with.)<br class=""><br class="">The problems with the snap are threefold:<br class=""><br class="">  * LDC creates two different executables, ldc2 and ldmd2 (the latter is a<br class="">    wrapper that implements compiler flags to match D's reference compiler,<br class="">    "Digital Mars D" or dmd).  However, the names given to the snap executables<br class="">    are ldc.ldc2 and ldc.ldmd2.  While I understand the wish to namespace, is<br class="">    there any way to drop the `ldc.` prefix ... ?<br class=""><br class="">  * LDC creates a config file, `/etc/ldc2.conf`, using libconfig.  This defines<br class="">    some default compiler flags, including the default 'include' location of<br class="">    header files for the runtime and standard library.  However, perhaps because<br class="">    of how the snap is built, the include paths are specified as if the snap's<br class="">    install dir was the root:<br class=""><br class="">        switches = [<br class="">            "-I/include/d/ldc",<br class="">            "-I/include/d",<br class="">            "-L-L/lib",<br class="">            "-defaultlib=phobos2-ldc,druntime-ldc",<br class="">            "-debuglib=phobos2-ldc-debug,druntime-ldc-debug"<br class="">        ];<br class=""><br class="">    This means that when one tries to compile anything, the compiler emits<br class="">    error messages that it is unable to locate the headers for runtime or<br class="">    standard-library modules.  If one manually specifies the full-path<br class="">    include locations:<br class=""><br class="">        -I/snap/ldc/current/include/d/ldc -I/snap/ldc/current/include/d<br class=""><br class="">    ... then the compiler can build an object file, but runs into the third<br class="">    of the problems ...<br class=""><br class="">  * LDC uses the default C compiler for linking, but the snap-installed<br class="">    compiler fails to find it, exiting with a message:<br class=""><br class="">        Error: failed to locate gcc<br class=""></div></div></blockquote><div><br class=""></div><div><br class=""></div>You can try to „see” gcc via /var/lib/snapd/hostfs/usr/bin/gcc but I bet it won’t „just work” because we are now in a chroot [1]. You could try to put gcc inside your own snap (I would actually do this to stay fully self-contained) but that might require different work to snap.</div><div><br class=""></div><div>Given enough permissions you could get out of the chroot and run host’s gcc with appropriate arguments but you might run into issues with passing files around by path (see the referenced link for details). If you only use -pipe then things should work.</div><div><br class=""></div><div>We also have snapd-xdg-open and I was wondering if it would be okay to extend it to do things like „run this command on the host with the permission of the current user” if the command can be white-listed to belong to an interface (e.g. you we could say that LDC has permissions to run „gcc” with any arguments).</div><div><br class=""></div><div>[1] <a href="http://www.zygoon.pl/2016/08/snap-execution-environment.html" class="">http://www.zygoon.pl/2016/08/snap-execution-environment.html</a></div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">Can anyone advise on how best to address any of these problems?  I would assume the last in particular is down to the lack of an interface for access to things like a linker or other aspects of a build system?<br class=""><br class="">I'm really delighted with how blissfully simple it was to get the essentials of packaging in place, and it would be really great if there were straightforward solutions to the remaining issues.<br class=""><br class="">Thanks in advance for any advice, and best wishes,<br class=""><br class="">    -- Joe<br class=""><br class="">-- <br class="">Snapcraft mailing list<br class=""><a href="mailto:Snapcraft@lists.snapcraft.io" class="">Snapcraft@lists.snapcraft.io</a><br class="">Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/snapcraft<br class=""></div></div></blockquote></div><br class=""></body></html>