This is an archive of the discontinued LLVM Phabricator instance.

[benchmarks] Unbreak third-party/benchmark build on Solaris
AbandonedPublic

Authored by ro on Dec 8 2021, 6:47 AM.

Details

Summary

D112012 broke the Solaris buildbots (sparcv9 and amd64:

/vol/llvm/src/llvm-project/local/third-party/benchmark/src/sysinfo.cc:447:2: error: #warning is a language extension [-Werror,-Wpedantic]
#warning "HOST_NAME_MAX not defined. using 64"
 ^
/vol/llvm/src/llvm-project/local/third-party/benchmark/src/sysinfo.cc:447:2: error: "HOST_NAME_MAX not defined. using 64" [-Werror,-W#warnings]
/vol/llvm/src/llvm-project/local/third-party/benchmark/src/sysinfo.cc:475:16: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
  int NumCPU = sysconf(_SC_NPROCESSORS_ONLN);
      ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/llvm/src/llvm-project/local/third-party/benchmark/src/sysinfo.cc:653:42: error: cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
  kstat_t *ksp = kstat_lookup(kc, (char*)"cpu_info", -1, (char*)"cpu_info0");
                                         ^
/vol/llvm/src/llvm-project/local/third-party/benchmark/src/sysinfo.cc:653:65: error: cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
  kstat_t *ksp = kstat_lookup(kc, (char*)"cpu_info", -1, (char*)"cpu_info0");
                                                                ^
/vol/llvm/src/llvm-project/local/third-party/benchmark/src/sysinfo.cc:663:53: error: cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
      (kstat_named_t*)kstat_data_lookup(ksp, (char*)"current_clock_Hz");
                                                    ^
  • Solaris uses MAXHOSTNAMELEN which, contrary to gethostname(3C) lives in <netdb.h>, not <unistd.h>`.
  • sysconf returns long, not int, so account for that
  • kstat_lookup etc. need const_casts

Tested on amd64-pc-solaris2.11.

Diff Detail

Event Timeline

ro created this revision.Dec 8 2021, 6:47 AM
ro requested review of this revision.Dec 8 2021, 6:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2021, 6:47 AM

Can you please submit this upstream first?

Can you please submit this upstream first?

+1, thanks - was just typing that. I wonder if a README under third_party explaining how to update benchmark would be discoverable? Or maybe a MAKING_CHANGES?

lebedev.ri requested changes to this revision.Jan 12 2023, 5:24 PM

This review seems to be stuck/dead, consider abandoning if no longer relevant.

This revision now requires changes to proceed.Jan 12 2023, 5:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 5:24 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
lebedev.ri resigned from this revision.Jan 12 2023, 5:56 PM
This revision now requires review to proceed.Jan 12 2023, 5:56 PM
ro abandoned this revision.Jan 13 2023, 1:15 AM

The patch is no longer crucial: since third-party/benchmark doesn't build with -Werror anymore, so there are just warnings left. Besides, the patch is now upstream, so whenever someone imports the current version into LLVM, even those will be gone.