WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Adjustment to python packages  (Read 169 times)

Offline polikuo

  • Hero Member
  • *****
  • Posts: 758
Adjustment to python packages
« on: December 11, 2024, 02:54:36 AM »
Hi, all.

It bugs me whenever the compile flag -O3 pop-up out of no where.
It turns out python is responsible. (main package)

Code: [Select]
$ py1=/usr/local/lib/python3.11/config-3.11-arm-linux-gnueabihf/Makefile
$ py2=/usr/local/lib/python3.11/_sysconfigdata__linux_arm-linux-gnueabihf.py
$ grep O3 $py1
OPT=            -DNDEBUG -g -fwrapv -O3 -Wall
$ grep O3 $py2
 'CFLAGS': '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -pipe '
 'LIBEXPAT_CFLAGS': '-I./Modules/expat -Wsign-compare -DNDEBUG -g -fwrapv -O3 '
                    '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -pipe '
 'OPT': '-DNDEBUG -g -fwrapv -O3 -Wall',
 'PY_BUILTIN_MODULE_CFLAGS': '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os '
 'PY_CFLAGS': '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -pipe '
 'PY_CORE_CFLAGS': '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -pipe '
 'PY_STDMODULE_CFLAGS': '-Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os '

The easy fix is sed one-liner
Code: [Select]
sed -i 's/-g -fwrapv -O3/-fwrapv/g' squashfs-root/$py1 squashfs-root/$py2
Could someone spares a couple of minutes to address that on all port ?
Many thanks  :)
« Last Edit: December 11, 2024, 02:56:52 AM by polikuo »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14847
Re: Adjustment to python packages
« Reply #1 on: December 14, 2024, 06:18:51 AM »
The correct piCore flags should be inserted, no?

Building python like this http://tinycorelinux.net/14.x/x86/tcz/src/python3.9/compile_python3.9 seems to build python with the correct ones already present.

Offline polikuo

  • Hero Member
  • *****
  • Posts: 758
Re: Adjustment to python packages
« Reply #2 on: December 14, 2024, 07:25:59 AM »
Hi, Juanito.

It's a different matter.

It appears that I didn't explain quite clearly in my previous post, let me try again.

They are hard-coded configuration which won't be touched unless you edit it manually.


What we're having here:

1. Download python source code (data files contain -O3)

2. configure, make --> /usr/local/bin/python built with -Os

3. make install --> ( config-3.11-arm-linux-gnueabihf/Makefile, _sysconfigdata__linux_arm-linux-gnueabihf.py ) got installed

4. Whenever you compile a new package (python setup.py, pip install, ...etc)
  python would first append (-Os) from environment variables, then override it with (-O3) from the hard-coded data files mentioned above.


P.S.
Node.js does this as well.
You can checkout what I've done here
http://tinycorelinux.net/13.x/armv7/tcz/src/node/
Specifically, the Favor4Size.patch
« Last Edit: December 14, 2024, 07:30:30 AM by polikuo »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14847
Re: Adjustment to python packages
« Reply #3 on: December 14, 2024, 08:15:32 AM »
That was the point I was making, see, for example:

/usr/local/lib/python3.9/config-3.9-x86_64-linux-gnu/Makefile
/usr/local/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py

Offline polikuo

  • Hero Member
  • *****
  • Posts: 758
Re: Adjustment to python packages
« Reply #4 on: December 14, 2024, 09:43:44 AM »
I see, things may vary with different platform, version ... etc.

This is what we have with armhf

Code: [Select]
tc@pi4-1:~$ (. /etc/init.d/tc-functions; getBuild)
armhf
tc@pi4-1:~$ tce-load -i python3.11
python3.11 is already installed!
tc@pi4-1:~$ grep "'OPT'" /tmp/tcloop/python3.11/usr/local/lib/python3.11/_sysconfigdata__linux_arm-linux-gnueabihf.py
 'OPT': '-DNDEBUG -g -fwrapv -O3 -Wall',
tc@pi4-1:~$ grep '^OPT=' /tmp/tcloop/python3.11/usr/local/lib/python3.11/config-3.11-arm-linux-gnueabihf/Makefile
OPT=            -DNDEBUG -g -fwrapv -O3 -Wall

When I was building distcc.tcz, [-O3] kept popping up.
I had to "sed" those files to set things right.