Index: lib/Driver/ToolChains.cpp =================================================================== --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -3618,11 +3618,14 @@ getTriple().getArch() == llvm::Triple::mips64el; const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || getTriple().getArch() == llvm::Triple::ppc64le; + const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64; + + SanitizerMask Res = ToolChain::getSupportedSanitizers(); Res |= SanitizerKind::Address; Res |= SanitizerKind::KernelAddress; Res |= SanitizerKind::Vptr; - if (IsX86_64 || IsMIPS64) { + if (IsX86_64 || IsMIPS64 || IsAArch64) { Res |= SanitizerKind::DataFlow; Res |= SanitizerKind::Leak; Res |= SanitizerKind::Thread; Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2488,11 +2488,19 @@ static void linkSanitizerRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) { + bool isAndroid = TC.getTriple().getEnvironment() == llvm::Triple::Android; // Force linking against the system libraries sanitizers depends on // (see PR15823 why this is necessary). CmdArgs.push_back("--no-as-needed"); - CmdArgs.push_back("-lpthread"); - CmdArgs.push_back("-lrt"); + if (!isAndroid) { + // android does not need explicit links against pthread nor + // librt. (i.e. they don't exist!) + CmdArgs.push_back("-lpthread"); + CmdArgs.push_back("-lrt"); + } else { + // on android, we need -pie + CmdArgs.push_back("-pie"); + } CmdArgs.push_back("-lm"); // There's no libdl on FreeBSD. if (TC.getTriple().getOS() != llvm::Triple::FreeBSD) @@ -2512,8 +2520,10 @@ // Collect static runtimes. if (Args.hasArg(options::OPT_shared) || - (TC.getTriple().getEnvironment() == llvm::Triple::Android)) { + (TC.getTriple().getEnvironment() == llvm::Triple::Android && + TC.getTriple().getArch() != llvm::Triple::aarch64)) { // Don't link static runtimes into DSOs or if compiling for Android. + // put in an exception for aarch64 return; } if (SanArgs.needsAsanRt()) {