Debug why GCC fails to build on K3 #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@davidlt says GCC hasn't built successfully on K3 for months. We need to solve this for Fedora ELN bootstrap (#32).
Here's a failed build on K3: https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=251308
From the build.log:
Investigate why GCC fails to build on K3to Debug why GCC fails to build on K3David points to an upstream thread about it:
https://lore.kernel.org/linux-riscv/apSYF5x1Tu7PlyL1@aurel32.net/
A couple of things:
We've ruled out this is not RVA23-specific issue. It could be specific to K3, we don't know yet.
There seems to be a gigantic gap between a Debian RISC-V GCC build and a Fedora RISC-V GCC build:
So it is very puzzling to see this huge difference, even if Debian is running some kind of trimmed build. We need to investigate this further.
The Debian RISC-V build does not run the test suite:
salsa.debian.org/toolchain-team/gcc/-@2a1da4d2b4/debian/rules.defs (L1822)Let's look at some recent numbers.
Fedora GCC build times
Debian GCC build times
So in Debian the riscv64 build "only" takes ~5x as long as the x86_64 build, using extremely outdated hardware. Whereas in Fedora, despite using some of the fastest riscv64 hardware that exists today, the build takes ~15x as the x86_64 one.
Why is GCC such a worst case scenario for Fedora? With other packages, the difference is still significant but the gap is not quite as severe. To me, that's the interesting question. Comparing build times between Fedora and Debian is not particularly useful, because as noted above they are doing wildly different things; but comparing the gap between different Fedora architectures to that between different Debian architectures could help us figure out how we can speed up our builds.
That said, this ticket is about the failure to build GCC on K3. Performance considerations should be tracked separately.
Sure. For completeness' sake, noting a correction to my message above after our chat elsewhere.
@kashyapc wrote in #36 (comment):
So
gcc-defaultsis the wrong Debian package, as you point out, I should look forgcc-16. So I looked and the build time for Debiangcc-16looks more reasonable: 2 days and 11 hours (~59h) on SiFive "Unmatched".Still, it is faster than Titan. This additional time could be explained by other factors: Fedora GCC build more languages, and "stack protector is enabled by default, double the testing (with and without stack protector)", as per a RHEL GCC tech lead, Siddhesh. @davidlt on Matrix noted that we could build it faster too by removing "bootstrap,
lto,pgo, and reducing the number of languages. We could try it for ELN, but that's a totally separate topic.So that explains the "puzzle" of the huge gap.
And I agree, the relative diff b/n arches in Fedora and Debian is the interesting bit! (We can track it separately, and leave this to GCC on K3.)
It was suggested disabling transparent_hugepages on the K3 might allow GCC to build. If so maybe it will gives a direction to investigate in, so I triggered a scratch build on one of my K3's to see if it will finish: https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=387659
Re: build time I also made a package that tries to mimic debian builds options to see what the build time looks like for same, or at least similar, options: https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=387658
Building with options close to Debian takes about 8.5 hours on a Milk-V Titan. To be clear I am not suggesting Fedora should change anything, rather just wanted a more equal comparison, and to demonstrate what David was sharing about removing things like bootstrap, lto, pgo, etc.
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=387648
The gcc build on the host with transparent_hugepages set to never is probably ~10-12 hours from finishing up
Jennifer Berringer had success building GCC with CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD=-1 set in the kernel. There are some links below with more information. I kicked off another scratch build with THP enabled again on a kernel with CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD=-1 set
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=389195
https://lore.kernel.org/linux-riscv/aqGNGp8PInSV4vty@aurel32.net/
https://patchew.org/linux/20240507-compile._5Fkernel._5Fwith._5Fextensions-v2-0-722c21c328c6@rivosinc.com/20240507-compile._5Fkernel._5Fwith._5Fextensions-v2-2-722c21c328c6@rivosinc.com/
I'm curious to see what your results are going to be, because unfortunately I've already had two failed attempts of my own with that workaround.
Granted, I was running a RHEL kernel/userspace and building the RHEL GCC package; still, that doesn't fill me with confidence that the
CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD=-1workaround is going to work. I will also note that the Bianbu kernel, which I've been able to use (with RHEL userspace) to successfully build a RHEL GCC on K3, doesn't set that config option.It sounds like it was decided that CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD=-1 doesn't work and that success was maybe seen with an older version of gcc, so I canceled the scratch build.
The disabled THP build is still going, but I had forgotten we were carrying v1 of a patch to potentially resolve the problem, so if the build succeeds it unfortunately doesn't really tell us which might have allowed it to build successfully.
I removed CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD=-1 from the config, updated the patch to v2 (https://lore.kernel.org/linux-riscv/20261020-vector_fpu_regs_status_rmw_fix-v2-1-474a59155e96@intel.com/), left THP enabled, and kicked off another scratch build. https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=389493
Using a kernel with the v2 patch mentioned above included, I was able to successfully build the RHEL GCC package on a K3 board running RHEL. So that looks very promising! I see that the Fedora GCC build that Jason kicked off is still going too, which is another encouraging sign.
My scratch build failed with:
Using
Which contains
gitlab.com/jmontleon/kernel-ark/-@50c8abae88