public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 0/1] riscv: Support building with Clang
@ 2024-01-20  0:14 kleines Filmröllchen
  2024-01-20  0:14 ` [PATCH 1/1] " kleines Filmröllchen
  0 siblings, 1 reply; 6+ messages in thread
From: kleines Filmröllchen @ 2024-01-20  0:14 UTC (permalink / raw)
  To: u-boot
  Cc: kleines Filmröllchen, Bin Meng, Leo, Rick Chen,
	Samuel Holland, Tom Rini


Hello everyone!

This is a minimal patchset for making U-Boot build with Clang on RISC-V,
something I stumbled upon while writing U-Boot build scripts for
SerenityOS's RISC-V port. The only change is a (for unclear reasons...)
differently-named flag for fixing the global pointer.

Notably, this patch does not make U-Boot actually functional under
Clang. Booting this on QEMU (`-M virt -kernel path/to/u-boot -serial
stdio`) hangs after the image is loaded. I do not have the motivation to
debug this, but it may be helpful for further work on getting a working
build out of Clang on this architecture.

Greetings,
kleines Filmröllchen

PS: I am new to a mail patch contribution workflow and may have messed
this up despite reading through plenty relevant documentation. Please
kindly point out any improvements I could make on my side.


kleines Filmröllchen (1):
  riscv: Support building with Clang

 arch/riscv/config.mk | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
2.39.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] riscv: Support building with Clang
  2024-01-20  0:14 [PATCH 0/1] riscv: Support building with Clang kleines Filmröllchen
@ 2024-01-20  0:14 ` kleines Filmröllchen
  2024-01-20  0:20   ` Tom Rini
  0 siblings, 1 reply; 6+ messages in thread
From: kleines Filmröllchen @ 2024-01-20  0:14 UTC (permalink / raw)
  To: u-boot
  Cc: kleines Filmröllchen, Bin Meng, Leo, Rick Chen,
	Samuel Holland, Tom Rini

The -ffixed-gp option of GCC has an exact equivalent of -ffixed-x3 in
Clang.

Signed-off-by: kleines Filmröllchen <filmroellchen@serenityos.org>
---

 arch/riscv/config.mk | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 9cf2aef0a4..dc4f30d673 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -9,6 +9,9 @@
 # Copyright (C) 2017 Andes Technology Corporation
 # Rick Chen, Andes Technology Corporation <rick@andestech.com>
 #
+# Copyright (C) 2024 the SerenityOS project
+# kleines Filmröllchen <filmroellchen@serenityos.org>
+#
 
 32bit-emul		:= elf32lriscv
 64bit-emul		:= elf64lriscv
@@ -25,7 +28,12 @@ EFI_LDS			:= elf_riscv64_efi.lds
 PLATFORM_ELFFLAGS	+= -B riscv -O elf64-littleriscv
 endif
 
-PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
+PLATFORM_CPPFLAGS	+= -fpic
+ifeq ($(cc-name),clang)
+PLATFORM_CPPFLAGS   += -ffixed-x3
+else
+PLATFORM_CPPFLAGS   += -ffixed-gp
+endif
 PLATFORM_RELFLAGS	+= -fno-common -ffunction-sections -fdata-sections
 LDFLAGS_u-boot		+= --gc-sections -static -pie
 
-- 
2.39.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] riscv: Support building with Clang
  2024-01-20  0:14 ` [PATCH 1/1] " kleines Filmröllchen
@ 2024-01-20  0:20   ` Tom Rini
  2024-01-25 14:06     ` [PATCH v2 0/1] " kleines Filmröllchen
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Rini @ 2024-01-20  0:20 UTC (permalink / raw)
  To: kleines Filmröllchen
  Cc: u-boot, kleines Filmröllchen, Bin Meng, Leo, Rick Chen,
	Samuel Holland

[-- Attachment #1: Type: text/plain, Size: 1481 bytes --]

On Sat, Jan 20, 2024 at 01:14:04AM +0100, kleines Filmröllchen wrote:

> The -ffixed-gp option of GCC has an exact equivalent of -ffixed-x3 in
> Clang.
> 
> Signed-off-by: kleines Filmröllchen <filmroellchen@serenityos.org>
> ---
> 
>  arch/riscv/config.mk | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
> index 9cf2aef0a4..dc4f30d673 100644
> --- a/arch/riscv/config.mk
> +++ b/arch/riscv/config.mk
> @@ -9,6 +9,9 @@
>  # Copyright (C) 2017 Andes Technology Corporation
>  # Rick Chen, Andes Technology Corporation <rick@andestech.com>
>  #
> +# Copyright (C) 2024 the SerenityOS project
> +# kleines Filmröllchen <filmroellchen@serenityos.org>
> +#
>  
>  32bit-emul		:= elf32lriscv
>  64bit-emul		:= elf64lriscv

We don't have hard and fast rules about adding copyright lines, but this
seems a bit excessive.

> @@ -25,7 +28,12 @@ EFI_LDS			:= elf_riscv64_efi.lds
>  PLATFORM_ELFFLAGS	+= -B riscv -O elf64-littleriscv
>  endif
>  
> -PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
> +PLATFORM_CPPFLAGS	+= -fpic
> +ifeq ($(cc-name),clang)
> +PLATFORM_CPPFLAGS   += -ffixed-x3
> +else
> +PLATFORM_CPPFLAGS   += -ffixed-gp
> +endif
>  PLATFORM_RELFLAGS	+= -fno-common -ffunction-sections -fdata-sections
>  LDFLAGS_u-boot		+= --gc-sections -static -pie

A quick check shows that GCC support -ffixed-x3 as well, so we should
just use that in all cases.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 0/1] riscv: Support building with Clang
  2024-01-20  0:20   ` Tom Rini
@ 2024-01-25 14:06     ` kleines Filmröllchen
  2024-01-25 14:06       ` [PATCH v2 1/1] " kleines Filmröllchen
  0 siblings, 1 reply; 6+ messages in thread
From: kleines Filmröllchen @ 2024-01-25 14:06 UTC (permalink / raw)
  To: u-boot
  Cc: kleines Filmröllchen, Bin Meng, Leo, Rick Chen,
	Samuel Holland, Tom Rini


Hello everyone!

This is a minimal patchset for making U-Boot build with Clang on RISC-V,
something I stumbled upon while writing U-Boot build scripts for
SerenityOS's RISC-V port. The only change is a (for unclear reasons...)
differently-named flag for fixing the global pointer.

Notably, this patch does not make U-Boot actually functional under
Clang. Booting this on QEMU (`-M virt -kernel path/to/u-boot -serial
stdio`) hangs after the image is loaded. I do not have the motivation to
debug this, but it may be helpful for further work on getting a working
build out of Clang on this architecture.

Greetings,
kleines Filmröllchen

Changes in v2:
- Removed copyright attribution
- Use -ffixed-x3 unconditionally as it is also supported by GCC

kleines Filmröllchen (1):
  riscv: Support building with Clang

 arch/riscv/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/1] riscv: Support building with Clang
  2024-01-25 14:06     ` [PATCH v2 0/1] " kleines Filmröllchen
@ 2024-01-25 14:06       ` kleines Filmröllchen
  2024-01-25 14:16         ` Tom Rini
  0 siblings, 1 reply; 6+ messages in thread
From: kleines Filmröllchen @ 2024-01-25 14:06 UTC (permalink / raw)
  To: u-boot
  Cc: kleines Filmröllchen, Bin Meng, Leo, Rick Chen,
	Samuel Holland, Tom Rini

The -ffixed-gp option of GCC has an exact equivalent of -ffixed-x3 in
Clang.

Signed-off-by: kleines Filmröllchen <filmroellchen@serenityos.org>
---

Changes in v2:
- Removed copyright attribution
- Use -ffixed-x3 unconditionally as it is also supported by GCC

 arch/riscv/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 9cf2aef0a4..9f16dda92a 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -25,7 +25,7 @@ EFI_LDS			:= elf_riscv64_efi.lds
 PLATFORM_ELFFLAGS	+= -B riscv -O elf64-littleriscv
 endif
 
-PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
+PLATFORM_CPPFLAGS	+= -ffixed-x3 -fpic
 PLATFORM_RELFLAGS	+= -fno-common -ffunction-sections -fdata-sections
 LDFLAGS_u-boot		+= --gc-sections -static -pie
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] riscv: Support building with Clang
  2024-01-25 14:06       ` [PATCH v2 1/1] " kleines Filmröllchen
@ 2024-01-25 14:16         ` Tom Rini
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2024-01-25 14:16 UTC (permalink / raw)
  To: kleines Filmröllchen
  Cc: u-boot, kleines Filmröllchen, Bin Meng, Leo, Rick Chen,
	Samuel Holland

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

On Thu, Jan 25, 2024 at 03:06:59PM +0100, kleines Filmröllchen wrote:

> The -ffixed-gp option of GCC has an exact equivalent of -ffixed-x3 in
> Clang.
> 
> Signed-off-by: kleines Filmröllchen <filmroellchen@serenityos.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-25 14:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-20  0:14 [PATCH 0/1] riscv: Support building with Clang kleines Filmröllchen
2024-01-20  0:14 ` [PATCH 1/1] " kleines Filmröllchen
2024-01-20  0:20   ` Tom Rini
2024-01-25 14:06     ` [PATCH v2 0/1] " kleines Filmröllchen
2024-01-25 14:06       ` [PATCH v2 1/1] " kleines Filmröllchen
2024-01-25 14:16         ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox