[compiler-rt] [builtins] Fix divtc3.c etc. compilation on Solaris/SPARC with gcc (PR #101662)
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 07:01:29 PDT 2024
rorth wrote:
> > Me knowing nothing about z/OS and not having access to such a system, could you please provide the output of the compilation of `divtc3.c` with `-g3 -dD -save-temps` added? Going through the maze of macro definitions was bad enough when I had to on SPARC, on a foreign system it's pure guesswork.
>
> Thank you for responding. The -save-temps`does not work. I'm going to attached output from compiling`divtc3.c`with`--dD -E` added. [divthc3.c.txt](https://github.com/user-attachments/files/16625525/divthc3.c.txt)
`-save-temps` probably did work, but what's confusing is that the `.i` file is stored alongside the `.o`, not in the working directory as one would expect.
There are a few things that confuse me, though:
- I find `CRT_HAS_128BIT` first defined (from `int_types.h` since `__LP64__` is defined), that immediately undefined. However, in the source, that's guarded like this:
```
#if defined(_MSC_VER) && !defined(__clang__)
#undef CRT_HAS_128BIT
#endif
```
However, in the `.i` file `_MSC_VER` isn't defined while `__clang__` is.
- The `.i` file claims to be from `compiler-rt/lib/builtins/divthc3.c`, which files doesn't exist upstream. The body of the file isn't anything like `divtc3.c` either.
Whatever the case, when looking at my patch again, I found that it should have guarded the `__divtc3` and `__multc3` definitions like this (relative to current sources):
```
diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c
--- a/compiler-rt/lib/builtins/divtc3.c
+++ b/compiler-rt/lib/builtins/divtc3.c
@@ -13,7 +13,7 @@
#define QUAD_PRECISION
#include "fp_lib.h"
-#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
+#if defined(CRT_HAS_F128) && defined(CRT_HAS_TF_MODE)
// Returns: the quotient of (a + ib) / (c + id)
diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c
--- a/compiler-rt/lib/builtins/multc3.c
+++ b/compiler-rt/lib/builtins/multc3.c
@@ -15,7 +15,7 @@
#include "int_lib.h"
#include "int_math.h"
-#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
+#if defined(CRT_HAS_F128) && defined(CRT_HAS_TF_MODE)
// Returns: the product of a + ib and c + id
```
All the functions use (`__compiler_rt_logbtf` and several more) are guarded by `CRT_HAS_TF_MODE`. That works on SPARC, but won't for you since it isn't defined in your `.i` file.
Are you maybe using modified sources?
> > Given that the patch has been in for two weeks without complaint, could you give me a day or two to investigate and come up with a fix? This avoid the constant churn of Revert/Reland/Re-Revert/Re-Reland. Thanks.
>
> Waiting fews days should be fine with us,.
Good, thanks.
https://github.com/llvm/llvm-project/pull/101662
More information about the llvm-commits
mailing list