agbcc icon indicating copy to clipboard operation
agbcc copied to clipboard

build script fails on newer version of MacOS

Open tustin2121 opened this issue 4 years ago • 17 comments

On MacOS Catalina and above, builds of the agbcc project always fail. Several people have reported this problem in various places in the discord server, myself being one of them.

Symptoms generally include the build.sh script failing partway through with the following error:

gcc -MT toplev.o -MMD -MP -MF .d/toplev.Td -g -std=gnu11 -DOLD_COMPILER -I/usr/local/opt/qt/include -I. -I. -c toplev.c
toplev.c:1048:11: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
    error(message);
          ^~~~~~~
toplev.c:1048:11: note: treat the string as an argument to avoid this
    error(message);
          ^
          "%s", 
toplev.c:2382:13: error: implicit declaration of function 'unlink' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            unlink(aux_info_file_name);
            ^
toplev.c:2390:13: error: implicit declaration of function 'unlink' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            unlink(offset_info_file_name);
            ^
toplev.c:3486:14: warning: 'sizeof (indep_options)' will return the size of the pointer, not the array itself [-Wsizeof-pointer-div]
    for (k = NUM_ELEM(indep_options); k--; )
             ^~~~~~~~~~~~~~~~~~~~~~~
toplev.c:728:34: note: expanded from macro 'NUM_ELEM'
#define NUM_ELEM(a)  (sizeof (a) / sizeof ((a)[0]))
                      ~~~~~~~~~~ ^
toplev.c:3441:32: note: pointer 'indep_options' declared here
    lang_independent_options * indep_options;
                               ^
2 warnings and 2 errors generated.
make: *** [toplev.o] Error 1

and/or attempt to call make on one of pret's projects failing with the following error:

clang: error: unknown argument: '-Map'

The problem may lie in the fact that mac uses clang for its implementation of gcc, but simply installing gcc via homebrew does not fix the problem. Manually bypassing clang (by setting CC to a specific version installed via homebrew like gcc-9 or gcc-10) seems to function as a workaround in the meantime.

Ideally, the build script should deal with the potential problem and either fix or give instructions for fixing the problem. Failing that, some sort of documentation on how to set up agbcc on new MacOS would help greatly.

tustin2121 avatar Jan 23 '21 22:01 tustin2121

unlink is supposed to be included in <unistd.h>. Looking through the commit history, <unistd.h> was never included in the first place, and I'm not sure why the gcc developers at the time didn't include it. Try including <unistd.h> and see if that helps.

luckytyphlosion avatar Jan 24 '21 04:01 luckytyphlosion

I tried installing Clang on WSL1 (both Clang 10 and Clang 12), and I didn't seem to get the error. Clang simply treated it as a warning. The only way I could get it to error is by explicitly setting -Werror-implicit-function-declaration. I don't know why it's erroring for some users. Perhaps it has something to do with the default CFLAGS?

luckytyphlosion avatar Jan 26 '21 01:01 luckytyphlosion

From: https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes

Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

luckytyphlosion avatar Jan 26 '21 02:01 luckytyphlosion

(Should have posted in the above message <:masuda:544196054740893706>) So the solution is either to add -Wno-implicit-function-declaration, or to actually fix the implicit function declarations. Vestaiden in Discord tried the immediate solution of #include <unistd.h> but that only caused further issues.

luckytyphlosion avatar Jan 26 '21 02:01 luckytyphlosion

Facing same issues on Macbook Pro M1 (Apple Silicon) with Big Sur 11.2.1, any updates?

Manurocker95 avatar Mar 12 '21 11:03 Manurocker95

MacBook Pro with Big Sur 11.2.2 here, same issue.

LucaBGt avatar Mar 12 '21 12:03 LucaBGt

https://github.com/pizza2004/agbcc/commit/870e98780af6df3076d65d4c2af5251f0e4f5de2

This commit makes it build, but it catches somewhere else and I cannot figure out why.

pizza2004 avatar Mar 13 '21 14:03 pizza2004

pizza2004@870e987

This commit makes it build, but it catches somewhere else and I cannot figure out why.

Not working for me:

image

Manurocker95 avatar Mar 28 '21 19:03 Manurocker95

I never encountered anything like that and I'm not really equipped to tell you why it's happening either. Apparently downloading gmake and gcc will make it function like on other systems and it'll no longer be a problem, so I guess that's the solution now.

pizza2004 avatar Mar 29 '21 07:03 pizza2004

I never encountered anything like that and I'm not really equipped to tell you why it's happening either. Apparently downloading gmake and gcc will make it function like on other systems and it'll no longer be a problem, so I guess that's the solution now.

Any tutorial to how to configure them on macos?

Because I'm supposed to have GNU Make 3.81 and the latest gcc-arm-none-eabi

Manurocker95 avatar Mar 29 '21 11:03 Manurocker95

I'm not sure, I just know that's what luckytyphlosion was talking about on the Discord.

pizza2004 avatar Mar 29 '21 11:03 pizza2004

I'm not sure, I just know that's what luckytyphlosion was talking about on the Discord.

His repo doesn't allow issues and Pret hasn't updated this issue so I guess I'm stuck :/

Manurocker95 avatar Mar 29 '21 12:03 Manurocker95

I am lazy and busy, ask in 3-4 weeks when I'll have more time :trollface:

luckytyphlosion avatar Mar 30 '21 19:03 luckytyphlosion

I am lazy and busy, ask in 3-4 weeks when I'll have more time :trollface:

what about now (?)

Manurocker95 avatar May 03 '21 15:05 Manurocker95

Join the Discord (check any one of the decompilation readmes) and I can help resolve the macOS problem.

luckytyphlosion avatar May 03 '21 18:05 luckytyphlosion

Segfault seems to be specific to Macs with M1 Tried to ./build.sh on three differents macs running Big Sur 11.4, had no success with the M1 one (segfault 11)

TGFbSMAD avatar Jul 07 '21 09:07 TGFbSMAD

Fixed in #39

rawr51919 avatar Jun 24 '22 17:06 rawr51919