You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing my keyboard firmware I noticed that the nice tricks me and @zevv where using to move .data from the data section of the binaries and into .text via the PROGMEM C macro didn't work any longer. Looking at the C sources it was obvious why, in 1.4.0 Nim would take this code:
While obviously an unnecessary copy in any scenario it completely breaks the PROGMEM things as it isn't possible on these chips to modify the .text section while running (at least not via whatever mechanism nimCopyMem uses). This leaves myData uninitialised on runtime.
I ran a git bisect with an automated script and found commit 99032ca to be the one introducing this new behaviour. Looking through it I identified 99032ca#diff-ee922073e19918f7b88397ee2092b6f34c21b0e9983cac3c9a5dae1b32ad2273R214 as the breaking change and reverting that on 1.4.2 did in fact fix the issue. This commit seems to be meant to avoid duplicating Nim constants in code, but somehow it also affects the code generation for let assignments. Looking at the code it's not obvious how it would be called for let assignments, that might be a bug in itself.
For reproduceability here are the code snippets and bisect script I used to test this:
In a freshly cloned Nim repo I created a directory progmemtest with this file: progmemtest.nim
typeTest=array[3, uint8]
let colKeys =Test([10'u8, 20, 30])
And in the root directory of the repo I created this bisect script: bisect.sh
#!/bin/bash
nim c -d:release koch
if [ $?-ne 0 ];thenexit 125
fi
./koch temp -d:release
if [ $?-ne 0 ];thenexit 125
fi
/tmp/nim/compiler/nim c --nimcache:progmemtest/nimcache -d:danger --opt:size --os:any --gc:arc -d:useMalloc progmemtest/progmemtest.nim
if [ $?-ne 0 ];thenexit 125
fiif grep -q "nimCopyMem"'progmemtest/nimcache/@mprogmemtest.nim.c';thenexit 1
elseexit 0
fi
Then I checked out the v1.4.0 branch and ran git bisect start; git bisect good; git bisect bad v1.4.2; git bisect run ./bisect.sh
The text was updated successfully, but these errors were encountered:
While developing my keyboard firmware I noticed that the nice tricks me and @zevv where using to move .data from the data section of the binaries and into .text via the PROGMEM C macro didn't work any longer. Looking at the C sources it was obvious why, in 1.4.0 Nim would take this code:
and generate this output (shortened identifiers for readability):
But with 1.4.2 the same Nim code would now generate this C code:
While obviously an unnecessary copy in any scenario it completely breaks the PROGMEM things as it isn't possible on these chips to modify the .text section while running (at least not via whatever mechanism
nimCopyMem
uses). This leavesmyData
uninitialised on runtime.I ran a git bisect with an automated script and found commit 99032ca to be the one introducing this new behaviour. Looking through it I identified 99032ca#diff-ee922073e19918f7b88397ee2092b6f34c21b0e9983cac3c9a5dae1b32ad2273R214 as the breaking change and reverting that on 1.4.2 did in fact fix the issue. This commit seems to be meant to avoid duplicating Nim constants in code, but somehow it also affects the code generation for
let
assignments. Looking at the code it's not obvious how it would be called forlet
assignments, that might be a bug in itself.For reproduceability here are the code snippets and bisect script I used to test this:
In a freshly cloned Nim repo I created a directory progmemtest with this file:
progmemtest.nim
And in the root directory of the repo I created this bisect script:
bisect.sh
Then I checked out the v1.4.0 branch and ran
git bisect start; git bisect good; git bisect bad v1.4.2; git bisect run ./bisect.sh
The text was updated successfully, but these errors were encountered: