Skip to content

problem compiling chawan for ARM 32 Bit #26111

Description

@wbx-github

Nim Version

Hi,
./output/host/bin/nim -v
Nim Compiler Version 2.2.10 [Linux: amd64]

Description

I am new to nim. I want to add a package for nim and chawan to buildroot.
Therefore I am cross-compiling chawan and it works great for aarch64 and x86_64.

But for arm 32 Bit I get a lot of compilation errors with gcc 15.3.0:

buildroot/output/build/chawan-0.4.4/.obj/release/cha/@ppure@scollections@stables.nim.c:7039:377: error: passing argument 3 of ‘__builtin_saddl_overflow’ from incompatible pointer type [-Wincompatible-pointer-types]
buildroot/output/host/lib/nimbase.h:601:67: note: in definition of macro ‘nimAddInt’
  601 |       #define nimAddInt(a, b, res) __builtin_saddl_overflow(a, b, res)

Something like this patch make chawan work for me on a RPI4 with ARM 32 Bit Buildroot:

diff -Nur nim-2.2.10.orig/lib/nimbase.h nim-2.2.10/lib/nimbase.h
--- nim-2.2.10.orig/lib/nimbase.h	2026-04-24 05:34:24.000000000 +0200
+++ nim-2.2.10/lib/nimbase.h	2026-08-15 11:24:55.098128970 +0200
@@ -596,16 +596,9 @@
   #define nimMulInt64(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res)
 
   #if NIM_INTBITS == 32
-    #if (de```fined(__arm__) || defined(__riscv)) && defined(__GNUC__)
-      /* arm-none-eabi-gcc and riscv32-unknown-elf-gcc targets define int32_t as long int */
-      #define nimAddInt(a, b, res) __builtin_saddl_overflow(a, b, res)
-      #define nimSubInt(a, b, res) __builtin_ssubl_overflow(a, b, res)
-      #define nimMulInt(a, b, res) __builtin_smull_overflow(a, b, res)
-    #else
       #define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res)
       #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
       #define nimMulInt(a, b, res) __builtin_smul_overflow(a, b, res)
-    #endif
   #else
     /* map it to the 'long long' variant */
     #define nimAddInt(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res)

What is the correct way to fix this?

best regards
Waldemar

Current Output


Expected Output


Known Workarounds

No response

Additional Information

No response

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