Hassan, Ahmad
2013-Jan-17 13:56 UTC
[LLVMdev] Migrate Project Build system to LLVM BitCode
Hi All, I am migrating a build system of an existing project from 'Object files' based executable generation to 'LLVM Bitcode' files based exe generation and applying OPT pass to LLVM Bitcode. I found out the following 4 step procedure. Please let me know if this is the right procedure or is there any other easy way of doing it. I need to modify 'Makefile' accordingly. I read on some forums about GoldPlugin but I don't know exactly if it would be useful here: Original Makefile- Object Files based Build/Link Steps: clang -g -O2 -o .libs/mergedexe file1.o file2.o file3.o -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -ldl -pthread .libs/lib2.so Proposed Makefile- LLVM Bitcode based Build/Link Steps: 1. llvm-link -o .libs/mergedbc.bc file1.bc file2.bc file3.bc 2. opt -o optmerged.bc -load /path/to/Mypass.so -mypass < mergedbc.bc 3. llc -o .libs/mergedbc.s .libs/mergedbc.bc 4. gcc -g -O2 -o .libs/mergedexe .libs/mergedbc.s -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto -ldl -pthread .libs/lib2.so Thanks. Ahmad -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130117/02479a97/attachment.html>
Hi Ahmad, On 17/01/13 14:56, Hassan, Ahmad wrote:> Hi All, > > I am migrating a build system of an existing project from ‘Object files’ based > executable generation to ‘LLVM Bitcode’ files based exe generation and applying > OPT pass to LLVM Bitcode. I found out the following 4 step procedure. Please let > me know if this is the right procedure or is there any other easy way of doing > it. I need to modify ‘Makefile’ accordingly. I read on some forums about > GoldPlugin but I don’t know exactly if it would be useful here: > > *Original Makefile- Object Files based Build/Link Steps: * > > clang -g -O2 –o .libs/mergedexe file1.o file2.o file3.o -pthread > -Wl,--export-dynamic .libs/lib1.a -lssl –ldl –pthread .libs/lib2.so > > *Proposed Makefile- LLVM Bitcode based Build/Link Steps:* > > 1.llvm-link -o .libs/mergedbc.bc file1.bc file2.bc file3.bc > > 2.opt –o optmerged.bc -load /path/to/Mypass.so -mypass < mergedbc.bc > > 3.llc -o .libs/mergedbc.s .libs/mergedbc.bc > > 4.gcc -g -O2 -o .libs/mergedexe .libs/mergedbc.s -pthread > -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto –ldl –pthread .libs/lib2.soif you pass -O4 rather than -O2 to clang I think it will in essence do this all for you already. It might even do the link time optimization for you at -O2 even, I'm not sure. Ciao, Duncan.> > Thanks. > > Ahmad > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hassan, Ahmad
2013-Jan-17 15:09 UTC
[LLVMdev] Migrate Project Build system to LLVM BitCode
Hi Duncan,> 4.gcc -g -O2 -o .libs/mergedexe .libs/mergedbc.s -pthread > -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto -ldl -pthread .libs/lib2.so>if you pass -O4 rather than -O2 to clang I think it will in essence do this all >for you already. It might even do the link time optimization for you at -O2 >even, I'm not sure.No, if I use clang for producing executable then I get series of error both with O2 and O4: error: input can't have .file dwarf directives when -g is used to generate dwarf debug info for assembly code .file 38 "/usr/include/x86_64-linux-gnu/sys/un.h" If I remove '-g' then I get /usr/bin/ld: /usr/local/bin/../lib/LLVMgold.so: error loading plugin /usr/bin/ld: /usr/local/bin/../lib/LLVMgold.so: error in plugin cleanup (ignored) clang: error: linker command failed with exit code 1 It works fine if I use 'gcc' in step 4 for produce executable. Cheers, Ahmad Ciao, Duncan.> > Thanks. > > Ahmad > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >_______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Sahoo, Swarup Kumar
2013-Jan-17 15:10 UTC
[LLVMdev] Migrate Project Build system to LLVM BitCode
Hi Ahmad, If the Makefile contains only this command, then it is not worth spending time on GoldPlugin. If you are building a large project, then it will be simpler to use GoldPlugin. The steps you are using seem right. You can possibly combine the last two steps (3&4) using only 1 clang command. clang -g -O2 -o .libs/mergedexe .libs/mergedbc.bc -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto –ldl –pthread .libs/lib2.so -Swarup. ________________________________ From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] on behalf of Hassan, Ahmad [ahmad.hassan at sap.com] Sent: Thursday, January 17, 2013 7:56 AM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] Migrate Project Build system to LLVM BitCode Hi All, I am migrating a build system of an existing project from ‘Object files’ based executable generation to ‘LLVM Bitcode’ files based exe generation and applying OPT pass to LLVM Bitcode. I found out the following 4 step procedure. Please let me know if this is the right procedure or is there any other easy way of doing it. I need to modify ‘Makefile’ accordingly. I read on some forums about GoldPlugin but I don’t know exactly if it would be useful here: Original Makefile- Object Files based Build/Link Steps: clang -g -O2 –o .libs/mergedexe file1.o file2.o file3.o -pthread -Wl,--export-dynamic .libs/lib1.a -lssl –ldl –pthread .libs/lib2.so Proposed Makefile- LLVM Bitcode based Build/Link Steps: 1. llvm-link -o .libs/mergedbc.bc file1.bc file2.bc file3.bc 2. opt –o optmerged.bc -load /path/to/Mypass.so -mypass < mergedbc.bc 3. llc -o .libs/mergedbc.s .libs/mergedbc.bc 4. gcc -g -O2 -o .libs/mergedexe .libs/mergedbc.s -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto –ldl –pthread .libs/lib2.so Thanks. Ahmad -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130117/4ace3622/attachment.html>
Hassan, Ahmad
2013-Jan-17 15:19 UTC
[LLVMdev] Migrate Project Build system to LLVM BitCode
Hi Swarp,> clang -g -O2 -o .libs/mergedexe .libs/mergedbc.bc -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto -ldl -pthread .libs/lib2.soThanks. This works fine. The project that I am migrating is huge and has various massive Makefiles. But I am going to try this 3 step approach to apply passes and compile the code. If that gets too complex then I will move to GoldPlugin. Thanks. --Ahmad -Swarup. ________________________________ From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] on behalf of Hassan, Ahmad [ahmad.hassan at sap.com] Sent: Thursday, January 17, 2013 7:56 AM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] Migrate Project Build system to LLVM BitCode Hi All, I am migrating a build system of an existing project from 'Object files' based executable generation to 'LLVM Bitcode' files based exe generation and applying OPT pass to LLVM Bitcode. I found out the following 4 step procedure. Please let me know if this is the right procedure or is there any other easy way of doing it. I need to modify 'Makefile' accordingly. I read on some forums about GoldPlugin but I don't know exactly if it would be useful here: Original Makefile- Object Files based Build/Link Steps: clang -g -O2 -o .libs/mergedexe file1.o file2.o file3.o -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -ldl -pthread .libs/lib2.so Proposed Makefile- LLVM Bitcode based Build/Link Steps: 1. llvm-link -o .libs/mergedbc.bc file1.bc file2.bc file3.bc 2. opt -o optmerged.bc -load /path/to/Mypass.so -mypass < mergedbc.bc 3. llc -o .libs/mergedbc.s .libs/mergedbc.bc 4. gcc -g -O2 -o .libs/mergedexe .libs/mergedbc.s -pthread -Wl,--export-dynamic .libs/lib1.a -lssl -lcrypto -ldl -pthread .libs/lib2.so Thanks. Ahmad -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130117/460245ec/attachment.html>