unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* How to make a working ld in guix pure environment?
@ 2018-05-24 18:14 Fis Trivial
  2018-05-24 20:38 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Fis Trivial @ 2018-05-24 18:14 UTC (permalink / raw)
  To: help-guix


Hi, I'm working to get OpenCL into guix. In the OpenCL world, source
code for devices (such as GPU or FPGA or just CPU) is shipped as string
and embeded in the binary object, then latter compiled by OpenCL
implementation at runtime.

So, a correct linker at runtime is necessary for runing OpenCL
program, but I don't know how to achieve it.

I tried to use ld in guix pure environment, tested with bintuils,
gcc-toolchain, ld-wrapper, and none of them work.

Take the following trivial snippy (not opencl related) as an example:

// main.c
#include <math.h>

int main()
{
  log1p(32);
}


To build it, one would do something similar to `ld -lm main.o` after
compilation. But I got an error saying "ld: cannot find -lm".

I have a little chat with @lfam at IRC (thanks:) ). In order to clear
one of the confusions, please know that ld needed to be used standalone,
not with gcc-toolchain, since it's needed at target program runtime.

Please give me some advices about making a correct ld.

Thanks in advance.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to make a working ld in guix pure environment?
  2018-05-24 18:14 How to make a working ld in guix pure environment? Fis Trivial
@ 2018-05-24 20:38 ` Ludovic Courtès
  2018-05-25  8:48   ` Fis Trivial
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2018-05-24 20:38 UTC (permalink / raw)
  To: Fis Trivial; +Cc: help-guix

Hello,

Fis Trivial <ybbs.daans@hotmail.com> skribis:

> I tried to use ld in guix pure environment, tested with bintuils,
> gcc-toolchain, ld-wrapper, and none of them work.
>
> Take the following trivial snippy (not opencl related) as an example:
>
> // main.c
> #include <math.h>
>
> int main()
> {
>   log1p(32);
> }
>
>
> To build it, one would do something similar to `ld -lm main.o` after
> compilation. But I got an error saying "ld: cannot find -lm".

You would need to use ld-wrapper, not ld, so that ld-wrapper sets the
RUNPATH appropriately.

But this won’t fix the problem above.  The problem above is that glibc
is not in the search path.  To fix that, a simple fix would be to add a
wrapper atop ld-wrapper (!) that would add “-L /gnu/store/…-glibc/lib”.

Perhaps there are more elegant ways to achieve it though.  How is ld
invoked?  Would it work to add that -L flag directly in the code that
invokes ld?

HTH!

Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to make a working ld in guix pure environment?
  2018-05-24 20:38 ` Ludovic Courtès
@ 2018-05-25  8:48   ` Fis Trivial
  0 siblings, 0 replies; 3+ messages in thread
From: Fis Trivial @ 2018-05-25  8:48 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix, Fis Trivial


Ludovic Courtès writes:

> Hello,
>
> Fis Trivial <ybbs.daans@hotmail.com> skribis:
>
>> I tried to use ld in guix pure environment, tested with bintuils,
>> gcc-toolchain, ld-wrapper, and none of them work.
>>
>> Take the following trivial snippy (not opencl related) as an example:
>>
>> // main.c
>> #include <math.h>
>>
>> int main()
>> {
>>   log1p(32);
>> }
>>
>>
>> To build it, one would do something similar to `ld -lm main.o` after
>> compilation. But I got an error saying "ld: cannot find -lm".
>
> You would need to use ld-wrapper, not ld, so that ld-wrapper sets the
> RUNPATH appropriately.
>
> But this won’t fix the problem above.  The problem above is that glibc
> is not in the search path.  To fix that, a simple fix would be to add a
> wrapper atop ld-wrapper (!) that would add “-L /gnu/store/…-glibc/lib”.
>
> Perhaps there are more elegant ways to achieve it though.  How is ld
> invoked?  Would it work to add that -L flag directly in the code that
> invokes ld?
>

That would require me to look into OpenCL's
implementations. Heterogeneous is interesting to me, I guess it would be
a fun thing to do. I will try to hack it once I got the time, unless
someone else beat me to it.

> HTH!
>
> Ludo’.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-25  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-24 18:14 How to make a working ld in guix pure environment? Fis Trivial
2018-05-24 20:38 ` Ludovic Courtès
2018-05-25  8:48   ` Fis Trivial

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).