Skip to content

agbcc fails to build on Arch Linux: Conflicting types in toplev.c with modern host GCC #2147

@aguiarsc

Description

@aguiarsc

I'm encountering an issue while trying to build agbcc as part of the setup for pokeemerald on a fully updated Arch Linux system, following the instructions in INSTALL.md.

System Information:

  • OS: Arch Linux (kernel: 6.12.30-1-lts)
  • Host GCC Version: gcc (GCC) 15.1.1 20250425
  • pokeemerald Branch: master (cloned recently following INSTALL.md)
  • agbcc Branch: master (cloned via git clone https://github.com/pret/agbcc --branch=master --single-branch --depth=1 as per INSTALL.MD)
  • Relevant Dependencies Installed: base-devel, git, gcc-multilib, libpng, pkgconf, imagemagick (for compare), gmp, libmpc, mpfr (all installed via pacman -Syu --needed ...)

Steps to Reproduce:

  1. Followed the Arch Linux setup instructions in pokeemerald/INSTALL.md.
  2. Ensured all listed dependencies were installed.
  3. Cloned the agbcc repository as specified.
  4. Navigated to the agbcc directory.
  5. Executed ./build.sh.

Observed Behavior:

The ./build.sh script fails during the second make pass within the agbcc/gcc subdirectory. The final error messages are:

make: *** [Makefile:1405: toplev.o] Error 1
mv: cannot stat 'gcc_arm/cc1': No such file or directory

Key Error Messages from build.sh Output:

The build fails when compiling toplev.c. The relevant compiler command is:

gcc -DCROSS_COMPILE -DIN_GCC   -DMULTIBYTE_CHARS=1   -g -Werror-implicit-function-declaration -Wno-error=incompatible-pointer-types  -DHAVE_CONFIG_H    -I. -I. -I./config -I./../include \
  -DTARGET_NAME=\"arm-elf\" \
  -c `echo ./toplev.c | sed 's,^\./,,'`

This results in several "conflicting types" and "too many arguments" errors, for example:

In file included from toplev.c:42:
output.h:48:12: error: conflicting types for ‘get_attr_length’; have ‘int(struct rtx_def *)’
   48 | extern int get_attr_length      PROTO((rtx));
      |            ^~~~~~~~~~~~~~~
In file included from toplev.c:37:
insn-attr.h:19:12: note: previous declaration of ‘get_attr_length’ with type ‘int(void)’
   19 | extern int get_attr_length ();
      |            ^~~~~~~~~~~~~~~

toplev.c:154:13: error: conflicting types for ‘dump_flow_info’; have ‘void(void)’
  154 | extern void dump_flow_info ();
      |             ^~~~~~~~~~~~~~
output.h:130:13: note: previous declaration of ‘dump_flow_info’ with type ‘void(FILE *)’
  130 | extern void dump_flow_info              PROTO((FILE *));
      |             ^~~~~~~~~~~~~~

toplev.c:2997:17: error: too many arguments to function ‘rest_of_decl_compilation’; expected 0, have 4
 2997 |                 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~  ~~~~
toplev.c:162:6: note: declared here
  162 | void rest_of_decl_compilation ();
      |      ^~~~~~~~~~~~~~~~~~~~~~~~

In file included from ./config/arm/aout.h:323,
                 from ./config/arm/elf.h:336,
                 from ./config/arm/unknown-elf.h:166,
                 from ./tm.h:3,
                 from ./config/i386/xm-i386.h:43,
                 from config.h:3,
                 from toplev.c:26:
./config/arm/arm.h:1890:41: error: too many arguments to function ‘arm_reorg’; expected 0, have 1
 1890 | #define MACHINE_DEPENDENT_REORG(INSN)   arm_reorg ((INSN))
      |                                         ^~~~~~~~~  ~~~~~~
toplev.c:4115:4: note: in expansion of macro ‘MACHINE_DEPENDENT_REORG’
 4115 |    MACHINE_DEPENDENT_REORG (insns);
      |    ^~~~~~~~~~~~~~~~~~~~~~~
./config/arm/arm.h:2182:6: note: declared here
 2182 | void arm_reorg (/* struct rtx_def * */);
      |      ^~~~~~~~~

(The full build log is quite extensive but can be provided if needed.)

Additionally, during the first make pass within agbcc/gcc (where -DOLD_COMPILER is defined), there are multiple warnings from ./genrecog:

Warning: `s_register_operand' not in PREDICATE_CODES

While these are warnings, I'm noting them in case they are related.

Suspected Cause:

These errors strongly suggest an incompatibility between the C codebase of agbcc (which is based on an older version of GCC) and the modern host GCC compiler on my Arch Linux system. The host compiler's stricter type checking, handling of function prototypes (K&R style vs. ANSI), and the use of flags like -Werror-implicit-function-declaration seem to be exposing these issues.

What I've Tried:

  • Ensuring all dependencies listed in INSTALL.MD are installed, including imagemagick for compare.
  • Performing the build in a completely clean clone of the agbcc repository.
  • Confirmed that the issue persists despite these steps.

Request:

Could you provide any guidance or known workarounds for building agbcc successfully on a modern Arch Linux system with a recent host GCC version? Are there specific patches required, or perhaps a recommended older version of host GCC that should be used for this build process?

Thank you for your time and help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions