private CToolchain.Builder createAarch64Toolchain() { String toolchainName = "aarch64-linux-android-4.9"; String targetPlatform = "aarch64-linux-android"; CToolchain.Builder toolchain = CToolchain.newBuilder() .setToolchainIdentifier("aarch64-linux-android-4.9") .setTargetSystemName("aarch64-linux-android") .setTargetCpu("arm64-v8a") .setCompiler("gcc-4.9") .addAllToolPath(ndkPaths.createToolpaths(toolchainName, targetPlatform)) .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("arm64")) // Compiler flags .addCompilerFlag("-fpic") .addCompilerFlag("-ffunction-sections") .addCompilerFlag("-funwind-tables") .addCompilerFlag("-fstack-protector-strong") .addCompilerFlag("-no-canonical-prefixes") .addCompilerFlag("-fno-canonical-system-headers") // Linker flags .addLinkerFlag("-no-canonical-prefixes") // Additional release flags .addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.OPT) .addCompilerFlag("-O2") .addCompilerFlag("-g") .addCompilerFlag("-DNDEBUG") .addCompilerFlag("-fomit-frame-pointer") .addCompilerFlag("-fstrict-aliasing") .addCompilerFlag("-funswitch-loops") .addCompilerFlag("-finline-limit=300")) // Additional debug flags .addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.DBG) .addCompilerFlag("-O0") .addCompilerFlag("-UNDEBUG") .addCompilerFlag("-fno-omit-frame-pointer") .addCompilerFlag("-fno-strict-aliasing")); ndkPaths.addToolchainIncludePaths(toolchain, toolchainName, targetPlatform, "4.9"); stlImpl.addStlImpl(toolchain, "4.9"); return toolchain; }
/** Flags common to arm-linux-androideabi* */ private CToolchain.Builder createBaseArmeabiToolchain( boolean thumb, String gccVersion, String stackProtectorFlag, CppConfiguration.Tool... excludedTools) { String toolchainName = "arm-linux-androideabi-" + gccVersion; String targetPlatform = "arm-linux-androideabi"; CToolchain.Builder toolchain = CToolchain.newBuilder() .setTargetSystemName(targetPlatform) .setCompiler("gcc-" + gccVersion) .addAllToolPath(ndkPaths.createToolpaths(toolchainName, targetPlatform, excludedTools)) .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("arm")) .addCompilerFlag(stackProtectorFlag) // Compiler flags .addCompilerFlag("-fpic") .addCompilerFlag("-ffunction-sections") .addCompilerFlag("-funwind-tables") .addCompilerFlag("-no-canonical-prefixes") .addCompilerFlag("-fno-canonical-system-headers") // Linker flags .addLinkerFlag("-no-canonical-prefixes"); if (thumb) { toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.OPT) .addCompilerFlag("-mthumb") .addCompilerFlag("-Os") .addCompilerFlag("-g") .addCompilerFlag("-DNDEBUG") .addCompilerFlag("-fomit-frame-pointer") .addCompilerFlag("-fno-strict-aliasing") .addCompilerFlag("-finline-limit=64")); toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.DBG) .addCompilerFlag("-g") .addCompilerFlag("-fno-strict-aliasing") .addCompilerFlag("-finline-limit=64") .addCompilerFlag("-O0") .addCompilerFlag("-UNDEBUG") .addCompilerFlag("-marm") .addCompilerFlag("-fno-omit-frame-pointer")); } else { toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.OPT) .addCompilerFlag("-O2") .addCompilerFlag("-g") .addCompilerFlag("-DNDEBUG") .addCompilerFlag("-fomit-frame-pointer") .addCompilerFlag("-fstrict-aliasing") .addCompilerFlag("-funswitch-loops") .addCompilerFlag("-finline-limit=300")); toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.DBG) .addCompilerFlag("-g") .addCompilerFlag("-funswitch-loops") .addCompilerFlag("-finline-limit=300") .addCompilerFlag("-O0") .addCompilerFlag("-UNDEBUG") .addCompilerFlag("-fno-omit-frame-pointer") .addCompilerFlag("-fno-strict-aliasing")); } ndkPaths.addToolchainIncludePaths(toolchain, toolchainName, targetPlatform, gccVersion); return toolchain; }
private CToolchain.Builder createBaseArmeabiClangToolchain(String clangVersion, boolean thumb) { String toolchainName = "arm-linux-androideabi-4.8"; String targetPlatform = "arm-linux-androideabi"; String gccToolchain = ndkPaths.createGccToolchainPath("arm-linux-androideabi-4.8"); CToolchain.Builder toolchain = CToolchain.newBuilder() .setTargetSystemName("arm-linux-androideabi") .setCompiler("clang" + clangVersion) .addAllToolPath( ndkPaths.createClangToolpaths( toolchainName, targetPlatform, clangVersion, // gcc-4.8 arm doesn't have gcov-tool CppConfiguration.Tool.GCOVTOOL)) .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("arm")) // Compiler flags .addCompilerFlag("-gcc-toolchain") .addCompilerFlag(gccToolchain) .addCompilerFlag("-fpic") .addCompilerFlag("-ffunction-sections") .addCompilerFlag("-funwind-tables") .addCompilerFlag("-fstack-protector-strong") .addCompilerFlag("-Wno-invalid-command-line-argument") .addCompilerFlag("-Wno-unused-command-line-argument") .addCompilerFlag("-no-canonical-prefixes") .addCompilerFlag("-fno-canonical-system-headers") .addCompilerFlag("-fno-integrated-as") // Linker flags .addLinkerFlag("-gcc-toolchain") .addLinkerFlag(gccToolchain) .addLinkerFlag("-no-canonical-prefixes"); if (thumb) { toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.OPT) .addCompilerFlag("-mthumb") .addCompilerFlag("-Os") .addCompilerFlag("-g") .addCompilerFlag("-DNDEBUG") .addCompilerFlag("-fomit-frame-pointer") .addCompilerFlag("-fno-strict-aliasing")); toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.DBG) .addCompilerFlag("-g") .addCompilerFlag("-fno-strict-aliasing") .addCompilerFlag("-O0") .addCompilerFlag("-UNDEBUG") .addCompilerFlag("-marm") .addCompilerFlag("-fno-omit-frame-pointer")); } else { toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.OPT) .addCompilerFlag("-O2") .addCompilerFlag("-g") .addCompilerFlag("-DNDEBUG") .addCompilerFlag("-fomit-frame-pointer") .addCompilerFlag("-fstrict-aliasing")); toolchain.addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.DBG) .addCompilerFlag("-g") .addCompilerFlag("-O0") .addCompilerFlag("-UNDEBUG") .addCompilerFlag("-fno-omit-frame-pointer") .addCompilerFlag("-fno-strict-aliasing")); } ndkPaths.addToolchainIncludePaths(toolchain, toolchainName, targetPlatform, "4.8"); return toolchain; }
private CToolchain.Builder createAarch64ClangToolchain(String clangVersion) { String toolchainName = "aarch64-linux-android-4.9"; String targetPlatform = "aarch64-linux-android"; String gccToolchain = ndkPaths.createGccToolchainPath(toolchainName); String llvmTriple = "aarch64-none-linux-android"; CToolchain.Builder toolchain = CToolchain.newBuilder() .setToolchainIdentifier("aarch64-linux-android-clang" + clangVersion) .setTargetSystemName("aarch64-linux-android") .setTargetCpu("arm64-v8a") .setCompiler("clang" + clangVersion) .addAllToolPath( ndkPaths.createClangToolpaths(toolchainName, targetPlatform, clangVersion)) .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("arm64")) // Compiler flags .addCompilerFlag("-gcc-toolchain") .addCompilerFlag(gccToolchain) .addCompilerFlag("-target") .addCompilerFlag(llvmTriple) .addCompilerFlag("-ffunction-sections") .addCompilerFlag("-funwind-tables") .addCompilerFlag("-fstack-protector-strong") .addCompilerFlag("-fpic") .addCompilerFlag("-Wno-invalid-command-line-argument") .addCompilerFlag("-Wno-unused-command-line-argument") .addCompilerFlag("-no-canonical-prefixes") .addCompilerFlag("-fno-canonical-system-headers") // Linker flags .addLinkerFlag("-gcc-toolchain") .addLinkerFlag(gccToolchain) .addLinkerFlag("-target") .addLinkerFlag(llvmTriple) .addLinkerFlag("-no-canonical-prefixes") // Additional release flags .addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.OPT) .addCompilerFlag("-O2") .addCompilerFlag("-g") .addCompilerFlag("-DNDEBUG") .addCompilerFlag("-fomit-frame-pointer") .addCompilerFlag("-fstrict-aliasing")) // Additional debug flags .addCompilationModeFlags( CompilationModeFlags.newBuilder() .setMode(CompilationMode.DBG) .addCompilerFlag("-O0") .addCompilerFlag("-UNDEBUG") .addCompilerFlag("-fno-omit-frame-pointer") .addCompilerFlag("-fno-strict-aliasing")); ndkPaths.addToolchainIncludePaths(toolchain, toolchainName, targetPlatform, "4.9"); stlImpl.addStlImpl(toolchain, "4.9"); return toolchain; }