bitey w/ dragonegg for fortran code?

57 views
Skip to first unread message

Jeff Zitelli

unread,
Jan 18, 2013, 7:18:05 PM1/18/13
to bi...@googlegroups.com
Hi, I'm wondering if it is possible to use the dragonegg gcc plugin to compile fortran to llvm bitcode (instead of clang for c), and use bitey from there in the usual way?  Any obvious pitfalls or reasons why this would not work in principle?  Thank you! - jz

David Beazley

unread,
Jan 18, 2013, 9:03:50 PM1/18/13
to bi...@googlegroups.com, David Beazley
In principle, I can't see why it wouldn't work.   It might need some tweaking, but it would be an interesting experiment.

Just as aside, I'm hoping I can get back to some bitey work (after PyCon).   I've just been completely buried in work related to the 3rd edition update of the O'Reilly Cookbook.   I did manage to sneak a short LLVM example into the book under the radar though ;-).

Cheers,
Dave


On Jan 18, 2013, at 6:18 PM, Jeff Zitelli wrote:

Hi, I'm wondering if it is possible to use the dragonegg gcc plugin to compile fortran to llvm bitcode (instead of clang for c), and use bitey from there in the usual way?  Any obvious pitfalls or reasons why this would not work in principle?  Thank you! - jz


--
You received this message because you are subscribed to the Google Groups "bitey" group.
To unsubscribe from this group, send email to bitey+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeff Zitelli

unread,
Jan 18, 2013, 11:15:25 PM1/18/13
to bi...@googlegroups.com, David Beazley
Well I've already had some success... I compiled a simple integer add subroutine with gcc 4.6, llvm 3.1, dragonegg 3.1 with the following:

add.F90:
subroutine add(a, b, c) bind(c)
  implicit none
  integer, intent(in) :: a, b
  integer, intent(out) :: c
  c = a + b
end subroutine add

After some trial and error, the following command lines seemed to do what was needed:
gcc add.F90 -S -fplugin=dragonegg.so -flto
then invoked the llvm assembler:
llvm-as add.s -o add.o

My test run:

Python 2.7.3 |AnacondaCE 1.2.1 (64-bit)| (default, Nov 20 2012, 22:17:44)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import ctypes
In [2]: import bitey
In [3]: import add
In [4]: a = ctypes.c_int(1); b = ctypes.c_int(2); c = ctypes.c_int(0)
In [5]: add.add(a,b,c)
In [6]: c
Out[6]: c_int(3)

So far it looks good, the only issue I noticed once I produced the .o correctly is that an underscore is appended to the function name if you neglect the 2003 fortran bind(c) attribute.
- jz
Reply all
Reply to author
Forward
0 new messages