lfreist / hwinfo

cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
MIT License
459 stars 79 forks source link

Add PowerPC support #26

Open barracuda156 opened 1 year ago

barracuda156 commented 1 year ago

Apparently the code currently covers only Intel platforms. Possible to add support for POWER (for *BSD and AIX) and PowerPC (for Apple)?

lfreist commented 1 year ago

Hi, hwinfo should work architecture independent on Linux, Windows and Mac (development for MacOS is not very far...).

The supported (and yet unsupported) features for each platform stated here should work on any architecture.

Have you already tried building and running hwinfo on a PowerPC?

If so, it would be nice, if you can provide further information on whats unexpected/not working.

barracuda156 commented 1 year ago

@lfreist I will try and update you.

lfreist commented 1 year ago

Closed due to inactivity

barracuda156 commented 1 year ago

Closed due to inactivity

I apologize, this went forgotten. I will do this today.

barracuda156 commented 1 year ago

@lfreist Build fails here for me:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-ce1d868a7c451c27e98614dce74540aea914afd5/src/apple/cpu.cpp: In static member function 'static std::string hwinfo::CPU::getModelName()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-ce1d868a7c451c27e98614dce74540aea914afd5/src/apple/cpu.cpp:81:22: error: 'model' was not declared in this scope; did you mean 'modfl'?
   81 |   return std::string(model);
      |                      ^~~~~
      |                      modfl
barracuda156 commented 1 year ago

Types of PPC cpus can be found in /usr/include/mach/machine.h. This is how it can be determined: https://www.eidos.ic.i.u-tokyo.ac.jp/~tau/lecture/parallel_distributed/2016/examples/09mm/OpenBLAS/cpuid_power.c

lfreist commented 1 year ago

Thank you! It's a pure failure from my side. Didn't have a non x86 Mac for testing thins peace of code... However, I found the bug and will fix it later.

barracuda156 commented 1 year ago

@lfreist Great, thank you!

lfreist commented 1 year ago

commit ba3ba8b165502f1ab979204c4adcf93bb339c5b1 should fix the stated issue. Since I cannot test for non x86 MacOS, I cannot assure that there are no other issues... Would be grateful, if you can provide further information after testing the new commit!

barracuda156 commented 1 year ago

@lfreist Thank you. There is this error then:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-ba3ba8b165502f1ab979204c4adcf93bb339c5b1/src/apple/cpu.cpp: In static member function 'static std::string hwinfo::CPU::getModelName()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-ba3ba8b165502f1ab979204c4adcf93bb339c5b1/src/apple/cpu.cpp:79:58: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
   79 |   if (sysctlbyname("machdep.cpu.brand_string", model.data(), &size, NULL, 0) < 0) {
      |                                                ~~~~~~~~~~^~
      |                                                          |
      |                                                          const void*
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-ba3ba8b165502f1ab979204c4adcf93bb339c5b1/src/apple/cpu.cpp:12:
/usr/include/sys/sysctl.h:752:36: note:   initializing argument 2 of 'int sysctlbyname(const char*, void*, size_t*, void*, size_t)'
  752 | int     sysctlbyname(const char *, void *, size_t *, void *, size_t);
      |                                    ^~~~~~

When passing -fpermissive, it builds through completion. Many objects have no symbols though:

/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(filesystem.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(battery.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(cpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(gpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(ram.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(os.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(mainboard.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(disk.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(filesystem.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(cpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(gpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(ram.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(os.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(mainboard.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(disk.cpp.o) has no symbols
/opt/local/bin/ranlib ../lib/libHWinfo.a
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(filesystem.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(battery.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(cpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(gpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(ram.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(os.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(mainboard.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(disk.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(filesystem.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(cpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(gpu.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(ram.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(os.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(mainboard.cpp.o) has no symbols
/opt/local/bin/ranlib: file: ../lib/libHWinfo.a(disk.cpp.o) has no symbols

Destroot does not work too, but that is trivial to fix on our end.