15 Commits

Author SHA1 Message Date
Jorge Gorbe Moya
f9a6ea4489
[libc][bazel] Add BUILD targets for complex functions and tests. (#129618)
This involved a little bit of yak shaving because one of the new tests
depends on MPC, and we didn't have targets for it yet, so I ended up
needing to add a similar setup to what we have for MPFR.
2025-03-04 11:05:01 -08:00
Maksim Levental
392622d084
Revert "Revert "[mlir python] Add nanobind support (#119232)
Reverts revert #118517 after (hopefully) fixing builders
(https://github.com/llvm/llvm-zorg/pull/328,
https://github.com/llvm/llvm-zorg/pull/327)

This reverts commit 61bf308cf2fc32452f14861c102ace89f5f36fec.
2024-12-09 16:37:43 -05:00
Maksim Levental
61bf308cf2
Revert "[mlir python] Add nanobind support for standalone dialects." (#118517)
Reverts llvm/llvm-project#117922 because deps aren't met on some of the
post-commit build bots.
2024-12-03 09:26:33 -08:00
Peter Hawkins
afe75b4d5f
[mlir python] Add nanobind support for standalone dialects. (#117922)
This PR allows out-of-tree dialects to write Python dialect modules
using nanobind instead of pybind11.

It may make sense to migrate in-tree dialects and some of the ODS Python
infrastructure to nanobind, but that is a topic for a future change.

This PR makes the following changes:
* adds nanobind to the CMake and Bazel build systems. We also add
robin_map to the Bazel build, which is a dependency of nanobind.
* adds a PYTHON_BINDING_LIBRARY option to various CMake functions, such
as declare_mlir_python_extension, allowing users to select a Python
binding library.
* creates a fork of mlir/include/mlir/Bindings/Python/PybindAdaptors.h
named NanobindAdaptors.h. This plays the same role, using nanobind
instead of pybind11.
* splits CollectDiagnosticsToStringScope out of PybindAdaptors.h and
into a new header mlir/include/mlir/Bindings/Python/Diagnostics.h, since
it is code that is no way related to pybind11 or for that matter,
Python.
* changed the standalone Python extension example to have both pybind11
and nanobind variants.
* changed mlir/python/mlir/dialects/python_test.py to have both pybind11
and nanobind variants.

Notes:
* A slightly unfortunate thing that I needed to do in the CMake
integration was to use FindPython in addition to FindPython3, since
nanobind's CMake integration expects the Python_ names for variables.
Perhaps there's a better way to do this.
2024-12-03 09:13:34 -08:00
Keith Smiley
914a00a9c9
[bazel] Add support for pybind (#98398)
Previously these targets were disabled, but with a relatively new
rules_python we can build these pointing at a hermetic python, which
allows us to build these safely. Users can still access the files
directly if they need to customize how these are built.
2024-07-18 17:23:02 -07:00
Christian Sigg
cce18e40c0
[bazel] Fix BUILD after 2eb010ddce2a8e7813a8e289004102011b1138db. 2024-03-25 20:57:22 +01:00
Keith Smiley
2eb010ddce
[bazel] Restrict libpfm to linux (#86565)
This target doesn't build on macOS (even with the upstream make based
build system) so this encodes that in the build without requiring
non-linux users to disable it manually with the starlark flag. The flag
is still respected for linux users.
2024-03-25 12:47:16 -07:00
Jordan Rupprecht
2fcfc9754a [NFC] Reformat bzl files with buildifier 2024-02-12 11:35:18 -08:00
Aaron Siddhartha Mondal
a268127736
[bazel] Rework zlib dependency
Switches the library to use the zlib-ng implementation since the
original implementation is warning-incompatible with recent versions of clang.

Removes the wrapper logic for zlib in the bazel build and introduces new
logic to handle `LLVM_ENABLE_ZLIB`.

Removes the `BAZEL_LLVM_ZLIB_STRATEGY` environment variable and instead
introduces a boolean `--@llvm_zlib//:llvm_enable_zlib` flag which defaults
to true.

To migrate:
    * The previous "external" strategy is the default. May be explicitly
      enabled with `--@llvm_zlib//:llvm_enable_zlib=true`. For custom zlib
      variants you can use the BUILD file at `third_party_build/zlib.BUILD`
      as reference and adjust the `@llvm_zlib` archive in the `WORKSPACE`
      directly.
    * The previous "disable" strategy may be enabled with
      `--@llvm_zlib//:llvm_enable_zlib=false`.
    * The previous "system" strategy has been removed since it breaks
      hermeticity. If you need the "system" setup, use the "external"
      strategy and override the zlib dependency.

Addresses breakages of downstream projects using upstream clang and the
previously "external" zlib strategy (D141553).

Reviewed By: MaskRay, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D143320
2023-05-19 23:41:07 +02:00
Aaron Siddhartha Mondal
75d2032e9b [bazel] Port zstd support
Originally added in D128465. Used by `llvm:Support` and `lld:ELF`.

Enabled by default. Disable with `--@llvm_zstd//:llvm_enable_zstd=false`.

Reviewed By: MaskRay, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D143344
2023-03-29 01:29:35 +02:00
Jordan Rupprecht
4aa77690b9 [bazel] Restore libpfm as a conditional dependency for exegesis.
We used to have `pfm` built into exegesis, although since it's an external dependency we marked it as a manual target. Because of this we didn't have buildbot coverage and so we removed it in D134510 after we had a few breakages that weren't caught. This adds it back, but with three possible states similar to the story with `mpfr`, i.e. it can either be disabled, built from external sources (git/make), or use whatever `-lpfm` is installed on the system.

This change is modeled after D119547. Like that patch, the default is off (matching the status quo), but unlike that patch we don't enable it for CI because IIRC we don't have the package installed there, and building from source might be expensive. We could  enable it later either after installing it on buildbot machines or by measuring build cost and deeming it OK.

Reviewed By: GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D138470
2022-12-28 08:13:20 -08:00
Guillaume Chatelet
d856e5feac [reland][libc][bazel] Add tests to the bazel build
This patch adds bazel tests for llvm-libc.

Some math tests rely on the `mpfr` library. This is controlled via the `--@llvm-project//libc:libc_math_mpfr` flag. It can take three values:
 - `external` (default) will build `mpfr` and `gmp` from source.
 - `system` will use the system installed `mpfr` library.
 - `disable` will skip tests relying on `mpfr`.

Reviewed By: sivachandra, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D119547
2022-11-18 13:20:52 +00:00
Guillaume Chatelet
0e91a0913c Revert D119547 "[libc][bazel] Add tests to the bazel build"
The introducion of `constraint_setting` generated issues with downstream
integration.

This reverts commit 3c13d83ad59b5932328c0a99b0a0008e1da8b1d8.
2022-11-17 20:20:57 +00:00
Guillaume Chatelet
3c13d83ad5 [libc][bazel] Add tests to the bazel build
@GMNGeoffrey let me know it there's a better way to import MPFR and GMP for the purpose of testing libc math functions.

Differential Revision: https://reviews.llvm.org/D119547
2022-11-17 14:19:56 +00:00
Geoffrey Martin-Noble
4aeb2e60df Introduce a Bazel build configuration
This patch introduces configuration for a Bazel BUILD in a side
directory in the monorepo.

This is following the approval of
https://github.com/llvm/llvm-www/blob/main/proposals/LP0002-BazelBuildConfiguration.md

As detailed in the README, the Bazel BUILD is not supported
by the community in general, and is maintained only by interested
parties. It follows the requirements of the LLVM peripheral tier:
https://llvm.org/docs/SupportPolicy.html#peripheral-tier.

This is largely copied from https://github.com/google/llvm-bazel,
with a few filepath tweaks and the addition of the README.

Reviewed By: echristo, keith, dblaikie, kuhar

Differential Revision: https://reviews.llvm.org/D90352
2021-06-22 12:47:43 -07:00