Skip to content

Fail to build csources_v3 on Raspberry Pi 5 with 32-bit Raspberry Pi OS #25296

@demotomohiro

Description

@demotomohiro

Nim Version

Nim Compiler Version 2.3.1 [Linux: arm]
Compiled at 2025-11-18
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 46d4079
active boot switches: -d:release

Description

Compiling csources_v3 on Raspberry Pi 5 with Raspberry Pi OS 32-bit fails.
You might get the same error on Raspberry Pi 3, 4 and zero 2 with Raspberry Pi OS 32-bit because they have 64bit CPU.

Current Output

$ sh build_all.sh
...
cc -Ic_code -w -fmax-errors=3 -fno-strict-aliasing -O3 -fno-ident -fno-math-errno    -c -o c_code/2_18/@[email protected] c_code/2_18
/@[email protected]
In file included from c_code/2_18/@[email protected]:4:
c_code/nimbase.h:273:35: error: static assertion failed: "Pointer size mismatch between Nim and C/C++ backend. You probably need to setup the
 backend compiler for target CPU."
  273 | #define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
      |                                   ^~~~~~~~~~~~~~
c_code/nimbase.h:562:1: note: in expansion of macro ‘NIM_STATIC_ASSERT’
  562 | NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "Pointer size mismatch between Nim and C/C++ backend. Y
ou probably need to setup the backend compiler for target CPU.");
      | ^~~~~~~~~~~~~~~~~

Expected Output

Compiles without errors

Known Workarounds

No response

Additional Information

It seems makefile in csources_v3 try to build code for 64bit CPU but gcc target is 32bit CPU.
On Raspberry Pi 5 with 32-bit OS, uname -m command prints aarch64 but gcc -dumpmachine prints arm-linux-gnueabihf.
As makefile in csources_v3 uses uname -m to detect CPU arch, it builds Nim code for 64bit CPU but gcc target is 32bit CPU.

If makefile uses gcc -dumpmachine instead of uname -m to detect CPU arch, it can detect gcc target CPU arch and probably prevents above error.
But parsing output of gcc -dumpmachine seems tricky.
https://wiki.osdev.org/Target_Triplet
https://mcyoung.xyz/2025/04/14/target-triples/
You can get CPU arch from target triplet easily as it is always comes first, but OS part is tricky.

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