Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 866231 - dev-lang/rust: should filter LTO for USE=-system-llvm too
Summary: dev-lang/rust: should filter LTO for USE=-system-llvm too
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Georgy Yakovlev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-08-23 23:31 UTC by immolo
Modified: 2024-03-29 04:09 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Part of build.log (build.log.xz,65.96 KB, application/x-xz)
2022-08-23 23:33 UTC, immolo
Details
emerge --info (emerge.info,7.20 KB, text/plain)
2022-08-23 23:33 UTC, immolo
Details
ebuild.diff (rust-1.62.1.ebuild.diff,394 bytes, patch)
2022-08-25 01:30 UTC, immolo
Details | Diff
Build.log (build.log.xz,127.16 KB, application/x-xz)
2022-08-25 09:36 UTC, immolo
Details
GCC 11.3.0 and 10.4.0 build.logs (Rust-build.logs.tar.xz,382.02 KB, application/x-xz)
2022-08-27 18:15 UTC, immolo
Details
GCC 11.3.0 and 10.4.0 build.logs ansiflitered (Rust-build.logs.tar.xz,216.35 KB, application/x-xz)
2022-09-03 17:01 UTC, immolo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description immolo 2022-08-23 23:31:09 UTC
While testing LTO on Gentoo without the LTO overlay I've found the filter-flag '-flto*' isn't working with Rust for some reason so package.env is still required to get it to build.
Comment 1 immolo 2022-08-23 23:33:08 UTC
Created attachment 800679 [details]
Part of build.log
Comment 2 immolo 2022-08-23 23:33:36 UTC
Created attachment 800681 [details]
emerge --info
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-23 23:34:53 UTC
You don't have USE=system-llvm, right? So that's expected.

Please include the full build.log (compressed if needed).
Comment 4 immolo 2022-08-25 00:27:19 UTC
As always you are correct :)

I've added a section to Rust Gentoo wiki page so it's easier to find this information as I can't be the only person that missed it.

  https://wiki.gentoo.org/wiki/Rust#LTO_Users
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-25 00:27:34 UTC
(In reply to immolo from comment #4)
> As always you are correct :)
> 
> I've added a section to Rust Gentoo wiki page so it's easier to find this
> information as I can't be the only person that missed it.
> 
>   https://wiki.gentoo.org/wiki/Rust#LTO_Users

Thanks!
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-25 00:27:57 UTC
Oh, wait. Are you saying it fails to build with USE=-system-llvm? In that case, we should filter-lto then too?
Comment 7 immolo 2022-08-25 00:40:00 UTC
It does fail with USE="-system-llvm" but filtering out does solve the issue.

From the discussion on IRC I thought this was intended however now I know it's not I'll run a test and fire over diff with the confirmed fix.
Comment 8 immolo 2022-08-25 01:30:51 UTC
Created attachment 800905 [details, diff]
ebuild.diff

This simple fix now allows LTO flags to be filtered on both +/-system-llvm and have I confirmed both build on my system.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-25 01:36:12 UTC
(In reply to immolo from comment #1)
> Created attachment 800679 [details]
> Part of build.log

Is the error actually in this? Can you attach the full build.log when it fails without the filter?
Comment 10 immolo 2022-08-25 09:36:22 UTC
Created attachment 800974 [details]
Build.log

Build.log with USE="-system-llvm" now included, as shown previously filtering -flto=* from the flags allows this to build.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-25 09:38:46 UTC
(In reply to immolo from comment #10)
> Created attachment 800974 [details]
> Build.log
> 
> Build.log with USE="-system-llvm" now included, as shown previously
> filtering -flto=* from the flags allows this to build.

[01m[K/var/tmp/portage/dev-lang/rust-1.62.1/work/rustc-1.62.1-src/src/llvm-project/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp:595:[m[K [01;31m[Kinternal compiler error: [m[KSegmentation fault
  595 | bool RegisterBankInfo::InstructionMapping::verify(
      | 
0xff9d7d internal_error(char const*, ...)
	???:0
0x13d76f4 operator_bitwise_not::fold_range(irange&, tree_node*, irange const&, irange const&, tree_code) const
	???:0
0x12fb352 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
	???:0
0x12fa2f4 fold_using_range::fold_stmt(irange&, gimple*, fur_source&, tree_node*)
	???:0
0x1330088 path_range_query::range_of_stmt(irange&, gimple*, tree_node*)
	???:0
0x132ef0c path_range_query::range_defined_in_block(irange&, tree_node*, basic_block_def*)
	???:0
0x132fd86 path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
	???:0
0x12faeb2 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
	???:0
0x12fa2f4 fold_using_range::fold_stmt(irange&, gimple*, fur_source&, tree_node*)
	???:0
0x1330088 path_range_query::range_of_stmt(irange&, gimple*, tree_node*)
	???:0
0x132ef0c path_range_query::range_defined_in_block(irange&, tree_node*, basic_block_def*)
	???:0
0x132fd86 path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
	???:0
0x12faeb2 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
	???:0
0x12fa2f4 fold_using_range::fold_stmt(irange&, gimple*, fur_source&, tree_node*)
	???:0
0x1330088 path_range_query::range_of_stmt(irange&, gimple*, tree_node*)
	???:0
0x132ef0c path_range_query::range_defined_in_block(irange&, tree_node*, basic_block_def*)
	???:0
0x132fd86 path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
	???:0
0x12faeb2 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
	???:0
0x12fa2f4 fold_using_range::fold_stmt(irange&, gimple*, fur_source&, tree_node*)
	???:0
0x1330088 path_range_query::range_of_stmt(irange&, gimple*, tree_node*)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
make: *** [/var/tmp/portage/dev-lang/rust-1.62.1/temp/cc6o5o1I.mk:110: /var/tmp/portage/dev-lang/rust-1.62.1/temp/ccpbak5V.ltrans36.ltrans.o] Error 1
make: *** Waiting for unfinished jobs....
[01m[Klto-wrapper:[m[K [01;31m[Kfatal error: [m[Kmake returned 2 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Is this reproducible? That's a gcc bug if so.
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-25 09:39:28 UTC
(If it is reproducible, might be https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105663).
Comment 13 immolo 2022-08-27 18:15:20 UTC
Created attachment 801538 [details]
GCC 11.3.0 and 10.4.0 build.logs

I setup an environment to test from stable and this changes the error from what was seen in GCC-12.2.0.

I built from 10.4.0 as from what I can see this is version before the bug you mentioned was introduced, all versions build fine though when LTO is filtered out.
Comment 14 immolo 2022-09-03 17:01:29 UTC
Created attachment 803068 [details]
GCC 11.3.0 and 10.4.0 build.logs ansiflitered

Reuploaded as requested.
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-03 17:53:53 UTC
(In reply to immolo from comment #14)
> Created attachment 803068 [details]
> GCC 11.3.0 and 10.4.0 build.logs ansiflitered
> 
> Reuploaded as requested.

11.3.0:
```
Did not run successfully: signal: 6
rustc exited with signal: 6
error: could not compile `core`

Caused by:
[...]
-------------
rustc: /var/tmp/portage/dev-lang/rust-1.62.1/work/rustc-1.62.1-src/src/llvm-project/llvm/include/llvm/IR/User.h:216: void llvm::User::setNumHungOffUseOperands(unsigned int): Assertion `HasHungOffUses && "Must have hung off uses to use this method"' failed.

Did not run successfully: signal: 6

```

... and same for 10.4.0. So bundled LLVM is hosed with LTO apparently?
Comment 16 immolo 2022-09-03 18:14:57 UTC
That's what I think from testing is needed, however I don't yet understand why it fails to see if this is an issue I've created or if I need to upstream somewhere.

Probably just best to leave it as is and wait for someone else to confirm the bug for now unless you have a better idea I can test.
Comment 17 Larry the Git Cow gentoo-dev 2022-09-25 17:28:57 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3d08936b268a0b83d91b2085c8588b6e3cbe88bc

commit 3d08936b268a0b83d91b2085c8588b6e3cbe88bc
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-09-25 17:24:43 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-09-25 17:25:24 +0000

    dev-lang/rust: fix alt-abi support, filter out flto in 1.64.0
    
    Bug: https://bugs.gentoo.org/866231
    Closes: https://bugs.gentoo.org/872815
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/{rust-1.64.0.ebuild => rust-1.64.0-r1.ebuild} | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Comment 18 immolo 2022-09-27 14:01:25 UTC
Now successfully build so thanks for adding.

Show this be added to all versions to stop papercuts on those running LTO on stable?
Comment 19 Georgy Yakovlev archtester gentoo-dev 2022-09-27 20:29:07 UTC
Yeah can add to other versions without revbump. But those will go away anyway and pretty soon.
Comment 20 Larry the Git Cow gentoo-dev 2022-09-27 20:32:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=97bd3a9a25b3ea3c9fdc7beb09a13a7c7b032b36

commit 97bd3a9a25b3ea3c9fdc7beb09a13a7c7b032b36
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-09-27 20:31:37 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-09-27 20:31:57 +0000

    dev-lang/rust: filter out flto in all cases
    
    Closes: https://bugs.gentoo.org/866231
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/rust-1.62.1.ebuild    | 2 +-
 dev-lang/rust/rust-1.63.0-r1.ebuild | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)