Issue 240663
Summary Remove MPFR single_version_override in utils/bazel/MODULE.bazel
Labels new issue
Assignees nigham
Reporter nigham
    Commit 4331e9178f9f upgraded the BCR mpfr dependency in MODULE.bazel from 4.2.2.bcr.1 to 4.2.2.bcr.3.

In BCR 4.2.2.bcr.1, the Bazel overlay included custom autoconf checks that probed for GNU `__float128` and set `MPFR_WANT_FLOAT128=2` / `#define mpfr_float128 __float128`. In 4.2.2.bcr.3, BCR switched to an automated rules_cc_autoconf converter, which only included an AC_TRY_LINK probe for standard C `_Float128` and dropped the `__float128` fallback and macros entirely. Under clang C17,  `_Float128` failed detection, causing `mpfr_get_float128` and `mpfr_set_float128` to not be compiled into `libmpfr.a`.

Commit 826d63662a3b added explicit float128 template instantiations in MPFRUtils.cpp and added `modff128_test` / `remquof128_test` to the Bazel build overlay in `BUILD.bazel`, making `//libc:mpfr_wrapper` unconditionally attempt to link `mpfr_get_float128` / `mpfr_set_float128`; causing errors when bcr is built from source:

```
    ERROR: /usr/local/google/home/nigham/.cache/bazel/_bazel_nigham/ffa2afd6cdb8397784d2afd079f192ed/external/+llvm_configure+llvm-project/libc/test/src/math/BUILD.bazel:299:15: Linking external/+
 llvm_configure+llvm-project/libc/test/src/math/exp2_test failed: (Exit 1): clang failed: error executing CppLink command (from cc_test rule target @@+llvm_configure+llvm-
  project//libc/test/src/math:exp2_test) /usr/bin/clang @bazel-out/k8-fastbuild/bin/external/+llvm_configure+llvm-project/libc/test/src/math/exp2_test-0.params

 Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
    ld.lld: error: undefined symbol: mpfr_get_float128
    >>> referenced by MPCommon.cpp
    >>> bazel-out/k8-fastbuild/bin/external/+llvm_configure+llvm-project/libc/utils/MPFRWrapper/_objs/mp_common/MPCommon.pic.o:(__float128
 __llvm_libc_24_0_0_git::testing::mpfr::MPFRNumber::as<__float128>() const)

    ld.lld: error: undefined symbol: mpfr_set_float128
    >>> referenced by MPFRUtils.cpp
    >>> bazel-out/k8-fastbuild/bin/external/+llvm_configure+llvm-project/libc/utils/MPFRWrapper/_objs/mpfr_wrapper/MPFRUtils.pic.
 o:(__llvm_libc_24_0_0_git::testing::mpfr::MPFRNumber::MPFRNumber<__float128, 0>(__float128, unsigned int, __llvm_libc_24_0_0_git::fputil::testing::RoundingMode))
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

Upstream bazel builds on buildkite are unaffected because `--config=ci` is used which links against the system's mpfr.

Next steps (suggested by @boomanaiden154): https://github.com/llvm/llvm-project/pull/240646#pullrequestreview-5835323715
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to