Bug 253716 - LTO seems to be broken in 13-BETA3
Summary: LTO seems to be broken in 13-BETA3
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-STABLE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-toolchain (Nobody)
Depends on:
Reported: 2021-02-20 10:10 UTC by dmilith
Modified: 2021-02-22 14:21 UTC (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description dmilith 2021-02-20 10:10:51 UTC
My software build system's been using LTO for builds for years now.
I append "-flto=thin -ffat-lto-objects -fuse-linker-plugin -Wl,--thinlto-jobs=8" to CFLAGS/CXXFLAGS and it worked nicely until 13-BETA1 (last tested one).

Yesterday I updated to 13-BETA3, and same options now cause linker issues.

Example for Make 4.3:


(it also breaks with fat LTO enabled, not only with Thin)

It builds fine if I just remove "-flto" option.
Comment 1 Kyle Evans freebsd_committer 2021-02-22 13:50:38 UTC
I took a little bit of a look at this, and noted that lib/findprog-in.o -> lib/libgnu.a which does appear on the cut off part of the linker command that fails in the picture. AFAICT find_in_given_path does make the trip into libgnu.a, annotated like so:

define dso_local i8* @find_in_given_path(i8* %0, i8* %1, i1 zeroext %2) local_unnamed_addr #0 {
^4 = gv: (name: "find_in_given_path", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 119, calls: ((callee: ^9), (callee: ^5), (callee: ^8), (callee: ^3), (callee: ^13), (callee: ^11), (callee: ^2), (callee: ^6), (callee: ^10)), refs: (^14, ^15)))) ; guid = 1239841682990232801
Comment 2 Dimitry Andric freebsd_committer 2021-02-22 14:19:22 UTC
Can you come up with an actual test case? Saying "it doesn't work for my application which I'm not giving any details about except a screenshot" is not very helpful...
Comment 3 Kyle Evans freebsd_committer 2021-02-22 14:21:57 UTC
(In reply to Dimitry Andric from comment #2)

This reproduces easily enough with devel/gmake (the port representation of what they're trying to build) and the listed CFLAGS/CXXFLAGS pushed into the port's Makefile