The clang command lines that the build is using will look something like: clang -c file.cpp -o file.o By adding -emit-llvm -S, you are causing clang to write llvm bitcode to file.o, which is then later passed to the linker which is expecting to find an object file. To make this work you would need to get clang to output both the object file and the bitcode file. See http://clang-developers.42468.n3.nabble.com/how-to-generate-both-IR-and-object-file-td4040081.html for a similar discussion.
It will likely be difficult to adjust the makefiles to run both, so I would suggest wrapping clang in a script that can run clang with the same command line arguments, and then if -c is present, strip it and replace it with -emit-llvm -S and append .ll to the -o argument. That will run clang twice for every file, once to output the .o file for the next rules to use, and once to output llvm bitcode. On Mon, Mar 27, 2017 at 5:16 PM, Syed Rafiul Hussain <[email protected]> wrote: > Please note that I was trying to build android-6.0.1_r60. I have also tried > with the command: make USE_CLANG_PLATFORM_BUILD:= true -j4. I have run into > same issues. > > > On Monday, March 27, 2017 at 7:05:57 PM UTC-4, Syed Rafiul Hussain wrote: >> >> Hi, >> >> I would like to generate LLVM bitcode for Android AOSP and that's why I >> want to build AOSP with clang. >> >> I have changed the following in the build/core/clang/clear_vars.mk: >> >> >> LOCAL_CLANG_CFLAGS:=-emit-llvm -S >> LOCAL_CLANG_CPPFLAGS:=-emit-llvm -S >> LOCAL_CLANG:=true >> >> >> However, the AOSP build failed with the following error messages: >> >> >> >> prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld: >> error: out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o:1:14: >> invalid character >> >> >> prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld: >> error: out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o:1:14: >> syntax error, unexpected $end >> >> >> prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld: >> error: out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o: not an >> object or archive >> >> >> prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld: >> error: >> out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a: no >> archive symbol table (run ranlib) >> >> >> prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld: >> error: >> out/host/linux-x86/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a: >> no archive symbol table (run ranlib) >> >> >> prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//sysroot/usr/lib/Scrt1.o(.text+0x20): >> error: undefined reference to 'main' >> >> clang: error: linker command failed with exit code 1 (use -v to see >> invocation) >> >> >> >> Any suggestion to fix this issue would be appreciated. > > -- > -- > You received this message because you are subscribed to the "Android > Building" mailing list. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-building?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "Android Building" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- You received this message because you are subscribed to the "Android Building" mailing list. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-building?hl=en --- You received this message because you are subscribed to the Google Groups "Android Building" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
