mbox series

[0/2] Fix UML build with clang-18 and newer

Message ID 20240123-fix-uml-clang-18-v1-0-efc095519cf9@kernel.org (mailing list archive)
Headers show
Series Fix UML build with clang-18 and newer | expand

Message

Nathan Chancellor Jan. 23, 2024, 10:59 p.m. UTC
Hi all,

This series resolves two independent but related issues that were
recently exposed by two LLVM changes.

https://github.com/llvm/llvm-project/commit/ec92d74a0ef89b9dd46aee6ec8aca6bfd3c66a54
exposes that '-no-pie' is not getting added to the linker flags with
clang, resulting in building objects with '-fno-PIE' that are linked
with '-pie', to which the linker rightfully errors with:

  /usr/sbin/ld: init/main.o: relocation R_X86_64_32 against symbol `saved_command_line' can not be used when making a PIE object; recompile with -fPIE
  /usr/sbin/ld: failed to set dynamic section sizes: bad value

https://github.com/llvm/llvm-project/commit/4bf8a688956a759b7b6b8d94f42d25c13c7af130
adds '.ltext' (and '.ltext.*' with '-ffunction-sections') when using
'-mcmodel=large' (which UML does), which causes a segmentation fault
with modpost.

I have tested these patches with all supported versions of clang,
noticing no regressions.

---
Nathan Chancellor (2):
      um: Fix adding '-no-pie' for clang
      modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS

 arch/um/Makefile      | 4 +++-
 scripts/mod/modpost.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
---
base-commit: 0dd3ee31125508cd67f7e7172247f05b7fd1753a
change-id: 20240118-fix-uml-clang-18-e365b0503a29

Best regards,

Comments

Masahiro Yamada Jan. 27, 2024, 3:43 p.m. UTC | #1
On Wed, Jan 24, 2024 at 8:00 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi all,
>
> This series resolves two independent but related issues that were
> recently exposed by two LLVM changes.
>
> https://github.com/llvm/llvm-project/commit/ec92d74a0ef89b9dd46aee6ec8aca6bfd3c66a54
> exposes that '-no-pie' is not getting added to the linker flags with
> clang, resulting in building objects with '-fno-PIE' that are linked
> with '-pie', to which the linker rightfully errors with:
>
>   /usr/sbin/ld: init/main.o: relocation R_X86_64_32 against symbol `saved_command_line' can not be used when making a PIE object; recompile with -fPIE
>   /usr/sbin/ld: failed to set dynamic section sizes: bad value
>
> https://github.com/llvm/llvm-project/commit/4bf8a688956a759b7b6b8d94f42d25c13c7af130
> adds '.ltext' (and '.ltext.*' with '-ffunction-sections') when using
> '-mcmodel=large' (which UML does), which causes a segmentation fault
> with modpost.
>
> I have tested these patches with all supported versions of clang,
> noticing no regressions.


Both applied to linux-kbuild/fixes.

Thanks.




> ---
> Nathan Chancellor (2):
>       um: Fix adding '-no-pie' for clang
>       modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS
>
>  arch/um/Makefile      | 4 +++-
>  scripts/mod/modpost.c | 3 ++-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> ---
> base-commit: 0dd3ee31125508cd67f7e7172247f05b7fd1753a
> change-id: 20240118-fix-uml-clang-18-e365b0503a29
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>