On 01.09.2016 23:18, Sergio Schvezov wrote:


El 01/09/16 a las 18:06, Joseph Rushton Wakeling escribió:
On 31.08.2016 21:35, Joseph Rushton Wakeling wrote:
First things first, run `snapcraft stage`.  Then edit the auto-generated
stage/etc/ldc2.conf and replace it with this:
https://gist.github.com/WebDrake/229645efeca14fa54b0b1c82bcbb6477

... which as you can see includes a compiler flag: `-gcc=ldc2.gcc`.  This should
ensure that ldc2.gcc is called when LDC wants to call GCC.

OK, I think I have tied down why this is failing.

Under the hood, LDC does a lookup of the full path to the executable whose
name is passed via the -gcc flag, using llvm::sys::findProgramByName to do
so.  If it doesn't get a result, it first tries to look up CC, and if that
fails, it reverts to looking up the path for gcc.

This would suggest that, running within the snap, LDC is not able to find the
path to ldc2.gcc.

I've also tried passing it -gcc=%%ldcbinarypath%%/../command-gcc.wrapper and
also -gcc=/snap/ldc2/x1/command-gcc.wrapper and in both cases it still fails.

Actually, turns out I was completely wrong in the comments above: putting

    -gcc=%%ldcbinarypath%%/../command-gcc.wrapper

... _does_ work; it was failing because I'd manually included an extra -gcc= flag in the snapcraft.yaml for the ldc2 and ldmd2 commands. With that fixed, all is good.

But that brings us to ...

Please don't use the wrapper :-)

Well, I didn't _want_ to; it was something I tried as an experiment to see what would happen, and it's the first setup that has worked.

BTW what is problematic about using that wrapper in this way? Just to make sure I understand.

Any reason why you don't just set it to gcc? If gcc is inside the snap, it
should be in the PATH. To experiment simply run:

Yea, the problem is not gcc being in the path, but the --sysroot of gcc being correct. With the default gcc being called, the LDC build process falls over something like this (LDC's verbose output of its gcc call):

/snap/ldc2/x1/usr/bin/gcc hello.o -o hello -L/snap/ldc2/x1/bin/../lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -lrt -ldl -lpthread -lm -m64 /snap/ldc2/x1/usr/bin/ld: cannot find /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a
collect2: error: ld returned 1 exit status
Error: /snap/ldc2/x1/usr/bin/gcc failed with status: 1

So, gcc needs to be wrapped with something that adds the --sysroot=$SNAP option.

I'll try now to create such a minimal wrapper.

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

Reply via email to