← index #7894Issue #7616
Off-topic · high · value 0.161
QUERY · ISSUE

windows/mingw strange compiler error when freezing viper code

openby andrewleechopened 2021-10-12updated 2022-09-29

I was tring to freeze some libraries into a mingw windows build today, forgetting there was viper code in some of them.
There's an odd compiler error though that took me way too long to figure out was related to the viper functions, so thought it was worth documenting here:

micropython/ports/windows$ make CROSS_COMPILE=i686-w64-mingw32- FROZEN_MANIFEST=manifest.py
...
CC build/frozen_content.c
/tmp/ccm1KbYo.s: Assembler messages:
/tmp/ccm1KbYo.s:225: Warning: Ignoring changed section attributes for .text
/tmp/ccm1KbYo.s:225: Error: junk at end of line, first unrecognized character is `,'
/tmp/ccm1KbYo.s:270: Warning: Ignoring changed section attributes for .text
/tmp/ccm1KbYo.s:270: Error: junk at end of line, first unrecognized character is `,'

building from current master (d42cba0d22c) with

$ i686-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/9.3-win32/lto-wrapper
Target: i686-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers=/usr/i686-w64-mingw32/include --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --enable-threads=win32 --program-suffix=-win32 --program-prefix=i686-w64-mingw32- --target=i686-w64-mingw32 --with-as=/usr/bin/i686-w64-mingw32-as --with-ld=/usr/bin/i686-w64-mingw32-ld --enable-libatomic --enable-libstdcxx-filesystem-ts=yes --enable-dependency-tracking
Thread model: win32
gcc version 9.3-win32 20200320 (GCC)

details:

micropython/ports/windows$ cat manifest.py
freeze("../../tests/micropython")

micropython/ports/windows$ make CROSS_COMPILE=i686-w64-mingw32- FROZEN_MANIFEST=manifest.py CFLAGS_EXTRA='-save-temps'
...
frozen_content.s:6875: Error: junk at end of line, first unrecognized character is `,'
make: *** [../../py/mkrules.mk:77: build/build/frozen_content.o] Error 1
src/micropython/ports/windows$ awk 'NR==6872,NR==6878{print NR" "$0}' frozen_content.s
6872    .word   4086
6873    .word   -28951
6874    .word   1
6875    .section        .text,"ax",@progbits # ,"dr"
6876    .align 32
6877 _fun_data_native_const_intbig__lt_module_gt__f:
6878    .ascii "USATAUH\203\354"

I gather for actual viper support on windows we'll need a finished version of https://github.com/micropython/micropython/pull/4699 but this error looks like it'll need a fix similar to https://github.com/micropython/micropython/pull/2851 based on the issues that PR closed?

CANDIDATE · ISSUE

Rpi: freezing viper code crashes system

closedby hoihuopened 2021-08-04updated 2022-05-23
port-rp2

consider:

import uctypes

ar = bytearray(12)
ADR = uctypes.addressof(ar)

@micropython.viper
def dummy_write():
    a = ptr32(ADR)
    a[1] = 1234

when issuing on REPL, it works:

>>> dummy_write()
>>> ar
bytearray(b'\x00\x00\x00\x00\xd2\x04\x00\x00\x00\x00\x00\x00')
>>>

however, when I freeze this to an mpy file and download it to the Pico, then the call to dummy_write() does nothing but freezing the REPL.

I'm using MicroPython v1.16 on 2021-07-20; Raspberry Pi Pico with RP2040. Freezing is done with -march=armv7m

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied