Bug 277946 - devel/pkgconf: fails build WITH_LTO=yes
Summary: devel/pkgconf: fails build WITH_LTO=yes
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-25 12:49 UTC by Benjamin Takacs
Modified: 2024-03-31 03:40 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (bapt)


Attachments
devel/pkgconf: mark LTO_UNSAFE (389 bytes, patch)
2024-03-25 12:49 UTC, Benjamin Takacs
nimaje+fbz: maintainer-approval? (bapt)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Takacs 2024-03-25 12:49:10 UTC
Created attachment 249471 [details]
devel/pkgconf: mark LTO_UNSAFE

devel/pkgconf fails to build if WITH_LTO=yes is set.

relevant part of the log:
--- libpkgconf.la ---
/bin/sh ./libtool  --tag=CC    --mode=link cc -DPERSONALITY_PATH=\"/usr/local/share/pkgconfig/personality.d:/usr/local/etc/pkgconfig/personality.d\" -DPKG_DEFAULT_PATH=\"/usr/local/libdata/pkgconfig:/usr/libdata/pkgconfig:/usr/local/share/pkgconfig\" -DSYSTEM_INCLUDEDIR=\"/usr/include\" -DSYSTEM_LIBDIR=\"/usr/lib\" -O2 -pipe  -flto=thin -fstack-protector-strong -fno-strict-aliasing  -Wall -Wextra -Wformat=2 -std=gnu99  -no-undefined -version-info 4:0:0 -export-symbols-regex '^pkgconf_' -flto=thin -fstack-protector-strong -o libpkgconf.la -rpath /usr/local/lib libpkgconf/audit.lo libpkgconf/cache.lo  libpkgconf/client.lo libpkgconf/pkg.lo libpkgconf/bsdstubs.lo  libpkgconf/fragment.lo libpkgconf/argvsplit.lo  libpkgconf/fileio.lo libpkgconf/tuple.lo  libpkgconf/dependency.lo libpkgconf/queue.lo  libpkgconf/path.lo libpkgconf/personality.lo  libpkgconf/parser.lo  
libtool: link: /usr/bin/nm  libpkgconf/.libs/audit.o libpkgconf/.libs/cache.o libpkgconf/.libs/client.o libpkgconf/.libs/pkg.o libpkgconf/.libs/bsdstubs.o libpkgconf/.libs/fragment.o libpkgconf/.libs/argvsplit.o libpkgconf/.libs/fileio.o libpkgconf/.libs/tuple.o libpkgconf/.libs/dependency.o libpkgconf/.libs/queue.o libpkgconf/.libs/path.o libpkgconf/.libs/personality.o libpkgconf/.libs/parser.o   |  | /usr/bin/sed 's/.* //' | sort | uniq > .libs/libpkgconf.exp
eval: 1: Syntax error: "|" unexpected
*** [libpkgconf.la] Error code 2

Until that is fixed it should be marked as LTO_UNSAFE
Comment 1 Tatsuki Makino 2024-03-27 09:40:40 UTC
In this case, it seems that
BINARY_ALIAS= nm=llvm-nm
can keep LTO safe.

However, the environment that caused this same problem and confirmed that this would solve it is 12.4-STABLE :)
A retest with a version that is not out of support is required.
Comment 2 Benjamin Takacs 2024-03-30 21:21:01 UTC
(In reply to Tatsuki Makino from comment #1)

For me  BINARY_ALIAS= nm=llvm-nm  makes pkgconf build, but later fail to stage with:
libtool: install: strip --strip-debug /wrkdirs/usr/ports/devel/pkgconf/work/stage/usr/local/lib/libpkgconf.a
strip: file format not recognized
in staging phase on 14.0-RELEASE
Comment 3 Tatsuki Makino 2024-03-31 03:40:49 UTC
(In reply to Benjamin Takacs from comment #2)

I had only checked it to the point where it could be built :)

During install phase, it is likely that llvm-strip will need to be used with respect to strip.
BINARY_ALIAS+= strip=llvm-strip
Perhaps ar and ranlib also need to use llvm's.


Regarding these, I refer to the information that when linking static libraries with lto enabled, the tools provided by gcc must be used in the gcc environment. (e.g. gcc-ar)
On FreeBSD, make variables for these tools are set in /usr/share/mk/sys.mk.
If an executable binary resolved by PATH is used, such as its value, the elftoolchain one will be used.
So it must be explicitly switched to the tool provided by llvm.
BINARY_ALIAS is probably the easiest way to do it.
At any rate, these are the background.

And there seems to be a problem with just switching to using llvm's tools, which bug 270421 seems to be home base for.
Perhaps a modification is needed to include these conditions in Mk/Features/lto.mk and have it automatically select whether or not to use lto.