Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerPC build error #167

Closed
suve opened this issue Jan 5, 2023 · 9 comments
Closed

PowerPC build error #167

suve opened this issue Jan 5, 2023 · 9 comments

Comments

@suve
Copy link

suve commented Jan 5, 2023

cpufetch v1.03 fails to build on PowerPC for Linux.

src/common/printer.c: In function 'print_ascii_generic':
src/common/printer.c:487:23: error: 'ATTRIBUTE_CPU_NUM' undeclared (first use in this function); did you mean 'ATTRIBUTE_PEAK'?
  487 |       if(attr_type == ATTRIBUTE_CPU_NUM) {
      |                       ^~~~~~~~~~~~~~~~~
      |                       ATTRIBUTE_PEAK
src/common/printer.c:487:23: note: each undeclared identifier is reported only once for each function it appears in
src/common/printer.c: In function 'print_cpufetch_ppc':
src/common/printer.c:693:3: error: too few arguments to function 'print_ascii_generic'
  693 |   print_ascii_generic(art, longest_attribute, term->w, attribute_fields);
      |   ^~~~~~~~~~~~~~~~~~~
src/common/printer.c:433:6: note: declared here
  433 | void print_ascii_generic(struct ascii* art, uint32_t la, int32_t termw, const char** attribute_fields, bool hybrid_architecture) {
      |      ^~~~~~~~~~~~~~~~~~~
@suve
Copy link
Author

suve commented Jan 5, 2023

For the record, I ended up using the following patch:

--- cpufetch-1.03--orig/src/common/printer.c	2023-01-05 11:17:49.000000000 +0100
+++ cpufetch-1.03--patched/src/common/printer.c	2023-01-05 12:36:03.274338380 +0100
@@ -483,13 +483,16 @@
 
       if(attr_type == ATTRIBUTE_L3) {
         add_space = false;
       }
+#if defined(ARCH_X86) || defined(ARCH_ARM)
       if(attr_type == ATTRIBUTE_CPU_NUM) {
         printOut(lbuf, strlen(attr_value), "%s%s%s", logo->color_text[0], attr_value, art->reset);
         add_space = true;
       }
-      else {
+      else
+#endif
+      {
         beg_space = 0;
         space_right = 2 + 1 + (la - strlen(attribute_fields[attr_type]));
         if(hybrid_architecture && add_space) {
           beg_space = 2;
@@ -689,9 +692,9 @@
     attribute_fields = ATTRIBUTE_FIELDS_SHORT;
     longest_attribute = longest_attribute_length(art, attribute_fields);
   }
 
-  print_ascii_generic(art, longest_attribute, term->w, attribute_fields);
+  print_ascii_generic(art, longest_attribute, term->w, attribute_fields, false);
 
   return true;
 }
 #endif

@barracuda156
Copy link

Fails on macOS PPC too:

src/common/printer.c: In function 'print_ascii_generic':
src/common/printer.c:487:23: error: 'ATTRIBUTE_CPU_NUM' undeclared (first use in this function); did you mean 'ATTRIBUTE_PEAK'?
  487 |       if(attr_type == ATTRIBUTE_CPU_NUM) {
      |                       ^~~~~~~~~~~~~~~~~
      |                       ATTRIBUTE_PEAK
src/common/printer.c:487:23: note: each undeclared identifier is reported only once for each function it appears in
src/common/printer.c: In function 'print_cpufetch_ppc':
src/common/printer.c:693:3: error: too few arguments to function 'print_ascii_generic'
  693 |   print_ascii_generic(art, longest_attribute, term->w, attribute_fields);
      |   ^~~~~~~~~~~~~~~~~~~
src/common/printer.c:433:6: note: declared here
  433 | void print_ascii_generic(struct ascii* art, uint32_t la, int32_t termw, const char** attribute_fields, bool hybrid_architecture) {
      |      ^~~~~~~~~~~~~~~~~~~
src/ppc/uarch.c:6:10: fatal error: sys/auxv.h: No such file or directory
    6 | #include <sys/auxv.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [cpufetch] Error 1

barracuda156 referenced this issue in macports/macports-ports Jan 5, 2023
@barracuda156
Copy link

There is no flag -Wno-language-extension-token with GCC too, apparently.

cc1: error: unrecognized command line option "-Wno-language-extension-token"

@barracuda156
Copy link

So this is needed too:

--- src/ppc/uarch.c.orig	2023-01-05 17:17:49.000000000 +0700
+++ src/ppc/uarch.c	2023-01-06 02:37:58.000000000 +0700
@@ -3,9 +3,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/auxv.h>
 #include <errno.h>
 
+#ifndef __APPLE__
+  #include <sys/auxv.h>
+#endif
+
 #include "uarch.h"
 #include "../common/global.h"
 

With this plus a patch by @suve it builds fine.

@Dr-Noob
Copy link
Owner

Dr-Noob commented Jan 6, 2023

Thanks for the report. I have pushed a patch that should fix everything, except for the -Wno-language-extension-token, which I'll investigate later. Can you guys confirm that everything works under your machines with the latest commit?

@Dr-Noob
Copy link
Owner

Dr-Noob commented Jan 6, 2023

Fails on macOS PPC too:

src/common/printer.c: In function 'print_ascii_generic':
src/common/printer.c:487:23: error: 'ATTRIBUTE_CPU_NUM' undeclared (first use in this function); did you mean 'ATTRIBUTE_PEAK'?
  487 |       if(attr_type == ATTRIBUTE_CPU_NUM) {
      |                       ^~~~~~~~~~~~~~~~~
      |                       ATTRIBUTE_PEAK
src/common/printer.c:487:23: note: each undeclared identifier is reported only once for each function it appears in
src/common/printer.c: In function 'print_cpufetch_ppc':
src/common/printer.c:693:3: error: too few arguments to function 'print_ascii_generic'
  693 |   print_ascii_generic(art, longest_attribute, term->w, attribute_fields);
      |   ^~~~~~~~~~~~~~~~~~~
src/common/printer.c:433:6: note: declared here
  433 | void print_ascii_generic(struct ascii* art, uint32_t la, int32_t termw, const char** attribute_fields, bool hybrid_architecture) {
      |      ^~~~~~~~~~~~~~~~~~~
src/ppc/uarch.c:6:10: fatal error: sys/auxv.h: No such file or directory
    6 | #include <sys/auxv.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [cpufetch] Error 1

Actually, PowerPC was not supposed to work under macOS (see this table), but if you confirm it works now I'll be glad to change the table to reflect that!

@Dr-Noob
Copy link
Owner

Dr-Noob commented Jan 6, 2023

So this is needed too:

--- src/ppc/uarch.c.orig	2023-01-05 17:17:49.000000000 +0700
+++ src/ppc/uarch.c	2023-01-06 02:37:58.000000000 +0700
@@ -3,9 +3,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/auxv.h>
 #include <errno.h>
 
+#ifndef __APPLE__
+  #include <sys/auxv.h>
+#endif
+
 #include "uarch.h"
 #include "../common/global.h"
 

With this plus a patch by @suve it builds fine.

Quite funny - it seems like that include is not necessary at all...

@suve
Copy link
Author

suve commented Jan 6, 2023

Commit 874f890 builds fine in Fedora Linux.

Schamschula added a commit to macports/macports-ports that referenced this issue Jan 7, 2023
@Dr-Noob
Copy link
Owner

Dr-Noob commented Jan 8, 2023

Closing, feel free to reopen it if you find any additional issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants