From 434c449b606da91a5b316346a12124dc67b96530 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Mon, 26 Jan 2026 14:38:06 -0800 Subject: [PATCH] Update rules_hdl to use more bzlmod deps. This is in preparation to use parts of ortools that use eigen, which conflicts with how rules_hdl sets up ortools+eigen. While we're at it, let's bump to the latest rules_hdl. Related: hdl/bazel_rules_hdl#336 PiperOrigin-RevId: 861361594 --- MODULE.bazel | 9 ++++ MODULE.bazel.lock | 3 +- .../rules_hdl/rename_eigen.patch | 26 ++++++++++++ .../rules_hdl/rename_swig.patch | 29 +++++++++++++ .../rules_hdl/rules_hdl_deps.patch | 42 +++++++++++++++++++ .../rules_hdl/swig_bzlmod.patch | 20 +++++++++ dependency_support/rules_hdl/workspace.bzl | 11 +++-- xls/dslx/stdlib/tests/BUILD | 6 +-- 8 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 dependency_support/rules_hdl/rename_eigen.patch create mode 100644 dependency_support/rules_hdl/rename_swig.patch create mode 100644 dependency_support/rules_hdl/rules_hdl_deps.patch create mode 100644 dependency_support/rules_hdl/swig_bzlmod.patch diff --git a/MODULE.bazel b/MODULE.bazel index 2479f270be..81f20dd37a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -115,6 +115,7 @@ maven.artifact( ) # Used both by XLS and rules_hdl. +bazel_dep(name = "eigen", version = "4.0.0-20241125.bcr.2") bazel_dep(name = "rules_pkg", version = "1.2.0") # Workaround suggested by a Bazel team member; only needed for WORKSPACE to work correctly. @@ -127,6 +128,14 @@ proto_bazel_features(name = "proto_bazel_features") bazel_dep(name = "rules_bison", version = "0.3") bazel_dep(name = "rules_flex", version = "0.3") bazel_dep(name = "rules_m4", version = "0.3") +bazel_dep(name = "swig", version = "4.3.0") + +# TODO: rigge - Remove this override once the patch is in the main repo. +single_version_override( + module_name = "swig", + patch_strip = 1, + patches = ["//dependency_support/rules_hdl:swig_bzlmod.patch"], +) # Dev dependencies bazel_dep(name = "fuzztest", version = "20250805.0", dev_dependency = True, repo_name = "com_google_fuzztest") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index b657fe59eb..3c139ab86e 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -251,7 +251,8 @@ "https://bcr.bazel.build/modules/cython/3.0.11-1/MODULE.bazel": "868b3f5c956c3657420d2302004c6bb92606bfa47e314bab7f2ba0630c7c966c", "https://bcr.bazel.build/modules/cython/3.0.11-1/source.json": "da318be900b8ca9c3d1018839d3bebc5a8e1645620d0848fa2c696d4ecf7c296", "https://bcr.bazel.build/modules/eigen/3.4.0.bcr.2/MODULE.bazel": "23fd0e097bfc0952632b854377b79ccee80fd473db6d55e0e26fce80a919f0c5", - "https://bcr.bazel.build/modules/eigen/3.4.0.bcr.2/source.json": "517be47a2886a9fd0918674f381a6ff1b9db6468af36f062e0c03b2f4a419ef6", + "https://bcr.bazel.build/modules/eigen/4.0.0-20241125.bcr.2/MODULE.bazel": "c91e304c16bf95884333152b383a32aacdcfbde3b06f9f4908d31e6f60e44404", + "https://bcr.bazel.build/modules/eigen/4.0.0-20241125.bcr.2/source.json": "fbc35faefa352e7ab59a0175d809f05f2205712a34f06f3f52c807c8fe00267b", "https://bcr.bazel.build/modules/envoy_api/0.0.0-20241214-918efc9/MODULE.bazel": "24e05f6f52f37be63a795192848555a2c8c855e7814dbc1ed419fb04a7005464", "https://bcr.bazel.build/modules/envoy_api/0.0.0-20250128-4de3c74/MODULE.bazel": "1fe72489212c530086e3ffb0e018b2bfef4663200ca03571570f9f006bef1d75", "https://bcr.bazel.build/modules/envoy_api/0.0.0-20250128-4de3c74/source.json": "028519164a2e24563f4b43d810fdedc702daed90e71e7042d45ba82ad807b46f", diff --git a/dependency_support/rules_hdl/rename_eigen.patch b/dependency_support/rules_hdl/rename_eigen.patch new file mode 100644 index 0000000000..bc5642d67a --- /dev/null +++ b/dependency_support/rules_hdl/rename_eigen.patch @@ -0,0 +1,26 @@ +diff --git a/dependency_support/com_github_yosyshq_nextpnr/bundled.BUILD.bazel b/dependency_support/com_github_yosyshq_nextpnr/bundled.BUILD.bazel +index ca6a2f7..b63fd7a 100644 +--- dependency_support/com_github_yosyshq_nextpnr/bundled.BUILD.bazel ++++ dependency_support/com_github_yosyshq_nextpnr/bundled.BUILD.bazel +@@ -42,7 +42,7 @@ DEPS = [ + "@boost//:python", + "@boost//:system", + "@boost//:thread", +- "@eigen//:eigen3", ++ "@eigen//:eigen", + "@rules_python//python/cc:current_py_cc_headers", + ] + +diff --git a/dependency_support/org_theopenroadproject/build_helper.bzl b/dependency_support/org_theopenroadproject/build_helper.bzl +index fd4259c..2b58b21 100644 +--- dependency_support/org_theopenroadproject/build_helper.bzl ++++ dependency_support/org_theopenroadproject/build_helper.bzl +@@ -299,7 +299,7 @@ OPENROAD_LIBRARY_DEPS = [ + "@boost//:property_tree", + "@boost//:stacktrace", + "@boost//:thread", +- "@eigen//:eigen3", ++ "@eigen//:eigen", + "@com_github_quantamhd_lemon//:lemon", + "@org_llvm_openmp//:openmp", + "@com_github_gabime_spdlog//:spdlog", diff --git a/dependency_support/rules_hdl/rename_swig.patch b/dependency_support/rules_hdl/rename_swig.patch new file mode 100644 index 0000000000..2192c7305a --- /dev/null +++ b/dependency_support/rules_hdl/rename_swig.patch @@ -0,0 +1,29 @@ +index b5c1242..7a43e4f 100644 +--- dependency_support/org_theopenroadproject/tcl_wrap_cc.bzl ++++ dependency_support/org_theopenroadproject/tcl_wrap_cc.bzl +@@ -85,6 +85,9 @@ def _tcl_wrap_cc_impl(ctx): + outputs = [output_file], + inputs = src_inputs, + arguments = [args], ++ env = { ++ "SWIG_LIB": "external/swig~/Lib", ++ }, +- tools = ctx.files._swig, ++ tools = ctx.files._swig_lib, + executable = ([file for file in ctx.files._swig if file.basename == "swig"][0]), + ) +@@ -135,8 +138,13 @@ tcl_wrap_cc = rule( + "swig_options": attr.string_list( + doc = "args to pass directly to the swig binary", + ), ++ "_swig_lib": attr.label( ++ default = "@swig//:lib_tcl", ++ allow_files = True, ++ cfg = "exec", ++ ), + "_swig": attr.label( +- default = "@org_swig//:swig_stable", ++ default = "@swig//:swig", + allow_files = True, + cfg = "exec", + ), diff --git a/dependency_support/rules_hdl/rules_hdl_deps.patch b/dependency_support/rules_hdl/rules_hdl_deps.patch new file mode 100644 index 0000000000..ef47a5c8d7 --- /dev/null +++ b/dependency_support/rules_hdl/rules_hdl_deps.patch @@ -0,0 +1,42 @@ +diff --git a/dependency_support/dependency_support.bzl b/dependency_support/dependency_support.bzl +index 5f559a7..310c40f 100644 +--- dependency_support/dependency_support.bzl ++++ dependency_support/dependency_support.bzl +@@ -32,10 +32,6 @@ load("//dependency_support/com_github_westes_flex:com_github_westes_flex.bzl", " + load("//dependency_support/com_github_yosyshq_nextpnr:com_github_yosyshq_nextpnr.bzl", "com_github_yosyshq_nextpnr") + load("//dependency_support/com_github_yosyshq_prjtrellis:com_github_yosyshq_prjtrellis.bzl", "com_github_yosyshq_prjtrellis") + load("//dependency_support/com_github_yosyshq_prjtrellis_db:com_github_yosyshq_prjtrellis_db.bzl", "com_github_yosyshq_prjtrellis_db") +-load("//dependency_support/com_google_absl:com_google_absl.bzl", "com_google_absl") +-load("//dependency_support/com_google_googletest:com_google_googletest.bzl", "com_google_googletest") +-load("//dependency_support/com_google_ortools:com_google_ortools.bzl", "com_google_ortools") +-load("//dependency_support/com_google_protobuf:com_google_protobuf.bzl", "com_google_protobuf") + load("//dependency_support/com_google_skywater_pdk:com_google_skywater_pdk.bzl", "com_google_skywater_pdk") + load("//dependency_support/com_icarus_iverilog:com_icarus_iverilog.bzl", "com_icarus_iverilog") + load("//dependency_support/com_opencircuitdesign_magic:com_opencircuitdesign_magic.bzl", "com_opencircuitdesign_magic") +@@ -55,7 +51,6 @@ load("//dependency_support/org_nixos_patchelf:org_nixos_patchelf.bzl", "org_nixo + load("//dependency_support/org_pcre_ftp:org_pcre_ftp.bzl", "org_pcre_ftp") + load("//dependency_support/org_sourceware_bzip2:org_sourceware_bzip2.bzl", "org_sourceware_bzip2") + load("//dependency_support/org_sourceware_libffi:org_sourceware_libffi.bzl", "org_sourceware_libffi") +-load("//dependency_support/org_swig:org_swig.bzl", "org_swig") + load("//dependency_support/org_theopenroadproject:org_theopenroadproject.bzl", "org_theopenroadproject") + load("//dependency_support/org_theopenroadproject_asap7_pdk_r1p7:org_theopenroadproject_asap7_pdk_r1p7.bzl", "org_theopenroadproject_asap7_pdk_r1p7") + load("//dependency_support/org_theopenroadproject_asap7sc6t_26:org_theopenroadproject_asap7sc6t_26.bzl", "org_theopenroadproject_asap7sc6t_26") +@@ -86,10 +81,6 @@ def dependency_support(register_toolchains = True): + com_github_yosyshq_nextpnr() + com_github_yosyshq_prjtrellis() + com_github_yosyshq_prjtrellis_db() +- com_google_absl() +- com_google_googletest() +- com_google_protobuf() +- com_google_ortools() + com_google_skywater_pdk() + com_icarus_iverilog() + com_opencircuitdesign_magic() +@@ -109,7 +100,6 @@ def dependency_support(register_toolchains = True): + org_pcre_ftp() + org_sourceware_bzip2() + org_sourceware_libffi() +- org_swig() + org_theopenroadproject() + org_theopenroadproject_asap7_pdk_r1p7() + org_theopenroadproject_asap7sc6t_26() diff --git a/dependency_support/rules_hdl/swig_bzlmod.patch b/dependency_support/rules_hdl/swig_bzlmod.patch new file mode 100644 index 0000000000..dcd30c9caa --- /dev/null +++ b/dependency_support/rules_hdl/swig_bzlmod.patch @@ -0,0 +1,20 @@ +diff --git a/BUILD b/BUILD +index a2b99dc83..d5e6f7a8b 100644 +--- a/BUILD ++++ b/BUILD +@@ -161,3 +161,15 @@ filegroup( + licenses = ["notice"], # simple notice license for Lib/ + visibility = ["//visibility:public"], + ) ++ ++filegroup( ++ name = "lib_tcl", ++ srcs = glob([ ++ "Lib/*", ++ "Lib/tcl/*", ++ "Lib/std/*", ++ "Lib/typemaps/*", ++ ]), ++ licenses = ["notice"], # simple notice license for Lib/ ++ visibility = ["//visibility:public"], ++) diff --git a/dependency_support/rules_hdl/workspace.bzl b/dependency_support/rules_hdl/workspace.bzl index 32a346fcba..3213960170 100644 --- a/dependency_support/rules_hdl/workspace.bzl +++ b/dependency_support/rules_hdl/workspace.bzl @@ -29,15 +29,20 @@ def repo(): sha256 = "fd9e99f6ccb9e946755f9bc444abefbdd1eedb32c372c56dcacc7eb486aed178", ) - # Current as of 2025-11-07 - git_hash = "d17bb1646fa36e6172b349cc59af8d31a427cf23" + # Current as of 2026-01-26 + git_hash = "af93b9a5893e482f9959ce351834960e09a45a7b" maybe( http_archive, name = "rules_hdl", - integrity = "sha256-aWjEZVtMMTiO80C3a2c3WBtKJA0WzUgUzqMkA0QLsjs=", + integrity = "sha256-qphNuOxqovqNpGtk7sKxclWLPtxnoPm8ViyT+hiMaiw=", strip_prefix = "bazel_rules_hdl-%s" % git_hash, urls = [ "https://github.com/hdl/bazel_rules_hdl/archive/%s.tar.gz" % git_hash, ], + patches = [ + Label("@//dependency_support/rules_hdl:rules_hdl_deps.patch"), + Label("@//dependency_support/rules_hdl:rename_eigen.patch"), + Label("@//dependency_support/rules_hdl:rename_swig.patch"), + ], ) diff --git a/xls/dslx/stdlib/tests/BUILD b/xls/dslx/stdlib/tests/BUILD index 3e9681056b..d97a3c9fc3 100644 --- a/xls/dslx/stdlib/tests/BUILD +++ b/xls/dslx/stdlib/tests/BUILD @@ -173,7 +173,7 @@ cc_test( "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/status", "@com_google_absl//absl/types:span", - "@eigen//:eigen3", + "@eigen", ], ) @@ -546,7 +546,7 @@ cc_test( "@com_google_absl//absl/log", "@com_google_absl//absl/random", "@com_google_absl//absl/status:statusor", - "@eigen//:eigen3", + "@eigen", "@googletest//:gtest", ] + [":bfloat16_" + top + "_jit_wrapper" for top in BFLOAT16_CMP_TOPS], ) @@ -582,7 +582,7 @@ cc_test( "@com_google_absl//absl/log:check", "@com_google_absl//absl/random", "@com_google_absl//absl/status:statusor", - "@eigen//:eigen3", + "@eigen", "@googletest//:gtest", ], )