Questions about arm instruction sets, static library running, compilation errors, and other issues, arm Instruction Sets

Source: Internet
Author: User

Questions about arm instruction sets, static library running, compilation errors, and other issues, arm Instruction Sets

Reprint from http://www.jianshu.com/p/4a70aa03a4ea? Utm_campaign = hugo & utm_medium = reader_share & utm_content = note & utm_source = qq

 

I read a lot of information about the arm Instruction Set and the running of the static library, as shown below:

1: blog.csdn.net/lizhongfu2013/article/details/42387311

The following content is forwarded from the above link: iOS developer ~ Make a static library that supports armv7, armv7s, arm64, i386, and x86_64 at the same time. a. The article is very detailed and can have a clear understanding.

I. Summary

In normal project development, the static library. a provided by a third party may be used. If the. a provider is not mature, problems may occur during use. For example:

When compiling on a real machine, the following error occurs: No ubuntures to compile for (ONLY_ACTIVE_ARCH = YES, active arch = x86_64, VALID_ARCHS = i386 ).

When compiling on the simulator, the following error occurs: No ubuntures to compile for (ONLY_ACTIVE_ARCH = YES, active arch = armv7s, VALID_ARCHS = armv7 armv6 ).

To solve the above problems, we need to know some details about the instruction set of Apple mobile devices.

Ii. Several Important Concepts

1. ARM

ARM processors are small in size, low in power consumption, low in cost, and high in performance. Therefore, almost all mobile phone processors are ARM-based and widely used in embedded systems.

2. ARM processor Instruction Set

Armv6 | armv7 | armv7s | arm64 is the instruction set of the ARM processor. These instruction sets are backward compatible. For example, armv7 instruction sets are compatible with armv6, but armv6 cannot be used to achieve its performance, new Features of armv7 cannot be used, resulting in less efficient program execution.

There are also two familiar instruction sets: i386 | x86_64 is the Mac processor instruction set, and i386 is for intel general purpose microprocessor 32 architecture. X86_64 is a 64-bit processor for the x86 architecture. Therefore, when using the iOS simulator, you may encounter i386 | x86_64. the iOS simulator does not have an arm instruction set.

3. Current iOS mobile device Instruction Set

Arm64: iPhone5S | iPad Air | iPad mini2 (iPad mini with Retina Display)

Armv7s: iPhone5 | iPhone5C | iPad4 (iPad with Retina Display)

Armv7: iPhone3GS | iPhone4 | iPhone4S | iPad | iPad2 | iPad3 (The New iPad) | iPad mini | iPod Touch 3G | iPod tou44.

Armv6 devices: iPhone, iPhone E2, iPhone 3G, first generation, and second generation iPod Touch (generally not required)

4. Instruction Set related options in Xcode (in Build Setting)

(1) ubuntures

Space-separated list of identifiers. specifies the ubuntures (ABIs, processor models) to which the binary is targeted. when this build setting specifies more than one architecture, the generated binary may contain in object code for each of the specified ubuntures.

Specify the types of instruction sets that can be compiled into a project. The more instruction sets are supported, the more data packets containing multiple instruction sets are compiled. The larger the Binary Package is generated, that is, the ipa package will become larger.

(2) Valid ubuntures

Space-separated list of identifiers. specifies the ubuntures for which the binary may be built. during the build, this list is intersected with the value of ARCHS build setting; the resulting list specifies the ubuntures the binary can run on. if the resulting architecture list is empty, the target generates no binary.

Limit the scope of the instruction sets that may be supported, that is, the Binary Package Types compiled by Xcode are eventually generated from these types, and the package of which instruction sets is compiled, it is determined by the intersection of ubuntures and Valid ubuntures (so this cannot be blank), for example:

For example, the supported arm instruction sets of your Valid ubuntures include armv7, armv7s, and arm64. The supported arm instruction sets of the corresponding ubuntures include armv7s, in this case, Xcode generates only one Binary Package of the armv7s instruction set.

For example, set the arm Instruction Set supported by ubuntures to armv7 and armv7s, and the supported instruction sets of the corresponding Valid ubuntures to armv7s and arm64, XCode only supports armv7s to generate Binary packages.

In the Valid ubuntures settings in Xcode6.1.1, the default value is Standard ubuntures (armv7, arm64). If you want to change the value, change it in other.

The reasons are as follows:

When the standard ubuntures (including 64-bit) (armv7, arm64) parameter is used, the package contains 32-bit and 64-bit codes, for iPhone 5s (the cpu of iPhone 5s is 64-bit), it is preferred to run 64-bit code packages, and the rest of the iPhone (the rest of the iPhone are 32-bit, and the iPhone 5C is also 32-bit ), only 32-bit packages can be run, but code packages with two architectures can only run on ios6 and ios7 systems.

That is to say, this packaging method has almost no requirements for mobile phones, but has requirements for the system, that is, iOS 6 and above.

When the standard ubuntures (armv7, armv7s) parameter is used, only 32-bit code is used in the package. The cpu of iPhone 5s is 64-bit, but it is compatible with 32-bit code, that is, 32-bit code can be run. However, this will reduce the iPhone5s performance. The remaining iPhones have no problem with 32-bit code packages, and 32-bit code packages have almost no restrictions on the system.

So the summary is as follows:

To realize the 64-Bit performance of the iPhone 5S, it must contain 64-bit packages. The minimum requirement for the system is ios6. To be compatible with ios5 and lower-level systems, only 32-bit packages can be used, but the performance of iPhone 5S may be lost.

(3) Build Active Architecture Only

Specifies whether to compile only the instruction set supported by the currently connected device.

When the value is set to YES, this attribute is set to yes to facilitate compilation during debugging. It only compiles the current architecture version and sets it to no, compile all versions. The compiled version is backward compatible, and the instruction sets of connected devices are matched in sequence from high to low (arm64> armv7s> armv7. For example, if you set this value to yes, the armv7 version is compiled with iPhone 4, and iPhone 5 can also run, but the armv6 device cannot run. Therefore, you can select yes for debugging and no for release to adapt to different devices.

1)

Ubuntures: armv7, armv7s, arm64

Validubuntures: armv6, armv7s, arm64

Supported instruction sets for generating Binary packages: arm64

2)

Ubuntures: armv6, armv7, armv7s

Valid ubuntures: armv6, armv7s, arm64

Supported instruction sets for generating Binary packages: armv7s

3)

Ubuntures: armv7, armv7s, arm64

Valid ubuntures: armv7, armv7s

In this case, an error is reported because no arm64 is allowed in the instruction set.

Note: If you have requirements on the size of the ipa installation package, you can reduce the number of instruction sets of the installation package, so as to minimize the package size. Of course, this will cause performance loss for some devices. Of course, in common applications, this is almost invisible, at least it will not threaten the user's health check.

3. Create a static database. a is the instruction set selection.

Now, how can we create a "no problem. a static library, through the above information, we know that when we do the App, in order to pursue high efficiency and reduce the package size, Build Active Architecture Only to YES, ubuntures can be configured by default in Xcode, because arm64 is forward compatible. However, the production of the. a static library is different, because to ensure compatibility, including the running of different iOS devices and Simulators without errors, we need to achieve maximum compatibility in light of the current industry situation.

Validubuntures is set to armv7 | armv7s | arm64 | i386 | x86_64

Ubuntures settings remain unchanged (or as needed): armv7 | arm64

Then select the iOS device and simulator for compilation, and finally find the relevant. a. Package and use lipo-create library. a path simulator library. path of a-name of the output merging library. a (For details, refer to http://blog.csdn.net/lizhongfu2013/article/details/12648633)

In this way, a general static library is created.

2. The static library does not support 64-bit compilation errors.

Make sure your static library has which ubuntures.

Lipo-info myStaticLibrary.On terminal

Ios-XCode 6.1 Missing required architecture X86_64 in file-Stack Overflow

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.