Skip to content

qemu-arm fails to build with optimizations disabled #6095

@bwasim

Description

@bwasim

Observation
My original intent is to use micropython on the STM3L4 series (either bare-metal or zephyr rtos), but because that's a constraint target (1M flash partitioned into 512K code + 512K FS, 96 RAM), I started out with qemu-arm (mps2-an385) to understand more about the internals of micropython.

I was able to build and run it.. It exits after printing out "hello world" on the virtual console. However, to get more into it, I decided to disable optimizations by modifying the ports/qemu-arm/makefile to add this,

# Enable debugging
DEBUG = 1

By enabling versbose mode, I was able to ensure that this flag does take effect and now the qemu-arm port builds with O0 optimizations, but linker throws the following error,

bwasim@DESKTOP-G27NF4S:/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm$ make -j32
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/genhdr/qstr.i.last
GEN build/genhdr/qstr.split
GEN build/genhdr/compressed.split
GEN build/genhdr/qstrdefs.collected.h
GEN build/genhdr/compressed.collected
QSTR not updated
Compressed data not updated
CC main.c
arm-none-eabi-ld: build/py/gc.o: in function `gc_free':
/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:588: undefined reference to `__assert_func'
arm-none-eabi-ld: /mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:590: undefined reference to `__assert_func'
arm-none-eabi-ld: build/py/gc.o: in function `gc_realloc':
/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:750: undefined reference to `__assert_func'
arm-none-eabi-ld: /mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:686: undefined reference to `__assert_func'
arm-none-eabi-ld: /mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:688: undefined reference to `__assert_func'
arm-none-eabi-ld: build/py/mpprint.o:/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/mpprint.c:208: more undefined references to `__assert_func' follow
make: *** [Makefile:140: build/firmwa

Possible Fix
Looking at the other ports, this problem is arising because of the missing "weak" definitions of __assert_func / __fatal_error in the qemu-arm main.c file.. Adding these two functions fixes the problem.

I'm not sure if this port is intended to work without optimizations or not (i would expect it to), and hence not opening a pull request directly. I'm adding a patch which fixes the problem (simple copy-paste from other ports)..

0001-qemu-arm-port-fails-with-optimizations-disabled.txt

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy