pret / agbcc

C compiler
104 stars 75 forks source link

Error on building agbcc ([Makefile:81: expr.o] Error 1) #69

Open TheDarkSword opened 1 month ago

TheDarkSword commented 1 month ago

Hello, I'm on Arch Linux (EndeavourOS distro). I installed with pacman all dependencies listed in the INSTALL.md but when i try to build agbcc it fail with: make: [Makefile:81: expr.o] Error 1 make: exit from directory «/home//pokemon-emerald/agbcc/gcc»

Here full log file: https://pastebin.com/iWbB2jU0

The issue is similar to this

mid-kid commented 1 month ago

Try the following patch:

diff --git a/gcc/expr.h b/gcc/expr.h
index 466b4b1..e7f8f79 100755
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -356,7 +356,7 @@ typedef struct optab
 #define GEN_FCN(CODE) (*insn_gen_function[(int) (CODE)])
 #endif

-extern rtx (*const insn_gen_function[]) (rtx, ...);
+extern rtx (*const insn_gen_function[]) ();

 extern optab add_optab;
 extern optab sub_optab;
TheDarkSword commented 1 month ago

This resolve this issue. Thank you so much!

But there is another problem: creating cache ./config.cache checking LIBRARY_PATH variable... ok checking GCC_EXEC_PREFIX variable... ok checking host system type... i386-pc-linux-gnu checking target system type... arm-unknown-elf checking build system type... i386-pc-linux-gnu checking for gcc... gcc checking whether the C compiler (gcc ) works... no configure: error: installation or configuration problem: C compiler cannot create executables. mv: cannot stat 'gcc_arm/cc1': No such file or directory

The build stop here

mid-kid commented 1 month ago

Fix the same thing in gcc_arm/expr.h

TheDarkSword commented 1 month ago

I did, but the error still the same (even with a fresh git clone and modifying these files)

mid-kid commented 1 month ago

Re-clone the repository and try this patch: https://cdn.discordapp.com/attachments/528962845648355353/1239686241608405032/0001-Fix-building-with-GCC-14-and-Clang-16.patch?ex=6643d348&is=664281c8&hm=9aad9e12c32045ddebad4eac7a7e71603ece43e89683cf48fcc1eb0e1dd22d2e&

The underlying issue is that GCC 14 broke a bunch of things but nobody has this version of the compiler yet, so if this still doesn't work, I encourage you to either downgrade GCC or try a different distribution until some of us have had time to get this new version and fix it.

TheDarkSword commented 1 month ago

Ok I will try, thank you very much. But Why gcc 14 broke all?

mid-kid commented 1 month ago

I don't know why, exactly, but the gcc 14 update enables some -Werror flags by default, refusing to compile older code.

superluserdo commented 1 month ago

@mid-kid I just got into trying out pokemon decomp and ran into this exact issue, to find that you had posted a patch 3 minutes ago! After applying this patch and fixing a couple of seemingly separate problems in the agbcc configure scripts I've successfully built a working sapphire ROM. Thanks! (gcc version 14.1.1 20240507).

mid-kid commented 1 month ago

What separate problems?

superluserdo commented 1 month ago

Sorry, I was about to write an issue but realised that the configure script problems were introduced by the patch itself, they weren't separate.

1: In gcc_arm, the patch introduces an error fallthrough case for the switch statement for $machine:

@@ -2905,6 +2909,11 @@ for machine in $build $host $target; do
                tmake_file=arm/t-thumb-elf
                fixincludes=Makefile.in # There is nothing to fix
                ;;
+
+       *)
+               echo "Configuration $machine not supported" 1>&2
+               exit 1
+               ;;
        esac

This is a separate case statement to the check for *-*-linux-gnu*, so a machine of this type will give an error. Either removing the error fallthrough or combining the switch statements fixes this.

2: By commenting out the body of the if statement here:

@@ -3445,12 +3455,12 @@ fi

 # If we have ld in the build tree, make a link to it.
 if test -f ../ld/Makefile; then
-       rm -f ld; $symbolic_link ../ld/ld-new$host_exeext ld$host_exeext 2>/dev/null
+#      rm -f ld; $symbolic_link ../ld/ld-new$host_exeext ld$host_exeext 2>/dev/null
 fi

The if statement fails to parse. Commenting out the whole if statement works.

My changes fixed the above patch on my machine:

index c350e76..9e64093 100755
--- a/gcc_arm/configure
+++ b/gcc_arm/configure
@@ -2892,9 +2892,7 @@ for machine in $build $host $target; do
        *-*-linux-gnu*)
                xm_defines="HAVE_ATEXIT POSIX BSTRING"
                ;;
-       esac

-       case $machine in
        # Support site-specific machine types.
        arm*-*-elf)
                tm_file=arm/unknown-elf.h
@@ -3454,9 +3452,9 @@ if test -f ../binutils/Makefile; then
 fi

 # If we have ld in the build tree, make a link to it.
-if test -f ../ld/Makefile; then
+#if test -f ../ld/Makefile; then
 #      rm -f ld; $symbolic_link ../ld/ld-new$host_exeext ld$host_exeext 2>/dev/null
-fi
+#fi

 # Figure out what assembler alignment features are present.
 echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6
GiantBlargg commented 1 month ago

@mid-kid Could you provide another source for that patch? The link seems to have timed out.

mid-kid commented 1 month ago

0001-Fix-building-with-GCC-14-and-Clang-16.patch

danieltanfh95 commented 2 weeks ago

agbcc compiled on macos shows the following error at the end:

Configuration i386-pc-linux-gnu not supported
mv: rename gcc_arm/cc1 to agbcc_arm: No such file or directory
danieltanfh95 commented 2 weeks ago

can confirm that @superluserdo's fix works, patch file attached agbcc-8-23-02 PM.patch

miamilabs commented 3 days ago

This resolve this issue. Thank you so much!

But there is another problem: creating cache ./config.cache checking LIBRARY_PATH variable... ok checking GCC_EXEC_PREFIX variable... ok checking host system type... i386-pc-linux-gnu checking target system type... arm-unknown-elf checking build system type... i386-pc-linux-gnu checking for gcc... gcc checking whether the C compiler (gcc ) works... no configure: error: installation or configuration problem: C compiler cannot create executables. mv: cannot stat 'gcc_arm/cc1': No such file or directory

The build stop here

Did you find a fix for your error? I run into same problem on macbook m2.

checking for gcc... gcc
checking whether the C compiler (gcc  ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.
mv: rename gcc_arm/cc1 to agbcc_arm: No such file or directory
danieltanfh95 commented 3 days ago

@miamilabs did you apply the patch i linked above?

miamilabs commented 3 days ago

@miamilabs did you apply the patch i linked above?

I did apply both patches so this was the reason why it still did not work. After reset and your patch, everything worked like a charm.

Thank you for the effort and sharing

danieltanfh95 commented 3 days ago

@miamilabs did you apply the patch i linked above?

I did apply both patches so this was the reason why it still did not work. After reset and your patch, everything worked like a charm.

Thank you for the effort and sharing

Yes, only one final patch is needed.