$ mkdir llvm-toolchain && cd llvm-toolchain
$ repo init -u https://android.googlesource.com/platform/manifest -b llvm-toolchain
$ repo sync -c
初始化仓库,可以使用镜像提速。
$ python toolchain/llvm_android/build.py --lto --bolt --pgo --no-build windows
过程中会遇到各种库缺失的问题,安装对应的库后继续
这时,会出现一系列的异常,比如xxx.so,xxx.lib,xxx.a找不到,由三方库输出目录lib/lib64难以区分导致,修改后可正常编译
diff --git a/base_builders.py b/base_builders.py
index 58589a2..fea6af9 100644
--- a/base_builders.py
+++ b/base_builders.py
@@ -49,6 +49,7 @@ class LibInfo:
lib_version: str
static_lib: bool = False
+ lib_dir : str = 'lib'
@property
def install_dir(self) -> Path:
@@ -79,7 +80,7 @@ class LibInfo:
def link_libraries(self) -> List[Path]:
"""Path to the libraries used when linking."""
suffix = self._lib_suffix
- return list(self.install_dir / 'lib' / f'{name}{suffix}' for name in self._lib_names)
+ return list(self.install_dir / self.lib_dir / f'{name}{suffix}' for name in self._lib_names)
@property
def install_libraries(self) -> List[Path]:
diff --git a/builders.py b/builders.py
index cecd694..85a1a5c 100644
--- a/builders.py
+++ b/builders.py
@@ -702,6 +702,7 @@ class XzBuilder(base_builders.CMakeBuilder, base_builders.LibInfo):
src_dir: Path = paths.XZ_SRC_DIR
config_list: List[configs.Config] = [configs.host_config()]
static_lib: bool = True
+ lib_dir: str = 'lib64'
@property
def cmake_defines(self) -> Dict[str, str]:
@@ -720,6 +721,7 @@ class LibXml2Builder(base_builders.CMakeBuilder, base_builders.LibInfo):
src_dir: Path = paths.LIBXML2_SRC_DIR
config_list: List[configs.Config] = [configs.host_config()]
lib_version: str = '2.9.13'
+ lib_dir: str = 'lib64'
@contextlib.contextmanager
def _backup_file(self, file_to_backup: Path) -> Iterator[None]:
@@ -760,7 +762,7 @@ class LibXml2Builder(base_builders.CMakeBuilder, base_builders.LibInfo):
if self._config.target_os.is_windows:
return []
ext = 'so' if self._config.target_os.is_linux else 'dylib'
- return [self.install_dir / 'lib' / f'libxml2.{ext}']
+ return [self.install_dir / self.lib_dir / f'libxml2.{ext}']
class LldbServerBuilder(base_builders.LLVMRuntimeBuilder):