[llvm-dev] Help Building LLVM for Android

Justin Giannone via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 20 10:57:43 PDT 2019


Although there didn't seem to be any interest in my thread, I figured I
should still update with my partial success.  I've managed to get LLVM to
build with Android NDK and have put together scripts to encapsulate the
necessary commands.  See https://github.com/Jman420/llvm_for_android for
scripts and instructions.

For some reason the '*.exports' files do not seem to get generated
correctly.  They end up with double quoted lines (such as '"LLVM {"') which
seem to be invalid format.  Unfortunately, I haven't been able to figure
out where/what generates those files.  They seem to be generated by the
actual compiler since those files don't exist until I execute
'cmake --build . --target install'.

On Thu, Jun 13, 2019 at 5:13 PM Justin Giannone <jman.giannone at gmail.com>
wrote:

> Hey Guys,
>
> Still struggling with this.  Wondering if anyone has any recommendations?
>
> The command I'm using to generate the Ninja Build Files and execute the
> build are :
>
>> AndroidSdkDir="$LOCALAPPDATA/Android/Sdk"
>> AndroidCmakeExe="$AndroidSdkDir/cmake/3.10.2.4988404/bin/cmake.exe"
>> AndroidNinjaExe="$AndroidSdkDir/cmake/3.10.2.4988404/bin/ninja.exe"
>> NdkBundle="$AndroidSdkDir/ndk-bundle/"
>> ToolchainFile="$NdkBundle/build/cmake/android.toolchain.cmake"
>> ArchTargets="armeabi-v7a"
>>
>> $AndroidCmakeExe \
>> -DBUILD_SHARED_LIBS=1 \
>> -DLLVM_BUILD_LLVM_DYLIB=1 \
>> -DLLVM_BUILD_TOOLS=0 \
>> -DLLVM_BUILD_UTILS=0 \
>> -DLLVM_INCLUDE_BENCHMARKS=0 \
>> -DLLVM_INCLUDE_DOCS=0 \
>> -DLLVM_INCLUDE_EXAMPLES=0 \
>> -DLLVM_INCLUDE_GO_TESTS=0 \
>> -DLLVM_INCLUDE_RUNTIMES=1 \
>> -DLLVM_INCLUDE_TESTS=0 \
>> -DLLVM_INCLUDE_TOOLS=0 \
>> -DLLVM_INCLUDE_UTILS=0 \
>> \
>> -DLLVM_DEFAULT_TARGET_TRIPLE=armv7a-linux-androideabi \
>> -DLLVM_TARGET_ARCH=ARM \
>> -DLLVM_TARGETS_TO_BUILD=ARM \
>> \
>> -DPYTHON_EXECUTABLE="$NdkBundle/prebuilt/windows-x86_64/bin/python2.7.exe"
>> \
>> -DANDROID_NDK="$NdkBundle" \
>> -DANDROID_ABI="$archTarget" \
>> \
>> -DCMAKE_INSTALL_PREFIX=../../build-android/armeabi-v7a \
>> -DCMAKE_CROSSCOMPILING=True \
>> -DCMAKE_SYSTEM_NAME=Android \
>> -DANDROID_PLATFORM=android-21 \
>> -DCMAKE_SYSTEM_VERSION=21 \
>> -DCMAKE_ANDROID_NDK="$NdkBundle" \
>> -DCMAKE_TOOLCHAIN_FILE="$ToolchainFile" \
>> -DCMAKE_MAKE_PROGRAM="$AndroidNinjaExe" \
>> -G "Ninja" \
>> ../../llvm-8.0.0.src
>>
>> $AndroidCmakeExe --build .
>>
>
> And the full error output from the build is :
>
>> [186/1329] Creating export file for LLVMHello
>> FAILED: lib/Transforms/Hello/LLVMHello.exports
>> cmd.exe /C "cd /D
>> C:\JStash\Projects\llvm\llvm_android_project\armeabi-v7a\lib\Transforms\Hello
>> && echo "LLVM_8 {" > LLVMHello.exports && ( grep -q [[:alnum:]]
>> C:/JStash/Projects/llvm/llvm-8.0.0.src/lib/Transforms/Hello/Hello.exports
>> && echo "  global:" >> LLVMHello.exports || : ) && sed -e s/$/;/ -e "s/^/
>>  /" <
>> C:/JStash/Projects/llvm/llvm-8.0.0.src/lib/Transforms/Hello/Hello.exports
>> >> LLVMHello.exports && echo "  local: *;" >> LLVMHello.exports && echo };
>> >> LLVMHello.exports"
>> ':' is not recognized as an internal or external command,
>> operable program or batch file.
>> [195/1329] Configuring NATIVE LLVM...
>> FAILED: NATIVE/CMakeCache.txt
>> cmd.exe /C "cd /D
>> C:\JStash\Projects\llvm\llvm_android_project\armeabi-v7a\NATIVE &&
>> C:\Users\jgiannone\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe
>> -G Ninja
>> -DCMAKE_MAKE_PROGRAM="C:\Users\jgiannone\AppData\Local/Android/Sdk/cmake/3.10.2.4988404/bin/ninja.exe"
>> -DCMAKE_C_COMPILER=C:/Users/jgiannone/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
>> -DCMAKE_CXX_COMPILER=C:/Users/jgiannone/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
>> C:/JStash/Projects/llvm/llvm-8.0.0.src
>> -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE -DLLVM_TARGETS_TO_BUILD="ARM"
>> -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=""
>> -DLLVM_DEFAULT_TARGET_TRIPLE="armv7a-linux-androideabi"
>> -DLLVM_TARGET_ARCH="ARM" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="OFF"
>> -DCMAKE_BUILD_TYPE=Release"
>> -- The C compiler identification is Clang 8.0.7
>> -- The CXX compiler identification is Clang 8.0.7
>> -- The ASM compiler identification is Clang
>> -- Found assembler:
>> C:/Users/jgiannone/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
>> -- Check for working C compiler:
>> C:/Users/jgiannone/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
>> -- Check for working C compiler:
>> C:/Users/jgiannone/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
>> -- broken
>> CMake Error at
>> C:/Users/jgiannone/AppData/Local/Android/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52
>> (message):
>>   The C compiler
>>
>>
>> "C:/Users/jgiannone/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
>>
>>   is not able to compile a simple test program.
>>
>>   It fails with the following output:
>>
>>     Change Dir:
>> C:/JStash/Projects/llvm/llvm_android_project/armeabi-v7a/NATIVE/CMakeFiles/CMakeTmp
>>
>>     Run Build
>> Command:"C:\Users\jgiannone\AppData\Local/Android/Sdk/cmake/3.10.2.4988404/bin/ninja.exe"
>> "cmTC_43bcf"
>>     [1/2] Building C object CMakeFiles/cmTC_43bcf.dir/testCCompiler.c.obj
>>     [2/2] Linking C executable cmTC_43bcf.exe
>>     FAILED: cmTC_43bcf.exe
>>     cmd.exe /C "cd . &&
>> C:\Users\jgiannone\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
>>    CMakeFiles/cmTC_43bcf.dir/testCCompiler.c.obj  -o cmTC_43bcf.exe
>> -Wl,--out-implib,libcmTC_43bcf.dll.a
>> -Wl,--major-image-version,0,--minor-image-version,0  -lkernel32 -luser32
>> -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32
>> -ladvapi32 && cd ."
>>     clang: error: unable to execute command: program not executable
>>     clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>>     ninja: build stopped: subcommand failed.
>>
>>
>>
>>
>>   CMake will not be able to correctly generate this project.
>> Call Stack (most recent call first):
>>   CMakeLists.txt:39 (project)
>>
>>
>> -- Configuring incomplete, errors occurred!
>> See also
>> "C:/JStash/Projects/llvm/llvm_android_project/armeabi-v7a/NATIVE/CMakeFiles/CMakeOutput.log".
>> See also
>> "C:/JStash/Projects/llvm/llvm_android_project/armeabi-v7a/NATIVE/CMakeFiles/CMakeError.log".
>> ninja: build stopped: subcommand failed.
>>
>
> I'm kinda stumped as to what's going on...
>
> On Sat, Jun 8, 2019 at 11:59 AM Justin Giannone <jman.giannone at gmail.com>
> wrote:
>
>> Hey Guys,
>>
>> I'm working on a project in Android related to System-level Audio DSP
>> Effects for Tuning Android Audio.  I want to leverage Faust (
>> https://faust.grame.fr/) to allow users to program their own filters.
>> Faust provides a libfaust implementation which includes a JIT Compiler
>> which leverages LLVM and seems to be the best path for me to use.
>> Unfortunately I'm having problems cross-compiling LLVM for Android on my
>> Windows Dev machine.  Wondering if anyone has any advice for me?
>>
>> I've been trying to use the android-ndk cmake & toolchains to build LLVM
>> so that I can cross-compile Faust against the Android LLVM build.  I've
>> managed to get Android's cmake to generate an Android Gradle Ninja project,
>> but when I try to build it I get lots of errors that seem to indicate that
>> the Ninja project is invalid, such as the following errors :
>>
>> FAILED: cmTC_4a28c.exe
>>>
>>>   cmd.exe /C "cd .  &&
>>>
>>> C:\Users\jgiannone\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
>>>   CMakeFiles/cmTC_4a28c.dir/testCCompiler.c.obj -o cmTC_4a28c.exe
>>>   -Wl,--out-implib,libcmTC_4a28c.dll.a
>>>   -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32
>>>   -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32
>>>   -ladvapi32 && cd ."
>>>
>>>   clang: error: unable to execute command: program not executable
>>>
>>>   clang: error: linker command failed with exit code 1 (use -v to see
>>>   invocation)
>>>
>>>   ninja: build stopped: subcommand failed.
>>>
>>
>> Thanks!
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190620/b5412e28/attachment-0001.html>


More information about the llvm-dev mailing list