<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57652>57652</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            test-suite doesn't compile on Solaris
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rorth
      </td>
    </tr>
</table>

<pre>
    The `test-suite` doesn't currently compile on Solaris for quite a number of reasons:

- `tools/timeit.c` doesn't compile:
```
tools/timeit.c:343:24: error: use of undeclared identifier 'RLIMIT_RSS'
    set_resource_limit(RLIMIT_RSS, g_target_rss_size_limit);
                       ^
tools/timeit.c:356:24: error: use of undeclared identifier 'RLIMIT_NPROC'
    set_resource_limit(RLIMIT_NPROC, g_target_subprocess_count_limit);
                       ^
```
  Can be avoided by checking for the respective macros.
- `MicroBenchmarks/libs/benchmark/test/benchmark_setup_teardown_test.cc` doesn't compile:
```
MicroBenchmarks/libs/benchmark/test/benchmark_setup_teardown_test.cc:13:11: error: redefinition of 'single' as different kind of symbol
namespace single {
          ^
/usr/include/floatingpoint.h:69:15: note: previous definition is here
typedef float single;
              ^
MicroBenchmarks/libs/benchmark/test/benchmark_setup_teardown_test.cc:18:5: error: 'single' (aka 'float') is not a class, namespace, or enumeration
  ++single::setup_call;
    ^
MicroBenchmarks/libs/benchmark/test/benchmark_setup_teardown_test.cc:25:5: error: 'single' (aka 'float') is not a class, namespace, or enumeration
  ++single::teardown_call;
    ^
MicroBenchmarks/libs/benchmark/test/benchmark_setup_teardown_test.cc:137:10: error: 'single' (aka 'float') is not a class, namespace, or enumeration
  assert(single::setup_call == 4);
         ^
MicroBenchmarks/libs/benchmark/test/benchmark_setup_teardown_test.cc:138:10: error: 'single' (aka 'float') is not a class, namespace, or enumeration
  assert(single::teardown_call == 4);
         ^
```
  Can be avoided by renaming `single` to `singlethreaded` (longer but that's the meaning).

- `MicroBenchmarks/ImageProcessing/Dither/main.cpp` doesn't compile:
```
MicroBenchmarks/ImageProcessing/Dither/main.cpp:72:11: error: call to 'pow' is ambiguous
  int n = pow(m, 2);
          ^~~
/usr/include/iso/math_iso.h:141:16: note: candidate function
        inline double pow(double __X, int __Y) { return
                      ^
/usr/include/iso/math_iso.h:163:16: note: candidate function
        inline double pow(float __X, int __Y) { return
                      ^
/usr/include/iso/math_iso.h:199:21: note: candidate function
        inline long double pow(long double __X, int __Y) { return
                           ^
```
  Can be avoided by casting the arg to `double`.

- `MultiSource/Applications/viterbi/read_dmatrix.c` doesn't compile:
```
MultiSource/Applications/viterbi/read_dmatrix.c:7:22: error: call to undeclared library function 'strrchr' with type 'char *(const char *, int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  const char *base = strrchr(str, '/');
                     ^
MultiSource/Applications/viterbi/read_dmatrix.c:7:22: note: include the header <string.h> or explicitly provide a declaration for 'strrchr'
```
  Just include `<string.h>`.

- `MultiSource/Benchmarks/McCat/05-eks/main.h` doesn't compile:
```
/usr/include/string.h:238:69: error: expected ')'
extern int timingsafe_memcmp(const void *s1, const void *s2, size_t n);
                                                                    ^
MultiSource/Benchmarks/McCat/05-eks/main.h:30:11: note: expanded from macro 'n'
#define n 51
          ^
/usr/include/string.h:238:29: note: to match this '('
extern int timingsafe_memcmp(const void *s1, const void *s2, size_t n);
```
  `main.h` defines `n` `51` which clashes with an argument of `timingsafe_memcmp`.  The declaration is obviously wrong, but the problem can be avoided by including system headers **before** local ones.

- `MultiSource/Applications/ClamAV/libclamav_readdb.c` doesn't compile:
```
MultiSource/Applications/ClamAV/libclamav_readdb.c:1080:9: error: no member named 'd_type' in 'struct dirent'
        if (a->d_type < b->d_type) return -1;
            ~  ^
MultiSource/Applications/ClamAV/libclamav_readdb.c:1080:21: error: no member named 'd_type' in 'struct dirent'
        if (a->d_type < b->d_type) return -1;
                        ~  ^
MultiSource/Applications/ClamAV/libclamav_readdb.c:1081:9: error: no member named 'd_type' in 'struct dirent'
        if (a->d_type > b->d_type) return 1;
            ~  ^
MultiSource/Applications/ClamAV/libclamav_readdb.c:1081:21: error: no member named 'd_type' in 'struct dirent'
        if (a->d_type > b->d_type) return 1;
                        ~  ^
```
  Like AIX, Solaris `struct dirent` lacks `d_type`, so handle both the same.
- `MultiSource/Applications/oggenc/oggenc.c` doesn't compile:
```
MultiSource/Applications/oggenc/oggenc.c:132:9: error: unknown type name 'u_int16_t'; did you mean 'uint16_t'?
typedef u_int16_t ogg_uint16_t;
        ^~~~~~~~~
        uint16_t
/usr/include/sys/int_types.h:70:25: note: 'uint16_t' declared here
typedef unsigned short          uint16_t;
                                ^
MultiSource/Applications/oggenc/oggenc.c:134:9: error: unknown type name 'u_int32_t'; did you mean 'uint32_t'?
typedef u_int32_t ogg_uint32_t;
        ^~~~~~~~~
        uint32_t
/usr/include/sys/int_types.h:71:23: note: 'uint32_t' declared here
typedef unsigned int            uint32_t;
                                ^
MultiSource/Applications/oggenc/oggenc.c:1920:11: error: call to undeclared library function 'alloca' with type 'void *(unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        buffer = alloca(len);
                 ^
MultiSource/Applications/oggenc/oggenc.c:1920:11: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
```
  Instead of using the non-standard (BSD?) fixed-width types, just use the standard (`<stdint.h>`) ones.

  `alloca` is declared on Solaris in `<alloca.h>` only.  The note is misleading: `alloca` is non-standard and while some systems may declare it in `<stdlib.h>`, others don't.
- `MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/fmemopen.c` doesn't compile:
```
MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/fmemopen.c:110:10: error: call to undeclared function 'funopen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  return funopen(mem, readfn, writefn, seekfn, closefn);
         ^
MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/fmemopen.c:110:10: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'FILE *' (aka 'struct __FILE *') [-Wint-conversion]
  return funopen(mem, readfn, writefn, seekfn, closefn);
         ^~~~~~~~~~~~~
```
  Solaris 11.4 **does** have `fmemopen`, just like Linux and FreeBSD, so reflect that.
- `MultiSource/Benchmarks/MiBench/consumer-lame/rtp.c` doesn't compile:
```
MultiSource/Benchmarks/MiBench/consumer-lame/rtp.c:47:13: error: call to undeclared library function 'alloca' with type 'void *(unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  char *buf=alloca(len+sizeof(struct rtpheader));
            ^
MultiSource/Benchmarks/MiBench/consumer-lame/rtp.c:47:13: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
```
  Include `<alloca.h>` as above.
- `MultiSource/Benchmarks/MiBench/office-ispell/term.c` doesn't compile:
```
MultiSource/Benchmarks/MiBench/office-ispell/term.c:341:23: error: use of undeclared identifier 'ECHO'
    sbuf.sg_flags &= ~ECHO;
                      ^
MultiSource/Benchmarks/MiBench/office-ispell/term.c:342:22: error: use of undeclared identifier 'CBREAK'
    sbuf.sg_flags |= TERM_MODE;
                     ^
MultiSource/Benchmarks/MiBench/office-ispell/config.h:601:19: note: expanded from macro 'TERM_MODE'
#define TERM_MODE       CBREAK
                        ^
```
  Like several others, Solaris needs `<termios.h>` for `ECHO` and `CBREAK`.
- `SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-930513-1` and `SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-920501-8` don't link:
```
FAILED: SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-930513-1
: && /var/llvm/test-suite/tools/timeit --summary SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-930513-1.link.time /vol/llvm-15/bin/clang -O3   SingleSource/Regression/C/gcc-c-torture/execute/CMakeFiles/GCC-C-execute-930513-1.dir/930513-1.c.o  -o SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-930513-1  -Wl,-u,_printf_float && cd /var/llvm/test-suite/SingleSource/Regression/C/gcc-c-torture/execute && /vol/llvm-15/bin/llvm-size --format=sysv /var/llvm/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-930513-1 > /var/llvm/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-930513-1.size
Undefined                       first referenced
 symbol                             in file
_printf_float                       (command line)
ld: fatal: symbol referencing errors
```
  There's a massive misunderstanding here: both tests are linked unconditionally with `-Wl,-u,__printf_float`.  However, the tests from the upstream GCC testsuite have
```
/* { dg-additional-options "-Wl,-u,_printf_float" { target newlib_nano_io } } */
```
  This means that this option is added **only** if the `newlib_nano_io` effective-target keyword is true.  In the end, this is set if GCC was configured with `--enable-newlib-nano-formatted-io` which does nothing more than record that fact, meant to indicate that `newlib` was configured with the same option.  However, I've found no indication whatsoever that LLVM supports `newlib` at all.  On top of there, there's an additional testcase (`ieee/920810-1.x`) that uses the same code.  However, given that `test-suite` doesn't know about those `.x` files and the test works just fine without the option, this seems a strong indication that the whole `TestRequiresNanoIO` code can just go.
- `litsupport/modules/hash.py` uses `strip --remove-section=.comment`, which Solaris `strip` doesn't support, just like Darwin.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdW1t34jgS_jXkRcccMOH2kAdCwk52O9N90r0zu08c2RagiW0xlp3L_vr9qmQbEyAD6aR7z3Jo4oss1b2-KrkDEz1ffFsp0Rp0cmVzzxY6VzgRkVE2bfnDXIRFlqk0j59FaJK1jpUwqfhqYplpKxYmE3_SM0KKtEgClQmzEJmS1qS21Zu0OletTvnr8SrGxLblz3KdKJ23wxdruRU2Dw465ZdPdx7uTXrnPfz65_gRKstMRgeFVURGkUYqBJ0qEjoCC3qhQR8Wuvt0c3vzbX739StO3NQCH6vyeaasKbJQzWOd6Lzlj5pjp2I5z2W2pHHWzq3-Tz1u3Opdbmba82n1rw8z0R-8mYlfv9x9nh7NRjm6wYgtgnVmQgV-QlOk-ekMvVCSEFOZigAW8WBAcSQC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