#141 Pass -Og to EXTRA_CFLAGS as well as to CFLAGS_NODIST
Merged 4 years ago by churchyard. Opened 4 years ago by churchyard.
rpms/ churchyard/python3 EXTRA_CFLAGS  into  master

file modified
+4 -3
@@ -683,14 +683,15 @@ 

    $ExtraConfigArgs \

    %{nil}

  

+ %global flags_override EXTRA_CFLAGS="$MoreCFlags" CFLAGS_NODIST="$CFLAGS_NODIST $MoreCFlags"

+ 

  %if %{without bootstrap}

    # Regenerate generated files (needs python3)

-   %make_build regen-all PYTHON_FOR_REGEN="python%{pybasever}"

+   %make_build %{flags_override} regen-all PYTHON_FOR_REGEN="python%{pybasever}"

  %endif

  

- 

    # Invoke the build

-   %make_build CFLAGS_NODIST="$CFLAGS_NODIST $MoreCFlags"

+   %make_build %{flags_override}

  

    popd

    echo FINISHED: BUILD OF PYTHON FOR CONFIGURATION: $ConfName

file modified
+3
@@ -11,6 +11,9 @@ 

      - smoke:

          dir: python/smoke

          run: VERSION=3.8 ./venv.sh

+     - debugsmoke:

+         dir: python/smoke

+         run: PYTHON=python3-debug TOX=false VERSION=3.8 ./venv.sh

      - selftest:

          dir: python/selftest

          run: VERSION=3.8 X="-x test_wsgiref" ./parallel.sh

  • to CFLAGS_NODIST to take precedence as CFLAGS_NODIST go after EXTRA_CFLAGS
  • to EXTRA_CFLAGS to "bake it in" and build extension modules with -Og

cc @cstratak

rebased onto 5c29f6e087d6fb6b40ecac808772641c853f5302

4 years ago

2 new commits added

  • Fedora CI: Run the smoke test on the debug build as well
  • Pass -Og to EXTRA_CFLAGS as well as to CFLAGS_NODIST
4 years ago

The CI job says:

gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -Og -fPIC -I/var/str/python/smoke/venv/include -I/usr/include/python3.8d -c module.c -o build/temp.linux-x86_64-3.8-pydebug/module.o

For building an extension module with python3-debug.

The python3's build log says:

gcc -pthread -c -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches   -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches   -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv   -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches   -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv  -Og -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -Og -I/builddir/build/BUILD/Python-3.8.0rc1/Include/internal -IObjects -IInclude -IPython -I. -I/builddir/build/BUILD/Python-3.8.0rc1/Include   -fPIC -DPy_BUILD_CORE -o Programs/python.o /builddir/build/BUILD/Python-3.8.0rc1/Programs/python.c

This seems to work. I've pushed the commit to all my 3.8.0 final PRs, but I will not merge it without somebody else reviewing it. It't easy to get lost in this.

The change doesn't work. It seems like Python (_warnings.c) is still built using -O2 for the debug build.

I looked at build.log at Koji for flags when building _asyncio C extension and _warnings.c.

https://koji.fedoraproject.org/koji/taskinfo?taskID=38296166

x86-64:

  • debug: _warnings built with -O2 (WRONG!), _asyncio built with -Og (good)
  • optimized: _warnings built with -O2 (good), _asyncio built with -O2 (good)

ppc64le logs:

  • debug: _warnings built with -O2 (WRONG!), _asyncio built with -Og (good)
  • optimized: _warnings built with -O2 (good), _asyncio built with -O2 (good)

s390x logs:

  • debug: _warnings built with -O2 (WRONG!), _asyncio built with -Og (good)
  • optimized: _warnings built with -O2 (good), _asyncio built with -O2 (good)

Note: optimized build can be recognized with "-fprofile-use" flag, debug build can be recognized by the lack of "-DNDEBUG" flag.

1 new commit added

  • Try putting $MoreCFlags everywhere
4 years ago

3 new commits added

  • Try putting $MoreCFlags everywhere, replacing -O2
  • Fedora CI: Run the smoke test on the debug build as well
  • Pass -Og to EXTRA_CFLAGS as well as to CFLAGS_NODIST
4 years ago

3 new commits added

  • Pass flags owerrides to regen-all as well
  • Fedora CI: Run the smoke test on the debug build as well
  • Pass -Og to EXTRA_CFLAGS as well as to CFLAGS_NODIST
4 years ago

@vstinner So, I have figured that the _warnings module is built during regen-all and we don't pass the flags to regen-all. I've pushed a commit that does that and hopefully that should be it.

3 new commits added

  • Pass flags override to regen-all as well
  • Fedora CI: Run the smoke test on the debug build as well
  • Pass -Og to EXTRA_CFLAGS as well as to CFLAGS_NODIST
4 years ago

rebased onto 796e80b

4 years ago

Building an extension module with python3-debug:

gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -Og -fPIC -I/var/str/python/smoke/venv/include -I/usr/include/python3.8d -c module.c -o build/temp.linux-x86_64-3.8-pydebug/module.o
grep -E '_asynciomodule.c|_warnings.c' build.log
gcc -c -O2 -g -O2 -g -O2 -g -Og -O2 -g -flto -g -O2 -g -Og -o Python/_warnings.o .../Python/_warnings.c
gcc -O2 -g -O2 -g -O2 -g -Og -O2 -g -flto -g -O2 -g -Og -c .../Modules/_asynciomodule.c -o ...pydebug.../Modules/_asynciomodule.o
gcc -c -DNDEBUG -O2 -g -O2 -g -O2 -g -O2 -g -flto -g -O2 -g -o Python/_warnings.o .../Python/_warnings.c
gcc -c -DNDEBUG -O2 -g -O2 -g -O2 -g -O2 -g -flto -g -O2 -g -fprofile-generate -o Python/_warnings.o .../Python/_warnings.c
gcc -DNDEBUG -O2 -g -O2 -g -O2 -g -O2 -g -flto -g -O2 -g -fprofile-generate -I/usr/local/include -I.../build/optimized -c .../Modules/_asynciomodule.c -o .../Modules/_asynciomodule.o
gcc -c -DNDEBUG -O2 -g -O2 -g -O2 -g -O2 -g -flto -g -O2 -g -fprofile-use -fprofile-correction -o Python/_warnings.o .../Python/_warnings.c
gcc -DNDEBUG -O2 -g -O2 -g -O2 -g -O2 -g -flto -g -O2 -g -fprofile-use -fprofile-correction -I/usr/local/include -I.../build/optimized -c .../Modules/_asynciomodule.c -o .../Modules/_asynciomodule.o

Extra flags removed.

Note: I will try to change the build to replace -O2 flags instead of appending -Og, but not in this PR. Ready to review again.

LGTM.

http://koji.fedoraproject.org/koji/taskinfo?taskID=38311080 build:

I confirm that -Og is now used to build the debug Python, and -O2 is used to build the optimized Python. As expected.

I looked at x86-64, ppc64 and s390x architectures.

Pull-Request has been merged by churchyard

4 years ago