* [PATCH] riscv: Only allow LTO with CMODEL_MEDANY
@ 2025-07-10 20:25 Nathan Chancellor
2025-08-08 21:53 ` Nathan Chancellor
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2025-07-10 20:25 UTC (permalink / raw)
To: Palmer Dabbelt, Alexandre Ghiti
Cc: Conor Dooley, linux-riscv, llvm, linux-kernel, stable,
kernel test robot, Nathan Chancellor
When building with CONFIG_CMODEL_MEDLOW and CONFIG_LTO_CLANG, there is a
series of errors due to some files being unconditionally compiled with
'-mcmodel=medany', mismatching with the rest of the kernel built with
'-mcmodel=medlow':
ld.lld: error: Function Import: link error: linking module flags 'Code Model': IDs have conflicting values: 'i32 3' from vmlinux.a(init.o at 899908), and 'i32 1' from vmlinux.a(net-traces.o at 1014628)
Only allow LTO to be performed when CONFIG_CMODEL_MEDANY is enabled to
ensure there will be no code model mismatch errors. An alternative
solution would be disabling LTO for the files with a different code
model than the main kernel like some specialized areas of the kernel do
but doing that for individual files is not as sustainable than
forbidding the combination altogether.
Cc: stable@vger.kernel.org
Fixes: 021d23428bdb ("RISC-V: build: Allow LTO to be selected")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506290255.KBVM83vZ-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
arch/riscv/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 36061f4732b7..4eee737a050f 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -68,7 +68,7 @@ config RISCV
select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
select ARCH_SUPPORTS_HUGETLBFS if MMU
# LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
- select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
+ select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000 && CMODEL_MEDANY
select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
---
base-commit: fda589c286040d9ba2d72a0eaf0a13945fc48026
change-id: 20250710-riscv-restrict-lto-to-medany-f1b7dd5c9bba
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Only allow LTO with CMODEL_MEDANY
2025-07-10 20:25 [PATCH] riscv: Only allow LTO with CMODEL_MEDANY Nathan Chancellor
@ 2025-08-08 21:53 ` Nathan Chancellor
2025-08-09 10:45 ` Alexandre Ghiti
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2025-08-08 21:53 UTC (permalink / raw)
To: Palmer Dabbelt, Alexandre Ghiti
Cc: Conor Dooley, linux-riscv, llvm, linux-kernel, stable,
kernel test robot
Ping? This is still getting hit.
On Thu, Jul 10, 2025 at 01:25:26PM -0700, Nathan Chancellor wrote:
> When building with CONFIG_CMODEL_MEDLOW and CONFIG_LTO_CLANG, there is a
> series of errors due to some files being unconditionally compiled with
> '-mcmodel=medany', mismatching with the rest of the kernel built with
> '-mcmodel=medlow':
>
> ld.lld: error: Function Import: link error: linking module flags 'Code Model': IDs have conflicting values: 'i32 3' from vmlinux.a(init.o at 899908), and 'i32 1' from vmlinux.a(net-traces.o at 1014628)
>
> Only allow LTO to be performed when CONFIG_CMODEL_MEDANY is enabled to
> ensure there will be no code model mismatch errors. An alternative
> solution would be disabling LTO for the files with a different code
> model than the main kernel like some specialized areas of the kernel do
> but doing that for individual files is not as sustainable than
> forbidding the combination altogether.
>
> Cc: stable@vger.kernel.org
> Fixes: 021d23428bdb ("RISC-V: build: Allow LTO to be selected")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202506290255.KBVM83vZ-lkp@intel.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> arch/riscv/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 36061f4732b7..4eee737a050f 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -68,7 +68,7 @@ config RISCV
> select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
> select ARCH_SUPPORTS_HUGETLBFS if MMU
> # LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
> - select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
> + select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000 && CMODEL_MEDANY
> select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
> select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
> select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
>
> ---
> base-commit: fda589c286040d9ba2d72a0eaf0a13945fc48026
> change-id: 20250710-riscv-restrict-lto-to-medany-f1b7dd5c9bba
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Only allow LTO with CMODEL_MEDANY
2025-08-08 21:53 ` Nathan Chancellor
@ 2025-08-09 10:45 ` Alexandre Ghiti
2025-08-10 0:24 ` Nathan Chancellor
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Ghiti @ 2025-08-09 10:45 UTC (permalink / raw)
To: Nathan Chancellor, Palmer Dabbelt
Cc: Conor Dooley, linux-riscv, llvm, linux-kernel, stable,
kernel test robot
Hi Nathan,
On 8/8/25 23:53, Nathan Chancellor wrote:
> Ping? This is still getting hit.
This is the second time your patches do not reach the linux-riscv
mailing list [1] [2], not even my personal mailbox.
[1]
https://lore.kernel.org/linux-riscv/?q=riscv%3A+Only+allow+LTO+with+CMODEL_MEDANY
[2]
https://lore.kernel.org/linux-riscv/?q=riscv%3A+uaccess%3A+Fix+-Wuninitialized+and+-Wshadow+in+__put_user_nocheck
I don't know what's going on, do you have any idea?
I'll pick this up in my fixes branch.
Thanks,
Alex
>
> On Thu, Jul 10, 2025 at 01:25:26PM -0700, Nathan Chancellor wrote:
>> When building with CONFIG_CMODEL_MEDLOW and CONFIG_LTO_CLANG, there is a
>> series of errors due to some files being unconditionally compiled with
>> '-mcmodel=medany', mismatching with the rest of the kernel built with
>> '-mcmodel=medlow':
>>
>> ld.lld: error: Function Import: link error: linking module flags 'Code Model': IDs have conflicting values: 'i32 3' from vmlinux.a(init.o at 899908), and 'i32 1' from vmlinux.a(net-traces.o at 1014628)
>>
>> Only allow LTO to be performed when CONFIG_CMODEL_MEDANY is enabled to
>> ensure there will be no code model mismatch errors. An alternative
>> solution would be disabling LTO for the files with a different code
>> model than the main kernel like some specialized areas of the kernel do
>> but doing that for individual files is not as sustainable than
>> forbidding the combination altogether.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 021d23428bdb ("RISC-V: build: Allow LTO to be selected")
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202506290255.KBVM83vZ-lkp@intel.com/
>> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>> ---
>> arch/riscv/Kconfig | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 36061f4732b7..4eee737a050f 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -68,7 +68,7 @@ config RISCV
>> select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
>> select ARCH_SUPPORTS_HUGETLBFS if MMU
>> # LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
>> - select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
>> + select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000 && CMODEL_MEDANY
>> select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
>> select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
>> select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
>>
>> ---
>> base-commit: fda589c286040d9ba2d72a0eaf0a13945fc48026
>> change-id: 20250710-riscv-restrict-lto-to-medany-f1b7dd5c9bba
>>
>> Best regards,
>> --
>> Nathan Chancellor <nathan@kernel.org>
>>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Only allow LTO with CMODEL_MEDANY
2025-08-09 10:45 ` Alexandre Ghiti
@ 2025-08-10 0:24 ` Nathan Chancellor
0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2025-08-10 0:24 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: Palmer Dabbelt, Conor Dooley, linux-riscv, llvm, linux-kernel,
stable, kernel test robot
On Sat, Aug 09, 2025 at 12:45:59PM +0200, Alexandre Ghiti wrote:
> Hi Nathan,
>
> On 8/8/25 23:53, Nathan Chancellor wrote:
> > Ping? This is still getting hit.
>
>
> This is the second time your patches do not reach the linux-riscv mailing
> list [1] [2], not even my personal mailbox.
>
> [1] https://lore.kernel.org/linux-riscv/?q=riscv%3A+Only+allow+LTO+with+CMODEL_MEDANY
>
> [2] https://lore.kernel.org/linux-riscv/?q=riscv%3A+uaccess%3A+Fix+-Wuninitialized+and+-Wshadow+in+__put_user_nocheck
>
> I don't know what's going on, do you have any idea?
Huh, not sure :/ I only use my kernel.org address and nothing about my
configuration or usage has changed plus it seems to have made it to
every other mailing list I sent it to?
https://lore.kernel.org/lkml/20250710-riscv-restrict-lto-to-medany-v1-1-b1dac9871ecf@kernel.org/
https://lore.kernel.org/llvm/20250710-riscv-restrict-lto-to-medany-v1-1-b1dac9871ecf@kernel.org/
https://lore.kernel.org/stable/20250710-riscv-restrict-lto-to-medany-v1-1-b1dac9871ecf@kernel.org/
Next time I have to send a RISC-V patch, I'll look at the archives to
see if it made it there and follow up if not.
> I'll pick this up in my fixes branch.
Great, thanks a lot!
Cheers,
Nathan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-10 0:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 20:25 [PATCH] riscv: Only allow LTO with CMODEL_MEDANY Nathan Chancellor
2025-08-08 21:53 ` Nathan Chancellor
2025-08-09 10:45 ` Alexandre Ghiti
2025-08-10 0:24 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).