OP-TEE / build

Makefiles to use OP-TEE on various platforms
109 stars 219 forks source link

toolchains.mk, get_clang.sh: upgrade to Clang 18.1.6 #762

Closed jforissier closed 5 months ago

jforissier commented 5 months ago

Update the Clang version from 12.0.0 to 18.1.6. Unfortunately, newer versions of the LLVM toolchain do not make available the pre-built compiler-rt packages for arm64 and armhf. Therefore, the way we obtain the toolchain is changed. I created a project with a Makefile and a Dockerfile [1] which allows to build Clang from scratch with the proper compiler-rt libraries for OP-TEE cross-compilation. Nothing really special, yet not a configuration that is availale pre-built in the major Linux distributions (Unbuntu). The problem is that on an x84_64 system, there is no way to install the compiler-rt builtins for a different architecture (libclang_rt.builtins-{aarch64,armhf}.a).

The new method to install Clang is thererfore to pull a pre-built image (called jforissier/clang--) from the Docker Hub, then simply extract the files contained inside, which is what the modified get_clang.sh does.

Link: https://github.com/jforissier/docker_clang [1]

jbech-linaro commented 5 months ago

Commit message: s/Unbuntu/Ubuntu/

Seems like a bit complicated way to get the stuff needed, but let's use until we have found a better way.

jenswi-linaro commented 5 months ago

If I understand correctly, you're distributing a binary you've built yourself. Can we build the compiler using buildroot instead?

jforissier commented 5 months ago

If I understand correctly, you're distributing a binary you've built yourself.

Yes

Can we build the compiler using buildroot instead?

Good idea. It may be a bit much (I mean, it will take significant time to compile on a typical development PC), but we already do a similar build for GCC on Arm64 hosts, and it would certainly make maintenance easier.

jenswi-linaro commented 5 months ago

If I understand correctly, you're distributing a binary you've built yourself.

Yes

Using that approach in CI is fine, but recommending others to install that on their development machines is something else.

Can we build the compiler using buildroot instead?

Good idea. It may be a bit much (I mean, it will take significant time to compile on a typical development PC), but we already do a similar build for GCC on Arm64 hosts, and it would certainly make maintenance easier.

Easier maintenance sounds like a selling point. :-)

jforissier commented 5 months ago

If I understand correctly, you're distributing a binary you've built yourself.

Yes

Using that approach in CI is fine, but recommending others to install that on their development machines is something else.

We're not installing anything, just unpacking the Clang binaries in <proj_root>/clang-18.1.6 in the same way we used to download and extract the Clang 12 binary packages into <proj_root>/clang-12.0.0 in the previous version of make clang-toolchains. The main difference being, instead of the binaries coming from llvm.org (which doesn't have everything we need anymore), they come from a Docker image I built myself and stored on the Docker Hub.

Can we build the compiler using buildroot instead?

Good idea. It may be a bit much (I mean, it will take significant time to compile on a typical development PC), but we already do a similar build for GCC on Arm64 hosts, and it would certainly make maintenance easier.

Easier maintenance sounds like a selling point. :-)

:)

jenswi-linaro commented 5 months ago

If I understand correctly, you're distributing a binary you've built yourself.

Yes

Using that approach in CI is fine, but recommending others to install that on their development machines is something else.

We're not installing anything, just unpacking the Clang binaries in <proj_root>/clang-18.1.6 in the same way we used to download and extract the Clang 12 binary packages into <proj_root>/clang-12.0.0 in the previous version of make clang-toolchains. The main difference being, instead of the binaries coming from llvm.org (which doesn't have everything we need anymore), they come from a Docker image I built myself and stored on the Docker Hub.

That's not my point. The point is that the binaries are executing on the development machines.

jforissier commented 5 months ago

I could not find a way to build Clang with Buildroot, not with all we need anyways. There is a clang command in the host directory but it is not a cross compiler. Then I can find libclang.so and llvm-* tools under target but no clang command and no libclang_rt libraries. The documentation is quite scarce... Moreover it takes forever to build because Buildroot first builds a specific version of GCC with whatever GCC is available, then it builds LLVM. I think people who want to build everything themselves are better off re-using the Dockerfile: https://github.com/jforissier/docker_clang/blob/master/Dockerfile

jforissier commented 5 months ago

Superseded by #765.