From f92d8840752be9f4c25474c02cb0a76dd76d72d4 Mon Sep 17 00:00:00 2001 From: yp9522 Date: Sat, 13 Apr 2024 21:07:13 +0800 Subject: [PATCH] [Build] Add libabigail for llvm_toolchain 1. Modify the path where llvm build/abi_check.py receives incoming abidw and adidiff 2. Modify llvm build/build. py to compile Abligail to generate Abidw and Adidiff during Abi check Issue:https://gitee.com/openharmony/third_party_llvm-project/issues/I9GEJ2 Test: Add some ABI public functions to use build. python3 ./toolchain/llvm-project/llvm-build/build.py --enable-check-abi Change-Id: I345e2350f203cb3c51c246c49e09b82269d6746d Signed-off-by: yp9522 --- llvm-build/abi_check.py | 25 ++++++++++++++++--- llvm-build/build.py | 6 +++++ .../aarch64-linux-ohos/libc++_shared.abi | 2 +- .../a7_hard_neon-vfpv4/libc++_shared.abi | 2 +- .../arm-linux-ohos/a7_soft/libc++_shared.abi | 2 +- .../a7_softfp_neon-vfpv4/libc++_shared.abi | 2 +- .../arm-linux-ohos/libc++_shared.abi | 2 +- .../a7_hard_neon-vfpv4/libc++_shared.abi | 2 +- .../arm-liteos-ohos/a7_soft/libc++_shared.abi | 2 +- .../a7_softfp_neon-vfpv4/libc++_shared.abi | 2 +- .../arm-liteos-ohos/libc++_shared.abi | 2 +- .../mipsel-linux-ohos/libc++_shared.abi | 2 +- .../nanlegacy/libc++_shared.abi | 2 +- .../riscv64-linux-ohos/libc++_shared.abi | 2 +- .../x86_64-linux-ohos/libc++_shared.abi | 2 +- llvm_products/llvm_build.json | 4 +++ 16 files changed, 45 insertions(+), 16 deletions(-) diff --git a/llvm-build/abi_check.py b/llvm-build/abi_check.py index e3d6621881d0..3d36c8b76225 100755 --- a/llvm-build/abi_check.py +++ b/llvm-build/abi_check.py @@ -37,7 +37,9 @@ class AbiCheck: headers_dir1=None, headers_dir2=None, show_size_offset=None, - compare_files=None + compare_files=None, + abidw_path=None, + abidff_path=None ) source_dict = vars(args) self.args.__dict__.update(source_dict) @@ -93,10 +95,13 @@ class AbiCheck: all_args.extend(["--annotate"]) all_args.extend(["--out-file", self.args.abi_file]) all_args.extend([self.args.elf_file]) - command = ["abidw"] + all_args + command = [self.args.abidw_path] + all_args return command def gen_abi_file(self): + if self.args.abidw_path is None: + logging.error("abidw_path is None, please check your config") + return if self.args.elf_file is None: logging.error("elf-file is None, please check your file") return @@ -131,10 +136,13 @@ class AbiCheck: size_offset = self.get_show_size_offset(self.args.show_size_offset) all_args.extend([f"--show-{size_offset}"]) all_args.extend(self.args.compare_files) - command = ["abidiff"] + all_args + command = [self.args.abidiff_path] + all_args return command def compare_abi_files(self, timeout=10): + if self.args.abidiff_path is None: + logging.error("abidiff_path is None, please check your config") + return if self.args.compare_files is None: logging.error("elf_file is None, please check your file") return False @@ -144,10 +152,15 @@ class AbiCheck: start_new_session=True) as process: output, errs = process.communicate(timeout=timeout) out_str = output.decode() + errs_str = errs.decode() if out_str is not None and out_str != "": logging.warning("cmd_string is : %s", cmd_string) logging.warning(out_str) return True + elif errs_str is not None and errs_str != "" : + logging.warning("cmd_string is : %s", cmd_string) + logging.warning(errs_str) + return True else: return False @@ -158,6 +171,9 @@ def parse_abi_check_args(): parser.add_argument('--suppressions', help=' specify a suppression file') parser.add_argument('--no-show-locs', action='store_true', default=False, help='do not show location information') gen_abi = parser.add_argument_group("gen_abi_file") + gen_abi.add_argument( + '--abidw-path', + help='abidw-path') gen_abi.add_argument( '--elf-file', help='elf-file to gen abi-file') @@ -181,6 +197,9 @@ def parse_abi_check_args(): default=False, help='annotate the ABI artifacts emitted in the output') compare_abi = parser.add_argument_group("compare_abi") + compare_abi.add_argument( + '--abidff-path', + help='abidff path') compare_abi.add_argument( '--compare-files', nargs=2, diff --git a/llvm-build/build.py b/llvm-build/build.py index bef40a27305b..cd0aa2ed608d 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -1916,6 +1916,9 @@ class LlvmLibs(BuildUtils): os.makedirs(os.path.join(windows64_install, 'bin')) shutil.copyfile(os.path.join(libxml2_build_path, 'libxml2.dll'), os.path.join(windows64_install, 'bin', 'libxml2.dll')) + def build_abi_check_tools(self): + self.sysroot_composer.run_hb_build('llvm_build', 'arm', 'libabigail-tools_host_toolchain') + def run_abi_checks(self, enable_check_abi, llvm_install, configs): diff_dict = {} for (arch, target) in configs: @@ -1955,6 +1958,8 @@ class LlvmLibs(BuildUtils): def run_abi_check(self, elf_file_path, abi_file_path, baseline_abi_file_path, header_dir): abi_args = argparse.Namespace() + abi_args.abidw_path = self.merge_out_path("llvm_build", "clang_x64", "thirdparty", "libabigail", "abidw") + abi_args.abidiff_path = self.merge_out_path("llvm_build", "clang_x64", "thirdparty", "libabigail", "abidiff") abi_args.elf_file = elf_file_path abi_args.abi_file = abi_file_path abi_args.compare_files = [baseline_abi_file_path, abi_file_path] @@ -2572,6 +2577,7 @@ def main(): for (arch, target) in configs: llvm_libs.build_libs(llvm_install, target) if build_config.enable_check_abi: + llvm_libs.build_abi_check_tools() has_diff = llvm_libs.run_abi_checks(build_config.enable_check_abi, llvm_install, configs) if has_diff: print("Build is interrupted because of libCxx ABI changed") diff --git a/llvm-build/libcxx_abidiff/aarch64-linux-ohos/libc++_shared.abi b/llvm-build/libcxx_abidiff/aarch64-linux-ohos/libc++_shared.abi index 757c2c4e24a7..41a8f3784672 100644 --- a/llvm-build/libcxx_abidiff/aarch64-linux-ohos/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/aarch64-linux-ohos/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_hard_neon-vfpv4/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_hard_neon-vfpv4/libc++_shared.abi index 9ab042d5bce0..8c85a895e049 100644 --- a/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_hard_neon-vfpv4/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_hard_neon-vfpv4/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_soft/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_soft/libc++_shared.abi index 9ab042d5bce0..8c85a895e049 100644 --- a/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_soft/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_soft/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi index 9ab042d5bce0..8c85a895e049 100644 --- a/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-linux-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-linux-ohos/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-linux-ohos/libc++_shared.abi index 9ab042d5bce0..8c85a895e049 100644 --- a/llvm-build/libcxx_abidiff/arm-linux-ohos/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-linux-ohos/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_hard_neon-vfpv4/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_hard_neon-vfpv4/libc++_shared.abi index 60a1c87eaead..3e3edf24e5aa 100644 --- a/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_hard_neon-vfpv4/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_hard_neon-vfpv4/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_soft/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_soft/libc++_shared.abi index 60a1c87eaead..3e3edf24e5aa 100644 --- a/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_soft/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_soft/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi index 60a1c87eaead..3e3edf24e5aa 100644 --- a/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-liteos-ohos/a7_softfp_neon-vfpv4/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/arm-liteos-ohos/libc++_shared.abi b/llvm-build/libcxx_abidiff/arm-liteos-ohos/libc++_shared.abi index 60a1c87eaead..3e3edf24e5aa 100644 --- a/llvm-build/libcxx_abidiff/arm-liteos-ohos/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/arm-liteos-ohos/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/mipsel-linux-ohos/libc++_shared.abi b/llvm-build/libcxx_abidiff/mipsel-linux-ohos/libc++_shared.abi index 65cda7fbf299..1fd5cac270a8 100644 --- a/llvm-build/libcxx_abidiff/mipsel-linux-ohos/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/mipsel-linux-ohos/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/mipsel-linux-ohos/nanlegacy/libc++_shared.abi b/llvm-build/libcxx_abidiff/mipsel-linux-ohos/nanlegacy/libc++_shared.abi index 65cda7fbf299..1fd5cac270a8 100644 --- a/llvm-build/libcxx_abidiff/mipsel-linux-ohos/nanlegacy/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/mipsel-linux-ohos/nanlegacy/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/riscv64-linux-ohos/libc++_shared.abi b/llvm-build/libcxx_abidiff/riscv64-linux-ohos/libc++_shared.abi index d8e41fef4660..4c4c03ef9dcd 100644 --- a/llvm-build/libcxx_abidiff/riscv64-linux-ohos/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/riscv64-linux-ohos/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm-build/libcxx_abidiff/x86_64-linux-ohos/libc++_shared.abi b/llvm-build/libcxx_abidiff/x86_64-linux-ohos/libc++_shared.abi index f14d3a5e3797..adb0c18d70e8 100644 --- a/llvm-build/libcxx_abidiff/x86_64-linux-ohos/libc++_shared.abi +++ b/llvm-build/libcxx_abidiff/x86_64-linux-ohos/libc++_shared.abi @@ -1,4 +1,4 @@ - + diff --git a/llvm_products/llvm_build.json b/llvm_products/llvm_build.json index a5a7061492af..b56ead5d4873 100644 --- a/llvm_products/llvm_build.json +++ b/llvm_products/llvm_build.json @@ -12,6 +12,10 @@ { "component": "musl", "features": [] + }, + { + "component": "libabigail", + "features": [] } ] }, -- Gitee