[cfe-commits] [PATCH] Fix x86 android support in clang

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Nov 2 11:36:48 PDT 2012


lgtm2.

Do you have commit access?

On 2 November 2012 08:45, Edwin Vane <edwin.vane at intel.com> wrote:
>   Fixed line break nit. These drive me nuts too!
>
> Hi eugenis,
>
> http://llvm-reviews.chandlerc.com/D91
>
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D91?vs=246&id=250#toc
>
> Files:
>   lib/Driver/Tools.cpp
>   test/Driver/clang-translation.c
>   test/Driver/linux-ld.c
>
> Index: lib/Driver/Tools.cpp
> ===================================================================
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -1088,6 +1088,8 @@
>
>  void Clang::AddX86TargetArgs(const ArgList &Args,
>                               ArgStringList &CmdArgs) const {
> +  const bool isAndroid =
> +    getToolChain().getTriple().getEnvironment() == llvm::Triple::Android;
>    if (!Args.hasFlag(options::OPT_mred_zone,
>                      options::OPT_mno_red_zone,
>                      true) ||
> @@ -1152,7 +1154,9 @@
>        if (getToolChain().getArch() == llvm::Triple::x86_64)
>          CPUName = "x86-64";
>        else if (getToolChain().getArch() == llvm::Triple::x86)
> -        CPUName = "pentium4";
> +        // All x86 devices running Android have core2 as their common
> +        // denominator. This makes a better choice than pentium4.
> +        CPUName = isAndroid ? "core2" : "pentium4";
>      }
>    }
>
> @@ -5760,8 +5764,8 @@
>    const toolchains::Linux& ToolChain =
>      static_cast<const toolchains::Linux&>(getToolChain());
>    const Driver &D = ToolChain.getDriver();
> -  const bool isAndroid = ToolChain.getTriple().getEnvironment() ==
> -    llvm::Triple::Android;
> +  const bool isAndroid =
> +    ToolChain.getTriple().getEnvironment() == llvm::Triple::Android;
>
>    ArgStringList CmdArgs;
>
> @@ -5831,8 +5835,7 @@
>        CmdArgs.push_back("-static");
>    } else if (Args.hasArg(options::OPT_shared)) {
>      CmdArgs.push_back("-shared");
> -    if ((ToolChain.getArch() == llvm::Triple::arm
> -         || ToolChain.getArch() == llvm::Triple::thumb) && isAndroid) {
> +    if (isAndroid) {
>        CmdArgs.push_back("-Bsymbolic");
>      }
>    }
> Index: test/Driver/clang-translation.c
> ===================================================================
> --- test/Driver/clang-translation.c
> +++ test/Driver/clang-translation.c
> @@ -99,3 +99,9 @@
>  // AMD64-MINGW: "-triple"
>  // AMD64-MINGW: "amd64--mingw32"
>  // AMD64-MINGW: "-munwind-tables"
> +
> +// RUN: %clang -target i386-linux-android -### -S %s 2>&1 \
> +// RUN:        --sysroot=%S/Inputs/basic_android_tree/sysroot \
> +// RUN:   | FileCheck --check-prefix=ANDROID-X86 %s
> +// ANDROID-X86: clang
> +// ANDROID-X86: "-target-cpu" "core2"
> Index: test/Driver/linux-ld.c
> ===================================================================
> --- test/Driver/linux-ld.c
> +++ test/Driver/linux-ld.c
> @@ -411,6 +411,10 @@
>  // RUN:     -target mipsel-linux-android \
>  // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
>  // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN:     -target i386-linux-android \
> +// RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
> +// RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
>  // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
>  // CHECK-ANDROID: "{{.*}}/crtbegin_dynamic.o"
>  // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
> @@ -433,7 +437,13 @@
>  // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
>  // RUN:     -shared \
>  // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-SO %s
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN:     -target i386-linux-android \
> +// RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
> +// RUN:     -shared \
> +// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-SO %s
>  // CHECK-ANDROID-SO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
> +// CHECK-ANDROID-SO: "-Bsymbolic"
>  // CHECK-ANDROID-SO: "{{.*}}/crtbegin_so.o"
>  // CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib"
>  // CHECK-ANDROID-SO-NOT: "gcc_s"
> @@ -455,6 +465,11 @@
>  // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
>  // RUN:     -static \
>  // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN:     -target i386-linux-android \
> +// RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
> +// RUN:     -static \
> +// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
>  // CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
>  // CHECK-ANDROID-STATIC: "{{.*}}/crtbegin_static.o"
>  // CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib"
> @@ -477,6 +492,11 @@
>  // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
>  // RUN:     -pie \
>  // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-PIE %s
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN:     -target i386-linux-android \
> +// RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
> +// RUN:     -pie \
> +// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-PIE %s
>  // CHECK-ANDROID-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
>  // CHECK-ANDROID-PIE: "{{.*}}/crtbegin_dynamic.o"
>  // CHECK-ANDROID-PIE: "-L[[SYSROOT]]/usr/lib"
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list