Independent LLVM IR

141 views
Skip to first unread message

Arpit Aggarwal

unread,
Jun 29, 2017, 1:11:32 PM6/29/17
to llgo-dev
Hi everyone,

I generated an llvm-IR for a simple go program consisting of channels.
When I saw the IR, it was containing only declarations for functions like makechan()
chan_big_send() and not definitions which I found in llgo's code in the libgo's runtime directory.

Is it possible that I can generate LLVM IR for the go program which consists of the definitions of these functions too?
Is it possible to generate the IR which contains all the definitions of the functions declared in itself

If this feature (or any form) is already available it would be very helpful for my project.

Thanks in advance!
Any help would be really appreciated.

Regards
Arpit

Andrew Wilkins

unread,
Jun 29, 2017, 7:06:09 PM6/29/17
to llgo...@googlegroups.com
On Fri, 30 Jun 2017 at 03:11 Arpit Aggarwal <arpit9...@gmail.com> wrote:
Hi everyone,

I generated an llvm-IR for a simple go program consisting of channels.
When I saw the IR, it was containing only declarations for functions like makechan()
chan_big_send() and not definitions which I found in llgo's code in the libgo's runtime directory.

Is it possible that I can generate LLVM IR for the go program which consists of the definitions of these functions too?
Is it possible to generate the IR which contains all the definitions of the functions declared in itself

It's *feasible* to compile the runtime and merge it all into a single bitcode module, but it is not something that the llgo build system supports now, nor is it likely to in the future. What's the use case?
 
If this feature (or any form) is already available it would be very helpful for my project.

Thanks in advance!
Any help would be really appreciated.

Regards
Arpit

--
You received this message because you are subscribed to the Google Groups "llgo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to llgo-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arpit Aggarwal

unread,
Jun 30, 2017, 4:15:45 AM6/30/17
to llgo-dev
Hi Andrew,





On Friday, June 30, 2017 at 4:36:09 AM UTC+5:30, Andrew Wilkins wrote:
On Fri, 30 Jun 2017 at 03:11 Arpit Aggarwal <arpit9...@gmail.com> wrote:
Hi everyone,

I generated an llvm-IR for a simple go program consisting of channels.
When I saw the IR, it was containing only declarations for functions like makechan()
chan_big_send() and not definitions which I found in llgo's code in the libgo's runtime directory.

Is it possible that I can generate LLVM IR for the go program which consists of the definitions of these functions too?
Is it possible to generate the IR which contains all the definitions of the functions declared in itself

It's *feasible* to compile the runtime and merge it all into a single bitcode module, but it is not something that the llgo build system supports now, nor is it likely to in the future. What's the use case?

My project takes the IR and converts it to another format used in some existing software for C++.
If the independent IR was available, it would have been easier for my project to do the conversion.

Can you tell me the procedure to compile the runtime and merge it all into single bitcode moudule.
That would be very helpful.

Thanks in advance.

Regards
Arpit
 

Arpit Aggarwal

unread,
Jul 1, 2017, 8:16:05 AM7/1/17
to llgo-dev
Hi Andrew,
When I tried to generate IR for proc.c using clang, I got an error for config.h not found.
Can you please help in this matter.

Also, I had a question about this approach of generating a bitcode for runtime. Using this way I have to feed runtime bitcode to the tool I am creating independent of whether the Go program contains channels or not. So it would be better if this was implemented somehow through llgo to generate bitcode for only that part which was required/used in Go program.

If you can guide me, I would like to help to add this feature to llgo.

Thanks
Arpit



On Friday, June 30, 2017 at 4:36:09 AM UTC+5:30, Andrew Wilkins wrote:

Andrew Wilkins

unread,
Jul 2, 2017, 11:29:50 PM7/2/17
to llgo...@googlegroups.com
On Sat, 1 Jul 2017 at 20:16 Arpit Aggarwal <arpit9...@gmail.com> wrote:
Hi Andrew,
When I tried to generate IR for proc.c using clang, I got an error for config.h not found.
Can you please help in this matter.

You cannot simply point clang at the source file. You'll need to set the appropriate compiler flags, the include paths in particular. Your best bet will be to modify the Makefiles or just pass the appropriate compiler flags to Make.
 
Also, I had a question about this approach of generating a bitcode for runtime. Using this way I have to feed runtime bitcode to the tool I am creating independent of whether the Go program contains channels or not. So it would be better if this was implemented somehow through llgo to generate bitcode for only that part which was required/used in Go program.

If you can guide me, I would like to help to add this feature to llgo.

One option that is in line with future goals is to weave in LTO support. There's already some support in cmd/gllgo for writing the bitcode for Go code to the object files. I'm not sure if Clang supports generating "fat" LTO objects, but if it does then you could update the compiler flags to pass to Clang, and then teach cmd/gllgo how to merge all of the modules together.

This is not something I am going to be able to help you with. I just do not have the time.

Cheers,
Andrew

Arpit Aggarwal

unread,
Jul 3, 2017, 4:51:33 AM7/3/17
to llgo-dev
Thank you very much for your help Andrew.

Regards
Arpit

Arpit Aggarwal

unread,
Jul 6, 2017, 7:50:38 AM7/6/17
to llgo-dev
Hi Andrew,

I am unable to compile libgo inorder to generate the IR for runtime.
Is there any documentaion available or  any other things to find out what all parameters have to be set to compile the runtime.
I found about how to modify makefiles to generate bitcode but I always get stuck at an error while running the configure.

 ./../../config-ml.in: No such file or directory

Can you please tell me what all flags need to be set.
I also read all the previous conversations in this group but I am unable to compile it still
Thanks a lot in advance.

Thanks,
Arpit

Andrew Wilkins

unread,
Jul 6, 2017, 7:29:50 PM7/6/17
to llgo...@googlegroups.com
On Thu, 6 Jul 2017 at 19:50 Arpit Aggarwal <arpit9...@gmail.com> wrote:
Hi Andrew,

I am unable to compile libgo inorder to generate the IR for runtime.
Is there any documentaion available or  any other things to find out what all parameters have to be set to compile the runtime.
I found about how to modify makefiles to generate bitcode but I always get stuck at an error while running the configure.

 ./../../config-ml.in: No such file or directory

How are you trying to build the runtime? There is a CMake target ("libgo") that will build the runtime.
 
Can you please tell me what all flags need to be set.
I also read all the previous conversations in this group but I am unable to compile it still
Thanks a lot in advance.
 
Thanks,
Arpit


On Thursday, June 29, 2017 at 10:41:32 PM UTC+5:30, Arpit Aggarwal wrote:
Hi everyone,

I generated an llvm-IR for a simple go program consisting of channels.
When I saw the IR, it was containing only declarations for functions like makechan()
chan_big_send() and not definitions which I found in llgo's code in the libgo's runtime directory.

Is it possible that I can generate LLVM IR for the go program which consists of the definitions of these functions too?
Is it possible to generate the IR which contains all the definitions of the functions declared in itself

If this feature (or any form) is already available it would be very helpful for my project.

Thanks in advance!
Any help would be really appreciated.

Regards
Arpit

--

Arpit Aggarwal

unread,
Jul 7, 2017, 1:26:46 AM7/7/17
to llgo-dev
Hi Andrew,

I was directly using configure command with different flags and options.
Will try Cmake now.
Thanks for your help.

Regards,
Arpit
Reply all
Reply to author
Forward
0 new messages