Skip to content

Comments

Fix build issues with recent gcc toolchains#59

Open
larsks wants to merge 3 commits intoMikeBland:masterfrom
larsks:fix/linker-errors
Open

Fix build issues with recent gcc toolchains#59
larsks wants to merge 3 commits intoMikeBland:masterfrom
larsks:fix/linker-errors

Conversation

@larsks
Copy link

@larsks larsks commented Jan 30, 2026

Attempting to build this project using gcc 14.3.1 was failing with a number
of errors:

  • "dangerous relocation: unsupported relocation"
  • "Unknown destination type (ARM/Thumb)"
  • Undefined reference errors for syscall functions

This commit corrects these errors by making two changes:

  1. Redefine __errno: Previously, errno was accessed as a simple global
    variable. In GCC 14.x with newlib-nano, the libraries expect errno to
    be accessed via the __errno() function, not as a direct global symbol.
    We can avoid the relocation errors by providing the necessary function.

  2. Uncomment syscall stubs: These symbols are required by the standard
    library, even though we're not calling them. By providing stub
    implementations we avoid the undefined reference errors.

Additionally, this PR also adds some flags to suppress copious compiler warnings and fixes a syntax error in the Makefile that prevented the build from working on Linux systems.

The Makefile was setting:

    OBJDIR = $(OBJROOT)\obj_$(PROJECT)

The use of the backslash, which is an escape character in GNU make, was
causing the build to fail with:

    makefile:51: Linux
    test -d .\obj_ersky9x ||
    /bin/sh: 1: Syntax error: end of file unexpected
    makefile:1364: recipe for target '.\obj_ersky9x' failed
    make: *** [.\obj_ersky9x] Error 2

With this change, the build now proceeds correctly.
With gcc 14.3.1, this code produces hundreds of warnings of the form:

    warning: ISO C++17 does not allow 'register' storage class specifier
    [-Wregister]

And many warnings of the form:

    warning: taking address of packed member of 't_EEGeneral' may result in
    an unaligned pointer value [-Waddress-of-packed-member]

This commit updates `makefile` to suppress these warnings.
Attempting to build this project using gcc 14.3.1 was failing with a number
of errors:

- "dangerous relocation: unsupported relocation"
- "Unknown destination type (ARM/Thumb)"
- Undefined reference errors for syscall functions

This commit corrects these errors by making two changes:

1. Redefine `__errno`: Previously, `errno` was accessed as a simple global
   variable. In GCC 14.x with newlib-nano, the libraries expect `errno` to
   be accessed via the `__errno()` function, not as a direct global symbol.
   We can avoid the relocation errors by providing the necessary function.

2. Uncomment syscall stubs: These symbols are required by the standard
   library, even though we're not calling them. By providing stub
   implementations we avoid the undefined reference errors.
@larsks larsks changed the title fix/linker errors Fix build issues with recent gcc toolchains Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant