Bug 1891657 - GCC -O1 -finline-functions -lto does not export a function: GCC 10.2.1-5 package regression
Summary: GCC -O1 -finline-functions -lto does not export a function: GCC 10.2.1-5 pack...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 32
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-10-27 01:08 UTC by Victor Stinner
Modified: 2021-01-06 09:37 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-01-06 09:37:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Output of gcc -E Python/compile.c (720.86 KB, text/plain)
2020-10-27 01:08 UTC, Victor Stinner
no flags Details

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.


Note You need to log in before you can comment on or make changes to this bug.