Skip to content

Conversation

maleyva1
Copy link
Contributor

Provides a fix for #23817.

With target arm-none-eabi, GCC defines int32_t to long int. Nim uses __builtin_sadd_overflow for 32-bit targets, but this emits warnings on GCC releases 13 and under, while generating an error on GCC 14. More info regarding this here and here.

The proposed PR attempts to address this issue for these targets by defining the nimAddInt, nimSubInt, and nimMulInt macros to use the appropriate compiler intrinsics for this platform.

As for as we know, the LLVM toolchain for bare metal Arm does not define int32_t as long int and has no need for this patch. Thus, we only define the above macros for GCC targeting arm-non-eabi.

@Araq Araq closed this Aug 12, 2024
@Araq Araq reopened this Aug 12, 2024
@Araq Araq added the merge_when_passes_CI mergeable once green label Aug 12, 2024
@Araq Araq merged commit c5b206d into nim-lang:devel Aug 12, 2024
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from c5b206d

Hint: mm: orc; opt: speed; options: -d:release
173437 lines; 7.898s; 654.785MiB peakmem

narimiran pushed a commit that referenced this pull request Sep 13, 2024
…cc. (#23835)

Provides a fix for #23817.

With target `arm-none-eabi`, GCC defines `int32_t` to `long int`. Nim
uses `__builtin_sadd_overflow` for 32-bit targets, but this emits
warnings on GCC releases 13 and under, while generating an error on GCC
14. More info regarding this
[here](https://gcc.gnu.org/gcc-14/porting_to.html#c) and
[here](https://gcc.gnu.org/pipermail/gcc-cvs/2023-December/394351.html).

The proposed PR attempts to address this issue for these targets by
defining the `nimAddInt`, `nimSubInt`, and `nimMulInt` macros to use the
appropriate compiler intrinsics for this platform.

As for as we know, the LLVM toolchain for bare metal Arm does not define
`int32_t` as `long int` and has no need for this patch. Thus, we only
define the above macros for GCC targeting `arm-non-eabi`.

(cherry picked from commit c5b206d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge_when_passes_CI mergeable once green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants