Bug 1891657

Summary: GCC -O1 -finline-functions -lto does not export a function: GCC 10.2.1-5 package regression
Product: [Fedora] Fedora Reporter: Victor Stinner <vstinner>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 32CC: aoliva, dmalcolm, fweimer, jakub, jwakely, law, mpolacek, msebor, nickc, sipoyare
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-06 09:37:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Output of gcc -E Python/compile.c none

Description Victor Stinner 2020-10-27 01:08:18 UTC
Created attachment 1724449 [details]
Output of gcc -E Python/compile.c

Description of problem:

gcc-10.2.1-5.fc32.x86_64.rpm introduced a regression in LTO build: it worked in the package version 10.2.1-1. GCC no longer exports _Py_Mangle and PyAST_CompileObject functions of Python/compile.c (source) in Python/compile.o (gcc -c).


Steps to Reproduce:

Use attached compile2.c.

$ gcc -pthread -c -DNDEBUG -fwrapv -O1 -finline-functions -finline-small-functions -fpartial-inlining -std=c99 -fvisibility=hidden -I./Include/internal -I. -I./Include -o compile2.o compile2.c -flto

$ nm compile2.o|grep _Py_Mangle

Actual results:

         U _Py_Mangle

Expected results:

00000000 T _Py_Mangle


Additional info:

Removing "-finline-functions -finline-small-functions -fpartial-inlining" (only use -O1 optimization flags) works around the issue.

The issue was first discovered on the Python project:
https://bugs.python.org/issue42164

Comment 1 Victor Stinner 2020-10-27 01:12:11 UTC
The original way to reproduce the issue is:

git clone https://github.com/python/cpython.git
cd cpython
export MAKEFLAGS=-j10
./configure --with-lto 
make

The linker fails since _Py_Mangle and PyAST_CompileObject symbols (of Python/compile.c) are missing (they are supposed to be defined by Python/compile.o).

Comment 2 Victor Stinner 2021-01-05 10:47:53 UTC
Jakub: Do you want me to report the issue to GCC upstream? I didn't check if the issue is specific to Fedora or if GCC upstream is also affected.

Comment 3 Jakub Jelinek 2021-01-05 14:28:24 UTC
Can't reproduce that.
gcc --version; gcc -pthread -c -DNDEBUG -fwrapv -O1 -finline-functions -finline-small-functions -fpartial-inlining -std=c99 -fvisibility=hidden -I./Include/internal -I. -I./Include -o compile2.o compile2.c -flto; nm compile2.o 2>&1 | grep _Py_Mangle
gcc (GCC) 10.2.1 20201005 (Red Hat 10.2.1-5)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

00000000 T _Py_Mangle

Comment 4 Victor Stinner 2021-01-06 09:37:49 UTC
I cannot reproduce the issue anymore with gcc-10.2.1-9.fc33.x86_64. Maybe it was an issue in another package, not GCC. I don't know. Anyway, I can no longer reproduce the issue on Fedora 33 x86-64.

I also closed https://bugs.python.org/issue42164.