Dynamically loading custom passes with gollvm?

120 views
Skip to first unread message

Balamurugan Marimuthu

unread,
Apr 9, 2022, 11:28:09 PM4/9/22
to golang-nuts
Hi there,

I see I can invoke the following and see the steps 'go build' is doing.

% go build -work -x mypackage.go 1> transcript.txt 2>&1

I struggle to understand how can I load my custom pass created as a shared library?

I was looking for something like this which is done with Clang:
clang -Xclang -load -Xclang build/skeleton/libSkeletonPass.* something.c

Is my understanding correct? Any help/pointers will be really helpful. 
Thanks! 

Ian Lance Taylor

unread,
Apr 10, 2022, 12:14:34 AM4/10/22
to Balamurugan Marimuthu, golang-nuts
Perhaps you are looking for something like

go build -gccgoflags="-Xclang -load -Xclang
build/skeleton/libSkeletonPass.*"

Ian

Balamurugan Marimuthu

unread,
Apr 10, 2022, 3:45:34 PM4/10/22
to golang-nuts
Yes, something like that! I basically want to run my custom pass as I compile using 'go build'

 But looks like llvm-goc doesn't support the -Xclang option

$ go build -gccgoflags="-Xclang -load -Xclang ../passes/FunctionInsertPass.so" cache_main.go
# command-line-arguments
/gollvm/install/bin/llvm-goc: error: unrecognized command line option '-Xclang'
/gollvm/install/bin/llvm-goc: error: unrecognized command line option '-Xclang'

Is there a way to load my custom pass as part of 'go build'?

Thanks!

Than McIntosh

unread,
Apr 11, 2022, 2:50:58 PM4/11/22
to Balamurugan Marimuthu, golang-nuts
Hello,

At the moment gollvm doesn't support anything like the "-Xclang -load -Xclang ...". 

It would not be too hard to add this though. Want to send a patch?

Thanks, Than


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9a976aca-4c5d-4074-a19d-f843e8b5ca63n%40googlegroups.com.

Than McIntosh

unread,
Apr 12, 2022, 7:07:05 AM4/12/22
to Balamurugan M, golang-nuts
>>>>It would not be too hard to add this though. Want to send a patch?
>>>>
>>Ohh! Yes please, that'll be very helpful for our experiments.
>>Thank you so much.

I think you misunderstood my comment. I was asking if you would like to send a patch yourself.

Thanks, Than



On Mon, Apr 11, 2022 at 10:02 PM Balamurugan M <bala...@gmail.com> wrote:
Hi!

Ohh! Yes please, that'll be very helpful for our experiments.
Thank you so much.

Regards
Reply all
Reply to author
Forward
Message has been deleted
0 new messages