From 7f69fe363412f04418fdc171cdb2e93710d9ac3c Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Mon, 10 Feb 2025 08:15:26 -0800 Subject: [PATCH] libpfm@4.11.0.bcr.1 - Build using rules_cc vs rules_foreign_cc (#3764) This has been tested against [googlebench:`9d8201efd4cbbe6271d0579ec2047dbfc396d22d`](https://github.com/google/benchmark/tree/9d8201efd4cbbe6271d0579ec2047dbfc396d22d) using the following diff ```diff diff --git a/MODULE.bazel b/MODULE.bazel index 62a3aa8..107a955 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,6 +12,10 @@ bazel_dep(name = "rules_python", version = "1.0.0", dev_dependency = True) bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True, repo_name = "com_google_googletest") bazel_dep(name = "libpfm", version = "4.11.0") +local_path_override( + module_name = "libpfm", + path = "../libpfm", +) # Register a toolchain for Python 3.9 to be able to build numpy. Python # versions >=3.10 are problematic. ``` ``` ~/google_benchmark$ bazel test //test/... WARNING: For repository 'platforms', the root module requires module version platforms@0.0.10, but got platforms@0.0.11 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off WARNING: For repository 'rules_cc', the root module requires module version rules_cc@0.0.9, but got rules_cc@0.0.17 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off WARNING: For repository 'com_google_googletest', the root module requires module version googletest@1.14.0, but got googletest@1.14.0.bcr.1 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off INFO: Analyzed 44 targets (1 packages loaded, 105 targets configured). INFO: Found 1 target and 43 test targets... INFO: Elapsed time: 21.765s, Critical Path: 19.76s INFO: 285 processes: 5 action cache hit, 101 internal, 184 linux-sandbox. INFO: Build completed successfully, 285 total actions //test:args_product_test PASSED in 0.3s //test:basic_test PASSED in 1.3s //test:benchmark_gtest PASSED in 0.1s //test:benchmark_min_time_flag_iters_test PASSED in 0.1s //test:benchmark_min_time_flag_time_test PASSED in 17.0s //test:benchmark_name_gtest PASSED in 0.0s //test:benchmark_random_interleaving_gtest PASSED in 0.1s //test:benchmark_setup_teardown_test PASSED in 0.1s //test:benchmark_test PASSED in 5.8s //test:commandlineflags_gtest PASSED in 0.0s //test:complexity_test PASSED in 3.5s //test:cxx03_test PASSED in 7.9s //test:diagnostics_test PASSED in 0.1s //test:display_aggregates_only_test PASSED in 0.1s //test:donotoptimize_test PASSED in 0.1s //test:filter_test PASSED in 0.2s //test:fixture_test PASSED in 0.1s //test:internal_threading_test PASSED in 1.9s //test:link_main_test PASSED in 0.9s //test:map_test PASSED in 0.3s //test:memory_manager_test PASSED in 0.1s //test:min_time_parse_gtest PASSED in 0.6s //test:multiple_ranges_test PASSED in 0.5s //test:options_test PASSED in 5.3s //test:perf_counters_gtest PASSED in 0.1s //test:perf_counters_test PASSED in 0.1s //test:profiler_manager_gtest PASSED in 0.2s //test:profiler_manager_iterations_test PASSED in 0.1s //test:profiler_manager_test PASSED in 0.1s //test:register_benchmark_test PASSED in 0.2s //test:repetitions_test PASSED in 0.2s //test:report_aggregates_only_test PASSED in 0.2s //test:reporter_output_test PASSED in 0.9s //test:skip_with_error_test PASSED in 0.4s //test:spec_arg_test PASSED in 0.1s //test:spec_arg_verbosity_test PASSED in 0.1s //test:statistics_gtest PASSED in 0.1s //test:string_util_gtest PASSED in 0.1s //test:templated_fixture_test PASSED in 0.1s //test:time_unit_gtest PASSED in 0.1s //test:user_counters_tabular_test PASSED in 0.8s //test:user_counters_test PASSED in 0.6s //test:user_counters_thousands_test PASSED in 0.2s Executed 43 out of 43 tests: 43 tests pass. ``` relates to https://github.com/bazelbuild/bazel/issues/24871 --------- Co-authored-by: Yun Peng --- modules/libpfm/4.11.0.bcr.1/MODULE.bazel | 8 + .../4.11.0.bcr.1/patches/add_build_file.patch | 246 ++++++++++++++++++ .../patches/module_dot_bazel.patch | 14 + modules/libpfm/4.11.0.bcr.1/presubmit.yml | 15 ++ modules/libpfm/4.11.0.bcr.1/source.json | 10 + modules/libpfm/metadata.json | 3 +- 6 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 modules/libpfm/4.11.0.bcr.1/MODULE.bazel create mode 100644 modules/libpfm/4.11.0.bcr.1/patches/add_build_file.patch create mode 100644 modules/libpfm/4.11.0.bcr.1/patches/module_dot_bazel.patch create mode 100644 modules/libpfm/4.11.0.bcr.1/presubmit.yml create mode 100644 modules/libpfm/4.11.0.bcr.1/source.json diff --git a/modules/libpfm/4.11.0.bcr.1/MODULE.bazel b/modules/libpfm/4.11.0.bcr.1/MODULE.bazel new file mode 100644 index 00000000000..61f396be7eb --- /dev/null +++ b/modules/libpfm/4.11.0.bcr.1/MODULE.bazel @@ -0,0 +1,8 @@ +module( + name = "libpfm", + version = "4.11.0.bcr.1", + compatibility_level = 1, +) + +bazel_dep(name = "platforms", version = "0.0.11") +bazel_dep(name = "rules_cc", version = "0.0.17") diff --git a/modules/libpfm/4.11.0.bcr.1/patches/add_build_file.patch b/modules/libpfm/4.11.0.bcr.1/patches/add_build_file.patch new file mode 100644 index 00000000000..67e16c93a6b --- /dev/null +++ b/modules/libpfm/4.11.0.bcr.1/patches/add_build_file.patch @@ -0,0 +1,246 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +new file mode 100644 +index 0000000..70a84e0 +--- /dev/null ++++ b/BUILD.bazel +@@ -0,0 +1,240 @@ ++load("@rules_cc//cc:defs.bzl", "cc_library") ++ ++AARCH32_SRCS_COMMON = [ ++ "lib/pfmlib_arm.c", ++ "lib/pfmlib_arm_armv7_pmuv1.c", ++ "lib/pfmlib_arm_armv6.c", ++ "lib/pfmlib_arm_armv8.c", ++ "lib/pfmlib_tx2_unc_perf_event.c", ++] ++ ++AARCH32_SRCS_LINUX = [ ++ "lib/pfmlib_arm_perf_event.c", ++] ++ ++AARCH64_SRCS_COMMON = [ ++ "lib/pfmlib_arm.c", ++ "lib/pfmlib_arm_armv8.c", ++ "lib/pfmlib_tx2_unc_perf_event.c", ++] ++ ++AARCH64_SRCS_LINUX = [ ++ "lib/pfmlib_arm_perf_event.c", ++] ++ ++MIPS_SRCS_COMMON = [ ++ "lib/pfmlib_mips.c", ++ "lib/pfmlib_mips_74k.c", ++] ++ ++MIPS_SRCS_LINUX = [ ++ "lib/pfmlib_mips_perf_event.c", ++] ++ ++POWERPC_SRCS_COMMON = [ ++ "lib/pfmlib_powerpc.c", ++ "lib/pfmlib_power4.c", ++ "lib/pfmlib_ppc970.c", ++ "lib/pfmlib_power5.c", ++ "lib/pfmlib_power6.c", ++ "lib/pfmlib_power7.c", ++ "lib/pfmlib_torrent.c", ++ "lib/pfmlib_power8.c", ++ "lib/pfmlib_power9.c", ++ "lib/pfmlib_powerpc_nest.c", ++] ++ ++POWERPC_SRCS_LINUX = [ ++ "lib/pfmlib_powerpc_perf_event.c", ++] ++ ++S390X_SRCS_COMMON = [ ++ "lib/pfmlib_s390x_cpumf.c", ++] ++ ++S390X_SRCS_LINUX = [ ++ "lib/pfmlib_s390x_perf_event.c", ++] ++ ++X86_64_SRCS_COMMON = [ ++ "lib/pfmlib_amd64.c", ++ "lib/pfmlib_intel_core.c", ++ "lib/pfmlib_intel_x86.c", ++ "lib/pfmlib_intel_x86_arch.c", ++ "lib/pfmlib_intel_atom.c", ++ "lib/pfmlib_intel_nhm_unc.c", ++ "lib/pfmlib_intel_nhm.c", ++ "lib/pfmlib_intel_wsm.c", ++ "lib/pfmlib_intel_snb.c", ++ "lib/pfmlib_intel_snb_unc.c", ++ "lib/pfmlib_intel_ivb.c", ++ "lib/pfmlib_intel_ivb_unc.c", ++ "lib/pfmlib_intel_hsw.c", ++ "lib/pfmlib_intel_bdw.c", ++ "lib/pfmlib_intel_skl.c", ++ "lib/pfmlib_intel_icl.c", ++ "lib/pfmlib_intel_rapl.c", ++ "lib/pfmlib_intel_snbep_unc.c", ++ "lib/pfmlib_intel_snbep_unc_cbo.c", ++ "lib/pfmlib_intel_snbep_unc_ha.c", ++ "lib/pfmlib_intel_snbep_unc_imc.c", ++ "lib/pfmlib_intel_snbep_unc_pcu.c", ++ "lib/pfmlib_intel_snbep_unc_qpi.c", ++ "lib/pfmlib_intel_snbep_unc_ubo.c", ++ "lib/pfmlib_intel_snbep_unc_r2pcie.c", ++ "lib/pfmlib_intel_snbep_unc_r3qpi.c", ++ "lib/pfmlib_intel_ivbep_unc_cbo.c", ++ "lib/pfmlib_intel_ivbep_unc_ha.c", ++ "lib/pfmlib_intel_ivbep_unc_imc.c", ++ "lib/pfmlib_intel_ivbep_unc_pcu.c", ++ "lib/pfmlib_intel_ivbep_unc_qpi.c", ++ "lib/pfmlib_intel_ivbep_unc_ubo.c", ++ "lib/pfmlib_intel_ivbep_unc_r2pcie.c", ++ "lib/pfmlib_intel_ivbep_unc_r3qpi.c", ++ "lib/pfmlib_intel_ivbep_unc_irp.c", ++ "lib/pfmlib_intel_hswep_unc_cbo.c", ++ "lib/pfmlib_intel_hswep_unc_ha.c", ++ "lib/pfmlib_intel_hswep_unc_imc.c", ++ "lib/pfmlib_intel_hswep_unc_pcu.c", ++ "lib/pfmlib_intel_hswep_unc_qpi.c", ++ "lib/pfmlib_intel_hswep_unc_ubo.c", ++ "lib/pfmlib_intel_hswep_unc_r2pcie.c", ++ "lib/pfmlib_intel_hswep_unc_r3qpi.c", ++ "lib/pfmlib_intel_hswep_unc_irp.c", ++ "lib/pfmlib_intel_hswep_unc_sbo.c", ++ "lib/pfmlib_intel_bdx_unc_cbo.c", ++ "lib/pfmlib_intel_bdx_unc_ubo.c", ++ "lib/pfmlib_intel_bdx_unc_sbo.c", ++ "lib/pfmlib_intel_bdx_unc_ha.c", ++ "lib/pfmlib_intel_bdx_unc_imc.c", ++ "lib/pfmlib_intel_bdx_unc_irp.c", ++ "lib/pfmlib_intel_bdx_unc_pcu.c", ++ "lib/pfmlib_intel_bdx_unc_qpi.c", ++ "lib/pfmlib_intel_bdx_unc_r2pcie.c", ++ "lib/pfmlib_intel_bdx_unc_r3qpi.c", ++ "lib/pfmlib_intel_skx_unc_cha.c", ++ "lib/pfmlib_intel_skx_unc_iio.c", ++ "lib/pfmlib_intel_skx_unc_imc.c", ++ "lib/pfmlib_intel_skx_unc_irp.c", ++ "lib/pfmlib_intel_skx_unc_m2m.c", ++ "lib/pfmlib_intel_skx_unc_m3upi.c", ++ "lib/pfmlib_intel_skx_unc_pcu.c", ++ "lib/pfmlib_intel_skx_unc_ubo.c", ++ "lib/pfmlib_intel_skx_unc_upi.c", ++ "lib/pfmlib_intel_knc.c", ++ "lib/pfmlib_intel_slm.c", ++ "lib/pfmlib_intel_tmt.c", ++ "lib/pfmlib_intel_knl.c", ++ "lib/pfmlib_intel_knl_unc_imc.c", ++ "lib/pfmlib_intel_knl_unc_edc.c", ++ "lib/pfmlib_intel_knl_unc_cha.c", ++ "lib/pfmlib_intel_knl_unc_m2pcie.c", ++ "lib/pfmlib_intel_glm.c", ++ "lib/pfmlib_intel_netburst.c", ++ "lib/pfmlib_amd64_k7.c", ++ "lib/pfmlib_amd64_k8.c", ++ "lib/pfmlib_amd64_fam10h.c", ++ "lib/pfmlib_amd64_fam11h.c", ++ "lib/pfmlib_amd64_fam12h.c", ++ "lib/pfmlib_amd64_fam14h.c", ++ "lib/pfmlib_amd64_fam15h.c", ++ "lib/pfmlib_amd64_fam17h.c", ++ "lib/pfmlib_amd64_fam16h.c", ++] ++ ++X86_SRCS_COMMON = X86_64_SRCS_COMMON + [ ++ "lib/pfmlib_intel_coreduo.c", ++ "lib/pfmlib_intel_p6.c", ++] ++ ++filegroup( ++ name = "cpu_srcs", ++ srcs = select({ ++ "@platforms//cpu:x86_32": X86_SRCS_COMMON, ++ "@platforms//cpu:x86_64": X86_64_SRCS_COMMON, ++ "@platforms//cpu:aarch32": AARCH32_SRCS_COMMON, ++ "@platforms//cpu:aarch64": AARCH64_SRCS_COMMON, ++ "@platforms//cpu:mips64": MIPS_SRCS_COMMON, ++ "@platforms//cpu:ppc32": POWERPC_SRCS_COMMON, ++ "@platforms//cpu:ppc64le": POWERPC_SRCS_COMMON, ++ "@platforms//cpu:ppc": POWERPC_SRCS_COMMON, ++ "@platforms//cpu:s390x": S390X_SRCS_COMMON, ++ "//conditions:default": [], ++ }), ++) ++ ++filegroup( ++ name = "linux_srcs", ++ srcs = select({ ++ "@platforms//cpu:aarch32": AARCH32_SRCS_LINUX, ++ "@platforms//cpu:aarch64": AARCH64_SRCS_LINUX, ++ "@platforms//cpu:mips64": MIPS_SRCS_LINUX, ++ "@platforms//cpu:ppc32": POWERPC_SRCS_LINUX, ++ "@platforms//cpu:ppc64le": POWERPC_SRCS_LINUX, ++ "@platforms//cpu:ppc": POWERPC_SRCS_LINUX, ++ "@platforms//cpu:s390x": S390X_SRCS_LINUX, ++ "//conditions:default": [], ++ }), ++) ++ ++filegroup( ++ name = "srcs", ++ srcs = [ ++ "lib/pfmlib_common.c", ++ "lib/pfmlib_perf_event.c", ++ "lib/pfmlib_perf_event_pmu.c", ++ "lib/pfmlib_perf_event_priv.h", ++ "lib/pfmlib_perf_event_raw.c", ++ "lib/pfmlib_torrent.c", ++ "lib/pfmlib_tx2_unc_perf_event.c", ++ ":cpu_srcs", ++ ] + select({ ++ "@platforms//os:linux": [":linux_srcs"], ++ "//conditions:default": [], ++ }), ++) ++ ++cc_library( ++ name = "pfm", ++ srcs = [ ++ ":srcs", ++ ], ++ hdrs = glob([ ++ "include/perfmon/*.h", ++ ]), ++ copts = [ ++ "-Wno-format-truncation", ++ "-Wno-use-after-free", ++ "-fPIC", ++ "-D_REENTRANT", ++ "-fvisibility=hidden", ++ ] + select({ ++ "@platforms//cpu:aarch32": ["-DCONFIG_PFMLIB_ARCH_ARM"], ++ "@platforms//cpu:aarch64": ["-DCONFIG_PFMLIB_ARCH_ARM64"], ++ "@platforms//cpu:mips64": ["-DCONFIG_PFMLIB_ARCH_MIPS"], ++ "@platforms//cpu:ppc32": ["-DCONFIG_PFMLIB_ARCH_POWERPC"], ++ "@platforms//cpu:ppc64le": ["-DCONFIG_PFMLIB_ARCH_POWERPC"], ++ "@platforms//cpu:ppc": ["-DCONFIG_PFMLIB_ARCH_POWERPC"], ++ "@platforms//cpu:s390x": ["-DCONFIG_PFMLIB_ARCH_S390X"], ++ "//conditions:default": [], ++ }), ++ includes = [ ++ "include", ++ "lib", ++ ], ++ strip_include_prefix = "include", ++ textual_hdrs = glob([ ++ "lib/**/*.h", ++ ]), ++ visibility = [ ++ "//visibility:public", ++ ], ++) ++ ++alias( ++ name = "libpfm", ++ actual = ":pfm", ++ visibility = [ ++ "//visibility:public", ++ ], ++) diff --git a/modules/libpfm/4.11.0.bcr.1/patches/module_dot_bazel.patch b/modules/libpfm/4.11.0.bcr.1/patches/module_dot_bazel.patch new file mode 100644 index 00000000000..a6c89f316d3 --- /dev/null +++ b/modules/libpfm/4.11.0.bcr.1/patches/module_dot_bazel.patch @@ -0,0 +1,14 @@ +diff --git a/MODULE.bazel b/MODULE.bazel +new file mode 100644 +index 0000000..61f396b +--- /dev/null ++++ b/MODULE.bazel +@@ -0,0 +1,8 @@ ++module( ++ name = "libpfm", ++ version = "4.11.0.bcr.1", ++ compatibility_level = 1, ++) ++ ++bazel_dep(name = "platforms", version = "0.0.11") ++bazel_dep(name = "rules_cc", version = "0.0.17") diff --git a/modules/libpfm/4.11.0.bcr.1/presubmit.yml b/modules/libpfm/4.11.0.bcr.1/presubmit.yml new file mode 100644 index 00000000000..558d63fb818 --- /dev/null +++ b/modules/libpfm/4.11.0.bcr.1/presubmit.yml @@ -0,0 +1,15 @@ +matrix: + platform: + - centos7 + - debian10 + - ubuntu2004 + bazel: + - "7.x" + - "8.x" +tasks: + verify_targets: + name: Verify build targets + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - '@libpfm//:libpfm' diff --git a/modules/libpfm/4.11.0.bcr.1/source.json b/modules/libpfm/4.11.0.bcr.1/source.json new file mode 100644 index 00000000000..9600fc3d120 --- /dev/null +++ b/modules/libpfm/4.11.0.bcr.1/source.json @@ -0,0 +1,10 @@ +{ + "url": "https://netcologne.dl.sourceforge.net/project/perfmon2/libpfm4/libpfm-4.11.0.tar.gz", + "integrity": "sha256-XaX4hyveFLNjTJaI2YD2i9ootRAmhyPMEpc+7bq5/sw=", + "strip_prefix": "libpfm-4.11.0", + "patches": { + "module_dot_bazel.patch": "sha256-D7BWrY0WiihCq9XSiVifZWK3sMLbI2chCsgddKJ38kM=", + "add_build_file.patch": "sha256-ibpLPyX2v/fbDytUuK4PKeZl/q303bWtSRTU95g5jz0=" + }, + "patch_strip": 1 +} diff --git a/modules/libpfm/metadata.json b/modules/libpfm/metadata.json index cba1a9af90c..cf1cec0c683 100644 --- a/modules/libpfm/metadata.json +++ b/modules/libpfm/metadata.json @@ -8,7 +8,8 @@ ], "repository": [], "versions": [ - "4.11.0" + "4.11.0", + "4.11.0.bcr.1" ], "yanked_versions": {} }