GithubHelp home page GithubHelp logo

pret / agbcc Goto Github PK

View Code? Open in Web Editor NEW
102.0 9.0 75.0 13.69 MB

C compiler

C++ 1.91% C 95.32% Assembly 0.31% Shell 0.14% Makefile 0.65% GDB 0.01% Yacc 0.14% Batchfile 0.01% JavaScript 0.01% Roff 0.01% Component Pascal 0.40% DIGITAL Command Language 0.24% TeX 0.85% sed 0.01%
c compiler

agbcc's People

Contributors

916253 avatar aaaaaa123456789 avatar camthesaxman avatar ethteck avatar holmesmr avatar huderlem avatar luckytyphlosion avatar meithecatte avatar pikalaxalt avatar revosucks avatar stanhash avatar whengryphonsfly avatar yamaarashi avatar yenatch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agbcc's Issues

arm-none-eabi-as: command not found

Failure ./build.sh:

make: Entering directory '/agbcc/agbcc/libgcc'
rm -f tmplibgcc1.a
set -e
for name in _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX; \
do \
  echo ${name}; \
  cc -E -undef -nostdinc -DL${name} -x assembler-with-cpp -o ${name}.s lib1thumb.asm; \
  bash -c 'echo -e ".text\n\t.align\t2, 0\n"' >> ${name}.s ; \
  arm-none-eabi-as -mcpu=arm7tdmi -o ${name}.o ${name}.s; \
  rm -f ${name}.s; \
  arm-none-eabi-ar -rc tmplibgcc1.a ${name}.o; \
  rm -f ${name}.o; \
done
_udivsi3
/bin/sh: line 5: arm-none-eabi-as: command not found
/bin/sh: line 7: arm-none-eabi-ar: command not found
_divsi3
/bin/sh: line 5: arm-none-eabi-as: command not found
/bin/sh: line 7: arm-none-eabi-ar: command not found
_umodsi3
/bin/sh: line 5: arm-none-eabi-as: command not found
/bin/sh: line 7: arm-none-eabi-ar: command not found
_modsi3
/bin/sh: line 5: arm-none-eabi-as: command not found
/bin/sh: line 7: arm-none-eabi-ar: command not found
_dvmd_tls
/bin/sh: line 5: arm-none-eabi-as: command not found
/bin/sh: line 7: arm-none-eabi-ar: command not found
_call_via_rX
/bin/sh: line 5: arm-none-eabi-as: command not found
/bin/sh: line 7: arm-none-eabi-ar: command not found
mv tmplibgcc1.a libgcc1.a
mv: cannot stat 'tmplibgcc1.a': No such file or directory
make: *** [Makefile:36: libgcc1.a] Error 1
make: Leaving directory '/agbcc/agbcc/libgcc'

Consider adding readme and licensing info

Hi there, this repo popped up in my GitHub feed. From a stand-alone, only-looking-at-this-repo perspective, I'm able to determine it's a C compiler (though that piece of info is github-specific), but not much else.

Just thought I'd mention this, having a brief README file describing what this repository is would likely help with discovery, preservation, etc. Same applies to a LICENSE or COPYING file.

libgcc.a fails to build on Linux Mint 18

I downloaded the repo and tried running build.sh, which failed, because it couldn't move libgcc/libgcc.a, since it didn't exist. I went into the libgcc directory and ran make, which told me it was trying to run ../old_agbcc, which didn't exist. I created the file without any contents and ran build.sh again. This time it worked.

Makefile:1: /base_tools: No such file or directory

Hi, when I run build.sh I get the following issues at the end, and it leads me to not be able to use install.sh afterward I think because of a lack of libgcc.a and libc.a. Here's the error:

Makefile:1: /base_tools: No such file or directory
make: *** No rule to make target '/base_tools'. Stop.
make: Leaving directory '/home/marina/git/agbcc/libgcc'

Edit: To clarify, when I try running install.sh after this I get thrown:
cp: cannot stat 'libgcc.a': No such file or directory

Buildscript failing.


gengenrtl.c:213:18: error: implicit declaration of function ‘strlen’ [-Werror=implicit-function-declaration]
  213 |            (int) strlen (format) - 1);
      |                  ^~~~~~
gengenrtl.c:213:18: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
gengenrtl.c:213:18: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
gengenrtl.c:213:18: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
gengenrtl.c: In function ‘genlegend’:
gengenrtl.c:230:6: error: unknown type name ‘FILE’
  230 |      FILE *f;
      |      ^~~~
gengenrtl.c:230:6: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
gengenrtl.c:232:3: warning: incompatible implicit declaration of built-in function ‘fprintf’ [-Wbuiltin-declaration-mismatch]
  232 |   fprintf (f, "/* Generated automaticaly by the program `gengenrtl'\n");
      |   ^~~~~~~
gengenrtl.c:232:3: note: include ‘<stdio.h>’ or provide a declaration of ‘fprintf’
gengenrtl.c: In function ‘genheader’:
gengenrtl.c:238:6: error: unknown type name ‘FILE’
  238 |      FILE *f;
      |      ^~~~
gengenrtl.c:238:6: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
gengenrtl.c:243:14: error: ‘formats’ undeclared (first use in this function)
  243 |   for (fmt = formats; *fmt; ++fmt)
      |              ^~~~~~~
gengenrtl.c:246:3: warning: incompatible implicit declaration of built-in function ‘fprintf’ [-Wbuiltin-declaration-mismatch]
  246 |   fprintf(f, "\n");
      |   ^~~~~~~
gengenrtl.c:246:3: note: include ‘<stdio.h>’ or provide a declaration of ‘fprintf’
rtl.h:48:28: error: ‘LAST_AND_UNUSED_RTX_CODE’ undeclared (first use in this function)
   48 | #define NUM_RTX_CODE ((int)LAST_AND_UNUSED_RTX_CODE)
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~
gengenrtl.c:248:19: note: in expansion of macro ‘NUM_RTX_CODE’
  248 |   for (i = 0; i < NUM_RTX_CODE; i++)
      |                   ^~~~~~~~~~~~
gengenrtl.c:250:27: error: ‘defs’ undeclared (first use in this function)
  250 |       if (special_format (defs[i].format))
      |                           ^~~~
gengenrtl.c: In function ‘gencode’:
gengenrtl.c:258:6: error: unknown type name ‘FILE’
  258 |      FILE *f;
      |      ^~~~
gengenrtl.c:258:6: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
gengenrtl.c:262:3: error: implicit declaration of function ‘fputs’ [-Werror=implicit-function-declaration]
  262 |   fputs ("#include \"config.h\"\n", f);
      |   ^~~~~
gengenrtl.c:262:3: note: include ‘<stdio.h>’ or provide a declaration of ‘fputs’
gengenrtl.c:273:14: error: ‘formats’ undeclared (first use in this function)
  273 |   for (fmt = formats; *fmt; ++fmt)
      |              ^~~~~~~
gengenrtl.c: In function ‘main’:
gengenrtl.c:300:3: error: unknown type name ‘FILE’
  300 |   FILE *f;
      |   ^~~~
gengenrtl.c:300:3: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
gengenrtl.c:303:5: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
  303 |     exit (1);
      |     ^~~~
gengenrtl.c:303:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
gengenrtl.c:307:7: error: implicit declaration of function ‘fopen’ [-Werror=implicit-function-declaration]
  307 |   f = fopen (argv[1], "w");
      |       ^~~~~
gengenrtl.c:307:7: note: ‘fopen’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
gengenrtl.c:307:5: warning: assignment to ‘int *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  307 |   f = fopen (argv[1], "w");
      |     ^
gengenrtl.c:310:7: error: implicit declaration of function ‘perror’ [-Werror=implicit-function-declaration]
  310 |       perror(argv[1]);
      |       ^~~~~~
gengenrtl.c:311:7: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
  311 |       exit (1);
      |       ^~~~
gengenrtl.c:311:7: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
gengenrtl.c:315:3: error: implicit declaration of function ‘fclose’; did you mean ‘false’? [-Werror=implicit-function-declaration]
  315 |   fclose(f);
      |   ^~~~~~
      |   false
gengenrtl.c:317:5: warning: assignment to ‘int *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  317 |   f = fopen (argv[2], "w");
      |     ^
gengenrtl.c:321:7: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
  321 |       exit (1);
      |       ^~~~
gengenrtl.c:321:7: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
gengenrtl.c:327:3: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
  327 |   exit (0);
      |   ^~~~
gengenrtl.c:327:3: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
cc1: some warnings being treated as errors
make: *** [Makefile:122: gengenrtl.o] Error 1
make: Leaving directory '/home/f-00/agbcc/gcc'

there are so many more errors, but it's too long

not sure what's going on, i'm running Arch Linux, i tried removing -Werror=implicit-function-declaration from the make file of gcc to no avail, either something is very wrong with my system or something else that i'm missing is not working.

i will provide more details if necessary.

Build script fails on NixOS

I don't have very much knowledge on topic of coding and such... so I'll post my log in hopes that I will receive some support in some way.

gcc -MT toplev.o -MMD -MP -MF .d/toplev.Td -g -std=gnu11 -Werror-implicit-function-declaration -DOLD_COMPILER  -I. -I. -c toplev.c
toplev.c: In function ‘fatal_insn’:
toplev.c:1049:5: error: format not a string literal and no format arguments [-Werror=format-security]
 1049 |     error(message);
      |     ^~~~~
toplev.c: In function ‘v_message_with_decl’:
toplev.c:1235:26: warning: ‘%ld’ directive writing between 1 and 20 bytes into a region of size 5 [-Wformat-overflow=]
 1235 |         sprintf(fmt, "%%.%lds", width);
      |                          ^~~
toplev.c:1235:22: note: directive argument in the range [-9223372036854775808, 255]
 1235 |         sprintf(fmt, "%%.%lds", width);
      |                      ^~~~~~~~~
In file included from /nix/store/07kmxfmj8i8h76zzz9vw9zfvxsarqr5d-glibc-2.34-210-dev/include/stdio.h:888,
                 from thumb.h:1078,
                 from telf.h:25,
                 from config.h:12,
                 from toplev.c:26:
/nix/store/07kmxfmj8i8h76zzz9vw9zfvxsarqr5d-glibc-2.34-210-dev/include/bits/stdio2.h:38:10: note: ‘__builtin___sprintf_chk’ output between 5 and 24 bytes into a destination of size 7
   38 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   39 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   40 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make: *** [Makefile:81: toplev.o] Error 1
make: Leaving directory '/home/tryzen/Code/agbcc/gcc'

Error 126 when attempting to run build.sh

ryan@REDFOX MSYS ~/Desktop/decomps/new/agbcc
$ ./build.sh
make: Entering directory '/home/ryan/Desktop/decomps/new/agbcc/gcc'
rm -f agbcc agbcc.exe old_agbcc old_agbcc.exe
rm -f toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o function.o stmt.o except.o expr.o calls.o expmed.o explow.o optabs.o varasm.o emit-rtl.o genrtl.o real.o regmove.o dwarf2out.o alias.o integrate.o jump.o cse.o loop.o unroll.o flow.o stupid.o combine.o varray.o regclass.o local-alloc.o global.o reload.o reload1.o caller-save.o gcse.o insn-peep.o final.o recog.o insn-opinit.o insn-recog.o insn-extract.o insn-output.o insn-emit.o lcm.o insn-attrtab.o thumb.o getpwd.o convert.o dyn-string.o splay-tree.o graph.o sbitmap.o resource.o c-parse.o c-lex.o c-decl.o c-typeck.o c-convert.o c-aux-info.o c-common.o c-iterate.o rtl.o bitmap.o obstack.o rtlanal.o print-rtl.o
rm -f genrtl.c genrtl.h insn-peep.c insn-opinit.c insn-recog.c insn-extract.c insn-output.c insn-emit.c insn-attrtab.c tree-check.h insn-config.h insn-flags.h insn-codes.h insn-attr.h
rm -f genemit genoutput genrecog genextract genflags gencodes genconfig genpeep gengenrtl gencheck genattr genattrtab genopinit genemit.exe genoutput.exe genrecog.exe genextract.exe genflags.exe gencodes.exe genconfig.exe genpeep.exe gengenrtl.exe gencheck.exe genattr.exe genattrtab.exe genopinit.exe genemit.o genoutput.o genrecog.o genextract.o genflags.o gencodes.o genconfig.o genpeep.o gengenrtl.o gencheck.o genattr.o genattrtab.o genopinit.o
rm -f s-config s-flags s-codes s-emit s-recog s-opinit s-extract s-peep \
s-attr s-attrtab s-output s-genrtl s-check
rm -f -r .d
make: Leaving directory '/home/ryan/Desktop/decomps/new/agbcc/gcc'
make: Entering directory '/home/ryan/Desktop/decomps/new/agbcc/gcc'
gcc -g -std=gnu11 -Werror-implicit-function-declaration -DOLD_COMPILER  -I. -I. -c gengenrtl.c
gcc -g -std=gnu11 -Werror-implicit-function-declaration -DOLD_COMPILER -o gengenrtl gengenrtl.o
./gengenrtl tmp-genrtl.h tmp-genrtl.c
./gengenrtl: ./gengenrtl: cannot execute binary file
make: *** [Makefile:223: s-genrtl] Error 126
make: Leaving directory '/home/ryan/Desktop/decomps/new/agbcc/gcc'

When I attempt to compile on Windows 11 build 22509, the build of agbcc fails in Msys2 as provided by devKitPro, with all the installed items as per pokeemerald's installation instructions.

libgcc.a does not build identically on Linux

I've set up my pokeruby environment on a Linux machine, but my pokeruby.gba would not match the original checksum. I found out that this is because the libgcc.a that I built on Linux is not identical to the libgcc.a from here https://github.com/YamaArashi/pokeruby-tools/tree/master/tools/agbcc/lib. The correct SHA1 checksum of libgcc.a is 8ace9b343e4e716bada7a6dc6c2e5d628714f638, while the one I built on Linux is e8d0737035dfabc9e19cf86304ab26cc7df6fd55. I did this on my school's build server, which runs the x86-64 version of Oracle Linux 7. Copying over the libgcc.a from my Windows machine allowed me to build an identical copy of pokeruby.

-fhex-asm prints too many digits for negative numbers in data labels

This happens on Ubuntu 14.04 64-bit.
Using the -fhex-asm flag causes negative numbers that were converted to hex to be printed with 8 digits regardless of the size. This causes the assembler to generate warnings, though it truncates them and still produces the same code regardless. Here is the compiler output for wallclock.c, compiled with and without -fhex-asm. In particular, look at gClockHandCoords.

wallclock_with_fhex_asm.s.txt
wallclock_without_fhex_asm.s.txt

build script fails on newer version of MacOS

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.

Build.sh fails with "error: incompatible function pointer"

I am using MacOs 14.4.1 with Apple M3 Chip. I installed Apple's Roesetta on my system and followed the installation instructions of pokemon emerald.

While trying to build agbcc I have encountered the following error:

expr.c:8863:19: error: incompatible function pointer types initializing 'rtx (*)(rtx, rtx, rtx)' (aka 'struct rtx_def ()(struct rtx_def *, struct rtx_def *, struct rtx_def *)') with an expression of type 'rtx (rtx, ...)' (aka 'struct rtx_def *(struct rtx_def *, ...)') [-Wincompatible-function-pointer-types]
rtx (*gen_insn)(rtx, rtx, rtx) = GEN_FCN (icode);

I added the log as a text file, in case it helps.
build.log

Multiple declaration errors while compiling

Hi,
As the title states, I am getting multiple declaration errors while trying to compile:

rtl.c:121:13: error: ‘BITS_PER_UNIT’ undeclared here (not in a function)
  121 |   ((SIZE) * BITS_PER_UNIT >= HOST_BITS_PER_WIDE_INT) ? ~(unsigned HOST_WIDE_INT)0 : ((unsigned HOST_WIDE_INT) 1 << (SIZE) * BITS_PER_UNIT) - 1,

machmode.h:35:32: error: ‘HOST_BITS_PER_INT’ undeclared here (not in a function); did you mean ‘HOST_BITS_PER_WIDE_INT’?
   35 | #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT

system.h:353:8: error: ‘FATAL_EXIT_CODE’ undeclared (first use in this function)
  353 |  exit (FATAL_EXIT_CODE))

These are just a few I'm getting, if I fix these (either by re declaring or including the files that contain the declarations) I get more of these, until eventually I get an undefined FIRST_PSEUDO_REGISTER error, while looking for its declaration, I see there are multiple:

$ git grep "#define FIRST_PSEUDO_REGISTER"
gcc/thumb.h:#define FIRST_PSEUDO_REGISTER 17
gcc_arm/config/arm/arm.h:#define FIRST_PSEUDO_REGISTER  27
gcc_arm/config/arm/arm_010110a.h:#define FIRST_PSEUDO_REGISTER  27
gcc_arm/config/arm/arm_020422.h:#define FIRST_PSEUDO_REGISTER  27
gcc_arm/config/arm/arm_020428.h:#define FIRST_PSEUDO_REGISTER  27
gcc_arm/config/arm/arm_990720.h:#define FIRST_PSEUDO_REGISTER  27
gcc_arm/config/arm/thumb.h:#define FIRST_PSEUDO_REGISTER 17
gcc_arm/config/arm/thumb.h.orig:#define FIRST_PSEUDO_REGISTER 17
gcc_arm/config/arm/thumb_000513.h:#define FIRST_PSEUDO_REGISTER 17
gcc_arm/config/arm/thumb_020422.h:#define FIRST_PSEUDO_REGISTER 17
gcc_arm/config/arm/thumb_020428.h:#define FIRST_PSEUDO_REGISTER 17

This leads me to believe that this is not the proper approach to fix these issues. Do you know if I'm doing something wrong or missing something? I already applied the patch provided in #68, which solved the function pointer issues.

My system is running Arch Linux and has the following package versions:

  • arm-none-eabi-binutils 2.42-1.
  • gcc 14.1.1.
  • GNU Make 4.4.1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.