69189

Define a symbol for an assembly (.s) source file in Android.mk?

Question:

<strong>Is there a simple way to define a symbol for the Android NDK toolchain's assembler from the Android.mk file?</strong>

My objective is to be able to build a native library made up from several .C and .s (assembler) files compiled and tuned for either ARMV6 or ARMV7A EABIS, with all the required conditional compilation driven by simply modifying the APP_ABI value on the Application.mk file.

First I have succesfully used the ifeq() directives available in Android.mk to query the value of the APP_ABI value and then conditionaly execute different parts of the build script.

Then I tried to use this functionality in order to conditionally inject a symbol (via -D), like this:

# Compilation Flags ifeq ($(TARGET_ARCH_ABI),armeabi) LOCAL_CFLAGS += -DTARGET_ARMEABI -marm -mtune='arm1136jf-s' -ffast-math -O3 -march=armv6 -fvisibility=hidden else #armeabi-v7a LOCAL_CFLAGS += -marm -ffast-math -O3 -march=armv7-a -fvisibility=hidden endif

<strong>The C source code files find the TARGET_ARMEABI symbol properly defined, however the assembler files don't.</strong> (I require this in order to define proper EABI attributes according the architecture). This is an example of how I attempt to conditionally define EABI attributes in the assembly language files:

.ifdef TARGET_ARMEABI .arch armv6 .fpu softvfp .eabi_attribute 23, 1 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .eabi_attribute 26, 2 .eabi_attribute 30, 2 .eabi_attribute 18, 4 .else .arch armv7-a .eabi_attribute 27, 3 .fpu vfp .eabi_attribute 23, 1 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .eabi_attribute 26, 2 .eabi_attribute 30, 2 .eabi_attribute 18, 4 .endif

Any pointers or suggestions are greatly appreciated.

Answer1:

Assembly files needs to end with capital S (.S or .sx) to be preprocessed by gcc. See <a href="http://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html" rel="nofollow">GCC doc, 3.2 Options Controlling the Kind of Output</a> about that.

I believe you can cheat from Bionic <a href="https://android.googlesource.com/platform/bionic/+/master" rel="nofollow">sources</a>, for example from <a href="https://android.googlesource.com/platform/bionic/+/master/libc/arch-arm/bionic/memcpy.S" rel="nofollow">libc/arch-arm/bionic/memcpy.S</a>.

Answer2:

To make TARGET_ARMEABI define visible in assembly file compile it with '<em>-x assembler-with-cpp</em>' option and use standard C preprocessor <em>#ifdef</em> directive in assembly file.

Recommend

  • Button in ActionBarSherlock not vertically centered
  • PHP/MySQL: Convert from YYYY-MM-DD to DD Month, YYYY?
  • No console.log to STDOUT when running “npm test” (jest)
  • get user name from an E-mail address in php [closed]
  • Continuous colorbar with contour levels
  • How to minimize(iconify) FXML app?
  • How to start camel even if the MQTT server is not reachable
  • Detect Boolean value changes inside Thread
  • After upgrade to GIT bash 2.8.2, cannot run sqlite3
  • pyodbc fails without error
  • Optimization of Neural Network input data
  • How to use OPENXML to load XML data into existing SQL Table?
  • How can I return more than one value from a method in C#
  • Create a mobile app that just points to URL
  • JavaFX resize children relative to parent
  • IIS - ASP.NET MVC redirection
  • Scrapy + Selenium + Datepicker
  • python pandas isin method?
  • Using Facebook Graph API with ASP.NET
  • CABasicAnimation creates empty default value copy of CALayer
  • Azure NodeJS Error: ENOENT, open 'D:\\home\\site\\wwwroot\\bin\\views\\'
  • Rust lifetime error
  • Nested AJAX Calls using .done
  • Shrinking Bootstrap Navbar with logo on scroll
  • if you have a DLL creating a bitmap in memory, how to return it to the browser?
  • Remove stopwords and tolower function slow on a Corpus in R
  • .htaccess redirect domain.com to www.domain.com
  • MayAVI install on Python 3.6 [duplicate]
  • How to get the Owner of the ContextMenu (from Silverlight 4 toolkit)?
  • Implementation of timeout in LDAP
  • Synchronous Calls with jqGrid?
  • view details for exception in vs 2017
  • 'Edit' function for forum posts and such
  • How to redirect into different page by user type in php and mysql
  • JQuery: Infinite input select
  • How can I ssh into a server that requires 2 password authentication using python's paramiko mod
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How to integrate angular2-material (alpha 8.2) with angular2-Quickstart app
  • What is the best way to cache and reuse immutable singleton objects in Java?