[PATCH] Support cross-compiling for Arm on a x86 Linux machine

Sriram Murali sriram87 at gmail.com
Fri Oct 4 18:04:25 PDT 2013


Hi, I updated the patch as per the suggestions from reviewers.

I request you to kindly see the revised patch.

Thanks
Sriram

Sent from my iPad

> On Oct 3, 2013, at 5:16 PM, "Murali, Sriram" <sriram.murali at intel.com> wrote:
>
> Hi there,
> I am attempting to cross-compile for Arm devices on a x86 machine. Looks like clang is picking up library paths in the wrong order, that it chose a different library file in /usr/lib32 directory, since I am compiling for arm. So, I worked around it by choosing the libpath of GNU cross compiler for arm instead.
>
> Further, there was a problem including the right header files from bits/ directory. So, I made sure clang picked it up from the GNU cross compiler include directory. However, clang did not have support to pick up include files from GCC version with no Patch, for example "4.8.0", where GCC version is of the format "Major.Minor.Patch". It looks at 4.8 instead. But, gnu cross compiler is packed such that the include files are in a directory with name 4.8.0. So, if the Version.Patch is -1 (which is unset for versions with no Patch) , we should pick the directory with Patch = 0.
>
> Please review the patch, and see if it can be improved.
>
> Thanks
> Sriram
>
>
> -----Original Message-----
> From: Sriram Murali [mailto:sriram.murali at intel.com]
> Sent: Thursday, October 03, 2013 5:06 PM
> To: Murali, Sriram; t.p.northover at gmail.com
> Cc: amara.emerson at arm.com
> Subject: [PATCH] Support cross-compiling for Arm on a x86 Linux machine
>
> Hi msriram,
>
> This patch enables cross-compiling for Arm devices on x86 linux machine.
> It adds include and lib path to the environment looked up by Clang. On Ubuntu (possibly Debian), this will be in /usr/arm-linux-gnueabi. Clang chose a different path instead.
>
> Tested on Ubuntu
>
> http://llvm-reviews.chandlerc.com/D1823
>
> Files:
>  lib/Driver/ToolChains.cpp
>
> Index: lib/Driver/ToolChains.cpp
> ===================================================================
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -2320,6 +2320,9 @@
>                     GCCInstallation.getMultiLibSuffix(),
>                     Paths);
>
> +    // Add correct path for library crt1.o used for cross-compiling arm on
> +    // Debian (Ubuntu)
> +    addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/",
> + Paths);
>     // If the GCC installation we found is inside of the sysroot, we want to
>     // prefer libraries installed in the parent prefix of the GCC installation.
>     // It is important to *not* use these paths when the GCC installation is @@ -2590,6 +2593,23 @@
>   StringRef BiarchSuffix = GCCInstallation.getBiarchSuffix();
>   const GCCVersion &Version = GCCInstallation.getVersion();
>
> +  // Find include files for cross-compiler in GCC Version
> + {Major.Minor.0},  // instead of just {Major.Minor} for versions with
> + no patch, i.e Patch = -1  if (Version.Patch == -1) {
> +    if (addLibStdCXXIncludePaths(LibDir.str() + "/../" + TripleStr + "/include",
> +                                 "/c++/" + Version.Text + ".0", TripleStr,
> +                                 MultiLibSuffix + BiarchSuffix, DriverArgs,
> +                                 CC1Args)
> +        )
> +      return;
> +  } else {
> +    if (addLibStdCXXIncludePaths(LibDir.str() + "/../" + TripleStr + "/include",
> +                                 "/c++/" + Version.Text, TripleStr,
> +                                 MultiLibSuffix + BiarchSuffix, DriverArgs,
> +                                 CC1Args))
> +      return;
> +  }
> +
>   if (addLibStdCXXIncludePaths(
>           LibDir.str() + "/../include", "/c++/" + Version.Text, TripleStr,
>           MultiLibSuffix + BiarchSuffix, DriverArgs, CC1Args))
> <D1823.1.patch>
> _______________________________________________
> 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