Reputation: 89
I wonder is there any option to output assembly from ndk-build? I tried put in -save-temp in LOCAL_CFLAGS but failed to build. It tells me it is an unrecognized option. Wonder whether google got it deleted in i686-android-linux like what is claimed in this link http://code.google.com/p/vs-android/issues/detail?id=47
Upvotes: 1
Views: 2379
Reputation: 926
There are two ways I've discovered to do this.
LOCAL_CFLAGS += -save-temps
Note the single dash and the spelling (not save-temp as mentioned in the question). The files are saved to the working directory for the build, usually the top-level project folder. Although this makes the files easier to find you may have issues if you have multiple files with the same name in different folders, or if you are building for multiple ABIs (though you can restrict that in Application.mk).
The alternative approach uses LOCAL_FILTER_ASM, which places the assembly files next to the object files, which matches the source directory layout and uses different paths for the different ABIs being targeted.
LOCAL_FILTER_ASM := cp
Setting this variable makes the NDK build output to assembly first, then run a command to "filter" the compiler's assembly output, and then assemble the filtered output. You need to set it to a command that accepts two arguments representing the source and destination paths. Thankfully the cp
command already accepts source and destination paths, so that can be used directly as a no-op filter.
After a build you can find your assembly files in obj/local/[abi]/objs/[module]/__/path-to-file.s
Due to using the LOCAL_FILTER_ASM feature there will also be another copy of the file with a ".filtered.s" extension, but that doesn't do any harm.
Upvotes: 2
Reputation: 999
Crude workaround: Put -S in LOCAL_CFLAGS; running then ndk-build will fail but checking the .o file created in ./obj/local/armeabi/objs-debug/ you may find it contains assembly :-)
Upvotes: 0