Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 615748

Summary: =dev-build/libtool-2.4.6-r6: libtool strips LDFLAGS/CFLAGS for "--param<space>option" style flags
Product: Gentoo Linux Reporter: Marco Ziebell <ziebell_marco>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: CONFIRMED ---    
Severity: normal CC: esigra, sam, toolchain, ziebell_marco
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 59506, 331933    
Attachments: build log of =dev-libs/libffi-3.2.1

Description Marco Ziebell 2017-04-16 10:43:50 UTC
Created attachment 470114 [details]
build log of =dev-libs/libffi-3.2.1

During the linking-phase of libffi the LDFLAGS are stripped.
e.g with CFLAGS and LDFLAGS like
CFLAGS="-march=native -mtune=native -w -pthread -pipe -fPIC -fdata-sections -ffunction-sections -g0 -O2 -flto=2 -fuse-linker-plugin -flto-partition=none -fomit-frame-pointer -ftree-vectorize -fira-loop-pressure -fno-aggressive-loop-optimizations -funswitch-loops -fgcse-sm -fgcse-las -fgcse-after-reload -fopenmp-simd -fopenmp -ftree-partial-pre -finline-functions -funroll-loops -mvzeroupper -malign-data=cacheline -maccumulate-outgoing-args -fschedule-insns -fsched-pressure -fmodulo-sched -fmodulo-sched-allow-regmoves --param prefetch-latency=600"

LDFLAGS="-Wl,-O1,--icf=all,--icf-iterations=4,--gc-sections,--as-needed,--hash-style=gnu ${CFLAGS}"

the resulting command invocation looks like this. please see the incorrect "--param".
-march=native -mtune=native -pthread -O2 -flto=2 -fuse-linker-plugin -flto-partition=none -fopenmp -mvzeroupper -malign-data=cacheline -maccumulate-outgoing-args -Wl,-O1 -Wl,--icf=all -Wl,--icf-iterations=4 -Wl,--gc-sections -Wl,--as-needed -Wl,--hash-style=gnu  -march=native -mtune=native -pthread -fPIC -fdata-sections -ffunction-sections -O2 -flto=2 -fuse-linker-plugin -flto-partition=none -fomit-frame-pointer -ftree-vectorize -fira-loop-pressure -fno-aggressive-loop-optimizations -funswitch-loops -fgcse-sm -fgcse-las -fgcse-after-reload -fopenmp-simd -fopenmp -ftree-partial-pre -finline-functions -funroll-loops -mvzeroupper -malign-data=cacheline -maccumulate-outgoing-args -fschedule-insns -fsched-pressure -fmodulo-sched --param -fmodulo-sched-allow-regmoves -fuse-ld=gold -Wl,-O1 -Wl,--icf=all -Wl,--icf-iterations=4 -Wl,--gc-sections -Wl,--as-needed -Wl,--hash-style=gnu -march=native -mtune=native -pthread -O2 -flto=2 -fuse-linker-plugin -flto-partition=none -fopenmp -mvzeroupper -malign-data=cacheline -maccumulate-outgoing-args   -pthread -fopenmp -Wl,-soname -Wl,libffi.so.6 -o .libs/libffi.so.6.0.4


The combination of CFLAGS and LDFLAGS is needed for LTO. Even though LTO is not officially supported (my last information), incorrect stripping is always bad.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-29 12:15:55 UTC
libtool performs parameter reordering to accomodate toolchain deficiencies: reorder libraries, sort CFLAGS, objects, libraries and so on.


Unfortunatly that means it has to understand multi-arguments flags like

    CFLAGS="... --param prefetch-latency=600 ..."

libtool does not understand them. The workaround is to use single-argument form:

    CFLAGS="... --param=prefetch-latency=600 ..."
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-29 12:26:43 UTC
Running 'elibtoolize' produces the same broken behaviour. Reassigning to base-system@ to triage further and maybe ask upstream to enhance option parsing.
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-29 13:59:58 UTC
Here is a libtool's flag whitelist:
    https://git.savannah.gnu.org/cgit/libtool.git/tree/build-aux/ltmain.in#n5365