Opened 23 months ago

Last modified 23 months ago

#71657 new defect

fastfetch @2.29.0 build error: error: 'FAT_CIGAM_64' undeclared (first use in this function); did you mean 'MH_CIGAM_64'?

Reported by: barracuda156 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.10.5
Keywords: snowleopard Cc: herbygillot (Herby Gillot)
Port: fastfetch

Description

Somehow this does not work now:

[ 99%] Building C object CMakeFiles/libfastfetch.dir/src/util/binary_apple.c.o
/opt/local/bin/gcc-mp-14 -DFF_HAVE_CHAFA=1 -DFF_HAVE_GLOB=1 -DFF_HAVE_IMAGEMAGICK6=1 -DFF_HAVE_SQLITE3=1 -DFF_HAVE_THREADS=1 -DFF_HAVE_UTMPX=1 -DFF_HAVE_WCWIDTH -DFF_HAVE_WORDEXP=1 -DFF_HAVE_ZLIB=1 -DFF_LIBSYSTEM_VERSION=\"117.0.0\" -DFF_PACKAGES_DISABLE_LIST=FF_PACKAGES_FLAG_WINGET_BIT -DFF_USE_SYSTEM_YYJSON -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -D_DARWIN_C_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_XOPEN_SOURCE -D__STDC_WANT_LIB_EXT1__ -I/opt/local/include/ImageMagick-6 -I/opt/local/include/chafa -I/opt/local/lib/chafa/include -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/build -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src -isystem /opt/local/include -pipe -Os -F/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -Wall -Wextra -Wconversion -Wno-error=uninitialized -Werror=return-type -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-error=int-conversion -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -MD -MT CMakeFiles/libfastfetch.dir/src/util/binary_apple.c.o -MF CMakeFiles/libfastfetch.dir/src/util/binary_apple.c.o.d -o CMakeFiles/libfastfetch.dir/src/util/binary_apple.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c: In function 'readData':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:19:20: warning: conversion from 'off_t' {aka 'long long int'} to 'long int' may change value [-Wconversion]
   19 |     fseek(objFile, offset, SEEK_SET);
      |                    ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c: In function 'dumpMachHeader':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:91:90: warning: conversion from 'uint64_t' {aka 'long long unsigned int'} to 'size_t' {aka 'long unsigned int'} may change value [-Wconversion]
   91 |                 if (!handleMachSection(objFile, section.sectname, section.offset, section.size, cb, userdata, minLength))
      |                                                                                   ~~~~~~~^~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c: In function 'dumpFatHeader':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:126:66: error: 'FAT_CIGAM_64' undeclared (first use in this function); did you mean 'MH_CIGAM_64'?
  126 |     bool needSwap = header.magic == FAT_CIGAM || header.magic == FAT_CIGAM_64;
      |                                                                  ^~~~~~~~~~~~
      |                                                                  MH_CIGAM_64
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:126:66: note: each undeclared identifier is reported only once for each function it appears in
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c: In function 'ffBinaryExtractStrings':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:179:85: error: 'FAT_CIGAM_64' undeclared (first use in this function); did you mean 'MH_CIGAM_64'?
  179 |     if (magic != MH_MAGIC && magic != MH_MAGIC_64 && magic != FAT_CIGAM && magic != FAT_CIGAM_64 && magic != FAT_MAGIC && magic != FAT_MAGIC_64)
      |                                                                                     ^~~~~~~~~~~~
      |                                                                                     MH_CIGAM_64
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:179:132: error: 'FAT_MAGIC_64' undeclared (first use in this function); did you mean 'FAT_MAGIC'?
  179 |     if (magic != MH_MAGIC && magic != MH_MAGIC_64 && magic != FAT_CIGAM && magic != FAT_CIGAM_64 && magic != FAT_MAGIC && magic != FAT_MAGIC_64)
      |                                                                                                                                    ^~~~~~~~~~~~
      |                                                                                                                                    FAT_MAGIC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.29.0/src/util/binary_apple.c:186:1: error: control reaches end of non-void function [-Werror=return-type]
  186 | }
      | ^
cc1: some warnings being treated as errors

Regardless of the error, this should probably be fixed, it does not look right:

    // MH_CIGAM and MH_CIGAM_64 seem to be no longer used, as `swap_mach_header` is marked as deprecated.
    // However FAT_CIGAM and FAT_CIGAM_64 are still used (/usr/bin/vim).
    if (magic != MH_MAGIC && magic != MH_MAGIC_64 && magic != FAT_CIGAM && magic != FAT_CIGAM_64 && magic != FAT_MAGIC && magic != FAT_MAGIC_64)
        return "Unsupported format or big endian mach-o file";

Change History (1)

comment:1 Changed 23 months ago by barracuda156

I kinda wonder how it compiles on 10a190, since Apple's fat.h misses those defines in it (and in fact in several later macOS versions as well). Anyway, FWIW, this fixes the build and produces a working app on 10.6.8:

--- a/src/util/binary_apple.c
+++ b/src/util/binary_apple.c
@@ -10,6 +10,13 @@
 #include <mach-o/swap.h>
 #include <mach-o/fat.h>
 
+#ifndef FAT_MAGIC_64
+#define FAT_MAGIC_64 0xcafebabf
+#endif
+#ifndef FAT_CIGAM_64
+#define FAT_CIGAM_64 0xbfbafeca
+#endif
+
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // swap_fat_arch
 
 // Ref: https://github.com/AlexDenisov/segment_dumper/blob/master/main.c

The binary_apple.c code should be reviewed with regard to BE still.

Last edited 23 months ago by barracuda156 (previous) (diff)
Note: See TracTickets for help on using tickets.