tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.87k stars 326 forks source link

Building compiler-rt with `build_compiler_rt.sh` fails #387

Closed cschol closed 1 year ago

cschol commented 1 year ago

Building compiler-rt using build_compiler_rt.sh fails in 564e2b9aa8e7a40da663d890c0e853a1259ff8b1.

I follow these steps in order:

  1. Build clang
  2. Build osxcross
  3. Build compiler-rt

The problem manifests itself as follows: Building clang extracts a tarball of sources via bsdtar into the build directory. This includes a directory called compiler-rt, which contains the compiler-rt source code.

When building compiler-rt via build_compiler_rt.sh, the build scripts try to create a build tree for compiler-rt in the build directory and clone the sources. Since the compiler-rt directory already exists, the build scripts fail when trying to perform git operations on the directory, which is not an actual git repository (git clean fails).

A solution is have build_compiler_rt.sh check if the build/compiler-rt directory is a build project, for example contains the build/compiler-rt/compiler-rt directory. The tarball just extracts compiler-rt source into build/compiler-rt, which is not a build project per the scripts. If build/compiler-rt is not a build project, we delete the directory and have the build scripts recreate the build project.