protected void addBaseStlImpl(CToolchain.Builder toolchain, String gccVersion, boolean armThumb) { toolchain .setToolchainIdentifier(toolchain.getToolchainIdentifier() + "-" + name) .setSupportsEmbeddedRuntimes(true) .setDynamicRuntimesFilegroup( createRuntimeLibrariesFilegroup( name, gccVersion, toolchain.getTargetCpu(), armThumb, RuntimeType.DYNAMIC)) .setStaticRuntimesFilegroup( createRuntimeLibrariesFilegroup( name, gccVersion, toolchain.getTargetCpu(), armThumb, RuntimeType.STATIC)); }
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; }
/** 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; }