Hello, Sorry for the late reply. Using dragonegg worked well, thanks all! Just as a note... I had to use llvm-ld during the link step because gfortran could not link bitcode. Here's an example of the error shown when using gfortran instead of llvm-ld: $ ${GCC_4_5_0}/bin/gfortran hw.f -c -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so -o hw.o -flto -emit-llvm -S $ ${LLVM_2_9}/bin/opt -mem2reg hw.o -o hw.o $ ${GCC_4_5_0}/bin/gfortran -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so ${GCC_4_5_0}/lib64/libgfortran.a hw.o -o hw hw.o: file not recognized: File format not recognized collect2: ld returned 1 exit status $ file hw.o hw.o: data Instead, using llvm-ld: $ ${LLVM_2_9}/bin/llvm-ld -native hw.o -o hw ${GCC_4_5_0}/lib64/libgfortran.a -lm llvm-gcc had the gold plugin. I wonder if there is any equivalent of that for dragonegg to be able to compile bitcode and native object code in a transparent manner. Thanks again! Ashay On Wed, Aug 31, 2011 at 4:29 PM, Anton Korobeynikov <anton at korobeynikov.info> wrote:> Hello > > > I am not very familiar with Fortran programs. I saw a few programs that > had > > a "MAIN" subroutine defined, some others that did not. Am I missing > > something while compiling the code? Is there a different way to compile > > bitcode (from Fortran programs) to a native binary? > For Fortran MAIN is indeed something similar to C main, but not > exactly the same. > You have to link the runtime library (libgfortran.a) in order to get > "proper" main, mak sure all stuff is initialized properly, etc. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110912/1395d7ce/attachment.html>
Ashay, If I understand correctly, in hw.o you would have llvm bytecode, while linker expects regular object binary. Probably first you need to emit asm out of bytecode using llc? - D. 2011/9/12 Ashay Rane <ashay.rane at tacc.utexas.edu>:> Hello, > Sorry for the late reply. Using dragonegg worked well, thanks all! > Just as a note... I had to use llvm-ld during the link step because gfortran > could not link bitcode. Here's an example of the error shown when using > gfortran instead of llvm-ld: > $ ${GCC_4_5_0}/bin/gfortran hw.f -c > -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so -o hw.o -flto -emit-llvm -S > $ ${LLVM_2_9}/bin/opt -mem2reg hw.o -o hw.o > $ ${GCC_4_5_0}/bin/gfortran > -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so ${GCC_4_5_0}/lib64/libgfortran.a > hw.o -o hw > hw.o: file not recognized: File format not recognized > collect2: ld returned 1 exit status > $ file hw.o > hw.o: data > Instead, using llvm-ld: > $ ${LLVM_2_9}/bin/llvm-ld -native hw.o -o hw > ${GCC_4_5_0}/lib64/libgfortran.a -lm > llvm-gcc had the gold plugin. I wonder if there is any equivalent of that > for dragonegg to be able to compile bitcode and native object code in a > transparent manner. > Thanks again! > Ashay > > On Wed, Aug 31, 2011 at 4:29 PM, Anton Korobeynikov > <anton at korobeynikov.info> wrote: >> >> Hello >> >> > I am not very familiar with Fortran programs. I saw a few programs that >> > had >> > a "MAIN" subroutine defined, some others that did not. Am I missing >> > something while compiling the code? Is there a different way to compile >> > bitcode (from Fortran programs) to a native binary? >> For Fortran MAIN is indeed something similar to C main, but not >> exactly the same. >> You have to link the runtime library (libgfortran.a) in order to get >> "proper" main, mak sure all stuff is initialized properly, etc. >> >> -- >> With best regards, Anton Korobeynikov >> Faculty of Mathematics and Mechanics, Saint Petersburg State University > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Thats correct. But using llc becomes a problem when I have archives (.a files). I could, in theory, extract its contents to a tempdir and then use llc and link but just wondering if there is a more elegant solution. Ashay On Mon, Sep 12, 2011 at 3:00 PM, Dmitry N. Mikushin <maemarcus at gmail.com>wrote:> Ashay, > > If I understand correctly, in hw.o you would have llvm bytecode, while > linker expects regular object binary. Probably first you need to emit > asm out of bytecode using llc? > > - D. > > 2011/9/12 Ashay Rane <ashay.rane at tacc.utexas.edu>: > > Hello, > > Sorry for the late reply. Using dragonegg worked well, thanks all! > > Just as a note... I had to use llvm-ld during the link step because > gfortran > > could not link bitcode. Here's an example of the error shown when using > > gfortran instead of llvm-ld: > > $ ${GCC_4_5_0}/bin/gfortran hw.f -c > > -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so -o hw.o -flto -emit-llvm -S > > $ ${LLVM_2_9}/bin/opt -mem2reg hw.o -o hw.o > > $ ${GCC_4_5_0}/bin/gfortran > > > -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so ${GCC_4_5_0}/lib64/libgfortran.a > > hw.o -o hw > > hw.o: file not recognized: File format not recognized > > collect2: ld returned 1 exit status > > $ file hw.o > > hw.o: data > > Instead, using llvm-ld: > > $ ${LLVM_2_9}/bin/llvm-ld -native hw.o -o hw > > ${GCC_4_5_0}/lib64/libgfortran.a -lm > > llvm-gcc had the gold plugin. I wonder if there is any equivalent of that > > for dragonegg to be able to compile bitcode and native object code in a > > transparent manner. > > Thanks again! > > Ashay > > > > On Wed, Aug 31, 2011 at 4:29 PM, Anton Korobeynikov > > <anton at korobeynikov.info> wrote: > >> > >> Hello > >> > >> > I am not very familiar with Fortran programs. I saw a few programs > that > >> > had > >> > a "MAIN" subroutine defined, some others that did not. Am I missing > >> > something while compiling the code? Is there a different way to > compile > >> > bitcode (from Fortran programs) to a native binary? > >> For Fortran MAIN is indeed something similar to C main, but not > >> exactly the same. > >> You have to link the runtime library (libgfortran.a) in order to get > >> "proper" main, mak sure all stuff is initialized properly, etc. > >> > >> -- > >> With best regards, Anton Korobeynikov > >> Faculty of Mathematics and Mechanics, Saint Petersburg State University > > > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110912/dd52e2ba/attachment.html>
Hi Ashay,> Sorry for the late reply. Using dragonegg worked well, thanks all! > > Just as a note... I had to use llvm-ld during the link step because > gfortran could not link bitcode. Here's an example of the error shown > when using gfortran instead of llvm-ld: > > $ ${GCC_4_5_0}/bin/gfortran hw.f -c -fplugin> ${DRAGONEGG_PLUGIN}/dragonegg.so -o hw.o -flto -emit-llvm -S > $ ${LLVM_2_9}/bin/opt -mem2reg hw.o -o hw.o > $ ${GCC_4_5_0}/bin/gfortran > -fplugin=${DRAGONEGG_PLUGIN}/dragonegg.so ${GCC_4_5_0}/lib64/libgfortran.a > hw.o -o hw > hw.o: file not recognized: File format not recognized > collect2: ld returned 1 exit status > > $ file hw.o > hw.o: data > > Instead, using llvm-ld: > $ ${LLVM_2_9}/bin/llvm-ld -native hw.o -o hw > ${GCC_4_5_0}/lib64/libgfortran.a -lm > > llvm-gcc had the gold plugin. I wonder if there is any equivalent of > that for dragonegg to be able to compile bitcode and native object code > in a transparent manner.can you please open a bug report about this. Hopefully there is a straightforward way to use the gold plugin with dragonegg, but I never thought about it (I always do LLVM LTO "by hand"). Ciao, Duncan.> > Thanks again! > Ashay > > > On Wed, Aug 31, 2011 at 4:29 PM, Anton Korobeynikov > <anton at korobeynikov.info <mailto:anton at korobeynikov.info>> wrote: > > Hello > > > I am not very familiar with Fortran programs. I saw a few > programs that had > > a "MAIN" subroutine defined, some others that did not. Am I missing > > something while compiling the code? Is there a different way to > compile > > bitcode (from Fortran programs) to a native binary? > For Fortran MAIN is indeed something similar to C main, but not > exactly the same. > You have to link the runtime library (libgfortran.a) in order to get > "proper" main, mak sure all stuff is initialized properly, etc. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev