openwrt / openwrt/packages

micropython: cannot compile with glibc because of "__P" redefined [-Werror]

Open
#23,786 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

Package: micropython
Maintainer: @jefferyto
OpenWrt Version: 23.05.3

Steps to reproduce:

git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git checkout v23.05.3
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
# Use glibc, enable micropython, exit.
make -j$(nproc) defconfig download clean world

Error Log:

[...]
In file included from ../../lib/berkeley-db-1.xx/PORT/include/db.h:40,
                 from ../../extmod/modbtree.c:35:
../../lib/berkeley-db-1.xx/PORT/include/cdefs.h:58: error: "__P" redefined [-Werror]
   58 | #define __P(protos)     protos          /* full-blown ANSI C */
      | 
In file included from /root/openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_glibc/include/features.h:491,
                 from /root/openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_glibc/include/bits/libc-header-start.h:33,
                 from /root/openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_glibc/include/stdint.h:26,
                 from /root/openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_glibc/lib/gcc/mips-openwrt-linux-gnu/12.3.0/include/stdint.h:9,
                 from ../../py/mpstate.h:29,
                 from ../../py/runtime.h:29,
                 from ../../extmod/modbtree.c:27:
/root/openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_glibc/include/sys/cdefs.h:118: note: this is the location of the previous definition
  118 | #define __P(args)       args
      | 
cc1: all warnings being treated as errors
[...]

Workaround:
Disable all warnings with "-w" (additional compiler options)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the glibc build and inspect extmod/modbtree.c together with lib/berkeley-db-1.xx/PORT/include/cdefs.h, where the conflicting __P definitions are reported. Compare the headers involved and verify the package builds with glibc without relying on the reported -w workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.