-1

I'm building iOS software from C and C++ code with clang (at the command line - for good but complex reasons), and want to know what variant of ARMv8 the compiler is targeting (e.g., 8, 8.3, etc). A related question: clang how to list supported target architectures, but many of the answers rely on tools such as llc, which aren't provided in Apple's Xcode.

John Dallman
  • 590
  • 4
  • 18

1 Answers1

0

This is fairly simple, once you find out how. A useful tool is an absolutely minimal C program with no includes:

main( int argc, char *argv[]) 
{
    return 0;
}

Compile this with the --verbose option, which makes the compiler produce lots of output about its work. For example,

clang -arch arm64 -fexceptions -std=c99 --verbose minimal_c_program_with_no_includes.c

is actually a compile for ARM macOS, and produces, among other output:

-triple arm64-apple-macosx11.0.0 -main-file-name minimal_c_program_with_no_includes.c  
-target-sdk-version=11.0 -target-cpu vortex -target-feature +v8.3a 
-target-feature +fp-armv8 -target-feature +neon

Whereas a compile for iOS 14 and later with:

clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
-mios-version-min=14.0 -fexceptions -std=c99 --verbose minimal_c_program_with_no_includes.c

produces:

-triple arm64-apple-ios14.0.0 -main-file-name minimal_c_program_with_no_includes.c 
-target-sdk-version=14.2 -target-cpu apple-a7 -target-feature +fp-armv8 
-target-feature +neon

The -target-sdk-version value is because I'm using Xcode 12.2, which has the iOS 14.2 SDK.

John Dallman
  • 590
  • 4
  • 18