-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem cross compiling freetype with Clang (android-ndk-r16b) #614
Comments
I thought you are expected to run ./configure for freetype, and need a standalone toolchain. |
freetype was properly configured and compiles and runs ok when compiled with gcc. The error arises when changing compiler from gcc to clang. |
Did you configure from scratch after setting up a clang standalone toolchain? |
No, I didn't use standalone toolchain since i didn't use freetype makefile to build but created Android.mk. AFAIK I shouldn't need standalone toolchain to configure freetype, so result of configure doesn't depend on standalone toolchain. Configure should just define the appropriate compilation flags and header files. The same generated code should be compiling and running both using gcc or clang cross compilers. |
If you run ./configure without specifying a cross-compilation toolchain, it uses the native compiler on your PC. If it happens to be gcc, your configuration may work with NDK/gcc, but even that is not guaranteed. |
I didn't run ./configure without specifying a cross-compilation toolchain since i know that I'll be building for the host machine. |
does freetype have inline assembler? see the last item "-fno-integrated-as" in https://android.googlesource.com/platform/ndk.git/+/master/docs/ClangMigration.md ... |
(it builds fine for us as part of the platform, though i note that we build for arm, not thumb.) |
The "-fno-integrated-as"/"-fintegrated-as" looks working the opposite of what is expected. "-fno-integrated-as" generates the reported error: ("Error: garbage following instruction") |
include/freetype/internal/ftcalc.h does indeed have inline assembly. In general, the integrated assembler should be preferred, although -fno-integrated-as helps to work around legacy assembly issues (which is why that is suggested on the other page). Our flags are listed at https://android.googlesource.com/platform/external/freetype/+/master/Android.bp, which shows that we are indeed not setting -fno-integrated-as (unlike your original command line). |
Thanks for the reply, I asked for the command line since I also don't have -fno-integrated-as in my Android makefile and that flag doesn't either come from freetype. |
No, as enh mentioned above, we build this as part of the Android platform which does not use any of the NDK .mk files. We default to the integrated assembler (as Clang does) and have only a few -fno-integrated-as for remaining third-party projects that don't assemble without it. I don't have the explicit command line flags, but it won't help you anyways, since the flags will produce a non-thumb version that only works for the latest target API level (probably not what you are expecting). @DanAlbert - can we remove -fno-integrated-as from the defaults? I feel like this is going to hurt more people in the future, and it certainly doesn't help to get anything fixed in Clang (assuming that there are assembler directives that should be supported and are missing). |
Ok, so if i am getting well I have only options to force -fintegrated-as in my Android.mk since using latest API level will not be compatible with old devices. |
You should just add -fintegrated-as in your Android.mk. If you can't use the integrated-as for all your projects, you can also just get it added to the cflags just for freetype (probably via configure). We highly recommend sticking with clang, since gcc is planned for removal, and we aren't supporting it in any way going forward. |
Test: ./checkbuild.py && ./run_tests.py Bug: android/ndk#614 Change-Id: I1ae3d7ab1a9792a0bff91bd2800d2aee1105006d (cherry picked from commit fb5456cf0b84af7b2caff90fc0cbe1fed1904b80)
Description
There is problem cross compiling freetype using clang toolchain instead of gcc
<root_path>/android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -MMD -MP -MF ./obj/local/armeabi-v7a/objs/freetype/./src/base/ftbase.o.d -gcc-toolchain <root_path>/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -fno-integrated-as -g -target armv7-none-linux-androideabi17 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -O2 -DNDEBUG -Ijni//freetype/include -Ijni//freetype -DANDROID -DFT2_BUILD_LIBRARY -D__ANDROID_API__=17 -Wa,--noexecstack -Wformat -Werror=format-security --sysroot <root_path>/android-ndk-r16b/sysroot -isystem <root_path>/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi -c -v jni//freetype/./src/base/ftbase.c -o ./obj/local/armeabi-v7a/objs/freetype/./src/base/ftbase.o
The command fails with error:
/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s: Assembler messages:
/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1707: Error: garbage following instruction --
orr r2,r5,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1731: Error: garbage following instruction --
orr r3,r4,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1759: Error: garbage following instruction --
orr r7,r1,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1783: Error: garbage following instruction --
orr r1,r4,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1888: Error: garbage following instruction --
orr r1,r7,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1912: Error: garbage following instruction --
orr r2,r5,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1940: Error: garbage following instruction --
orr r3,r4,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:1964: Error: garbage following instruction --
orr r2,r4,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3086: Error: garbage following instruction --
orr r0,r3,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3330: Error: garbage following instruction --
orr r12,lr,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3354: Error: garbage following instruction --
orr lr,r4,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3378: Error: garbage following instruction --
orr r8,r5,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3402: Error: garbage following instruction --
orr r9,r6,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3426: Error: garbage following instruction --
orr r10,r7,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3450: Error: garbage following instruction --
orr r5,r2,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3474: Error: garbage following instruction --
orr r2,r3,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3502: Error: garbage following instruction --
orr r0,r4,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3602: Error: garbage following instruction --
orr r1,r7,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:3622: Error: garbage following instruction --
orr r2,r6,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11111: Error: garbage following instruction --
orr lr,r4,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11135: Error: garbage following instruction --
orr r3,r5,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11163: Error: garbage following instruction --
orr r8,r6,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11187: Error: garbage following instruction --
orr r6,r7,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11381: Error: garbage following instruction --
orr r12,lr,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11405: Error: garbage following instruction --
orr lr,r4,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11429: Error: garbage following instruction --
orr r6,r5,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:11457: Error: garbage following instruction --
orr r1,r2,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:18772: Error: garbage following instruction --
orr r0,r3,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:18802: Error: garbage following instruction --
orr r0,r3,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:18829: Error: garbage following instruction --
orr r0,r3,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:18857: Error: garbage following instruction --
orr r0,r3,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:19635: Error: garbage following instruction --
orr r9,r2,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:19660: Error: garbage following instruction --
orr lr,r3,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:19702: Error: garbage following instruction --
orr r0,r2,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:19731: Error: garbage following instruction --
orr r0,r3,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:19758: Error: garbage following instruction --
orr r0,r3,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:19786: Error: garbage following instruction --
orr r0,r3,lsl#16' /var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:20687: Error: garbage following instruction --
orr r0,r3,lsl#16'/var/folders/_3/gdj9yqbn1l12xr67c7812smm0000gp/T/ftbase-97757a.s:20716: Error: garbage following instruction -- `orr r7,r3,lsl#16'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
Environment Details
NDK Version: android-ndk-r16b
Build sytem: ndk-build
Host OS: Mac
Compiler: Clang
ABI: armeabi-v7a
STL: NA
NDK API level: 17
Device API level: NA
The error disappear removing option "-fno-integrated-as" but that doesn't come from Android.mk
The text was updated successfully, but these errors were encountered: