rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Rust enablement for AArch64
@ 2023-01-25 16:37 Jamie Cunliffe
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Jamie Cunliffe @ 2023-01-25 16:37 UTC (permalink / raw)
  To: linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

The first patch is from Miguel's tree to enable Rust support for
AArch64. This has been tested with the Rust samples, and the generated
code has also been manually inspected.

The second patch enables the PAC ret and BTI options in the Rust build
flags to match the options that are used when building C.

The third patch disables the neon and fp target features to avoid fp &
simd registers. The use of fp-armv8 will cause a warning from rustc
about an unknown feature that is specified. The target feature is
still passed through to LLVM, this behaviour is documented as part of
the warning. This will be fixed in a future version of the rustc
toolchain. This pull request should address it,
https://github.com/rust-lang/rust/pull/107294


Jamie Cunliffe (2):
  arm64: rust: Enable PAC support for Rust.
  arm64: rust: Disable neon and fp target features.

Miguel Ojeda (1):
  arm64: rust: Enable Rust support for AArch64

 Documentation/rust/arch-support.rst |  1 +
 arch/arm64/Kconfig                  |  1 +
 arch/arm64/Makefile                 |  4 ++++
 scripts/generate_rust_target.rs     | 13 ++++++++++++-
 4 files changed, 18 insertions(+), 1 deletion(-)

-- 
2.30.2


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

* [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-25 16:37 [PATCH 0/3] Rust enablement for AArch64 Jamie Cunliffe
@ 2023-01-25 16:37 ` Jamie Cunliffe
  2023-01-25 19:50   ` Vincenzo Palazzo
                     ` (4 more replies)
  2023-01-25 16:37 ` [PATCH 2/3] arm64: rust: Enable PAC support for Rust Jamie Cunliffe
                   ` (3 subsequent siblings)
  4 siblings, 5 replies; 21+ messages in thread
From: Jamie Cunliffe @ 2023-01-25 16:37 UTC (permalink / raw)
  To: linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

From: Miguel Ojeda <ojeda@kernel.org>

This commit provides the build flags for Rust for AArch64. The core Rust
support already in the kernel does the rest.

The Rust samples have been tested with this commit.

[jcunliffe: Arm specific parts taken from Miguel's upstream tree]

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Co-developed-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
---
 Documentation/rust/arch-support.rst |  1 +
 arch/arm64/Kconfig                  |  1 +
 scripts/generate_rust_target.rs     | 13 ++++++++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst
index 6982b63775da..3776059a385a 100644
--- a/Documentation/rust/arch-support.rst
+++ b/Documentation/rust/arch-support.rst
@@ -15,5 +15,6 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
 ============  ================  ==============================================
 Architecture  Level of support  Constraints
 ============  ================  ==============================================
+``arm64``     Maintained        None.
 ``x86``       Maintained        ``x86_64`` only.
 ============  ================  ==============================================
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 03934808b2ed..fc3800e82802 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -209,6 +209,7 @@ config ARM64
 	select HAVE_FUNCTION_ARG_ACCESS_API
 	select MMU_GATHER_RCU_TABLE_FREE
 	select HAVE_RSEQ
+	select HAVE_RUST
 	select HAVE_STACKPROTECTOR
 	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_KPROBES
diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
index 3c6cbe2b278d..fe0e4ba54492 100644
--- a/scripts/generate_rust_target.rs
+++ b/scripts/generate_rust_target.rs
@@ -148,7 +148,18 @@ fn main() {
     let mut ts = TargetSpec::new();
 
     // `llvm-target`s are taken from `scripts/Makefile.clang`.
-    if cfg.has("X86_64") {
+    if cfg.has("ARM64") {
+        ts.push("arch", "aarch64");
+        ts.push(
+            "data-layout",
+            "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
+        );
+        ts.push("disable-redzone", true);
+        ts.push("features", "+strict-align,+neon,+fp-armv8");
+        ts.push("llvm-target", "aarch64-linux-gnu");
+        ts.push("max-atomic-width", 128);
+        ts.push("target-pointer-width", "64");
+    } else if cfg.has("X86_64") {
         ts.push("arch", "x86_64");
         ts.push(
             "data-layout",
-- 
2.30.2


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

* [PATCH 2/3] arm64: rust: Enable PAC support for Rust.
  2023-01-25 16:37 [PATCH 0/3] Rust enablement for AArch64 Jamie Cunliffe
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
@ 2023-01-25 16:37 ` Jamie Cunliffe
  2023-01-25 19:54   ` Vincenzo Palazzo
  2023-01-25 16:37 ` [PATCH 3/3] arm64: rust: Disable neon and fp target features Jamie Cunliffe
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 21+ messages in thread
From: Jamie Cunliffe @ 2023-01-25 16:37 UTC (permalink / raw)
  To: linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

Enable the PAC ret and BTI options in the Rust build flags to match
the options that are used when building C.

Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
---
 arch/arm64/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index d62bd221828f..b53ab6aa2dfe 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -85,8 +85,10 @@ PACRET-$(CONFIG_UNWIND_PATCH_PAC_INTO_SCS) := pac-ret
 
 ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
 branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protection=$(PACRET-y)+bti
+KBUILD_RUSTFLAGS += -Z branch-protection=bti,pac-ret,leaf
 else
 branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=$(PACRET-y)
+KBUILD_RUSTFLAGS += -Z branch-protection=pac-ret,leaf
 endif
 # -march=armv8.3-a enables the non-nops instructions for PAC, to avoid the
 # compiler to generate them and consequently to break the single image contract
-- 
2.30.2


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

* [PATCH 3/3] arm64: rust: Disable neon and fp target features.
  2023-01-25 16:37 [PATCH 0/3] Rust enablement for AArch64 Jamie Cunliffe
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
  2023-01-25 16:37 ` [PATCH 2/3] arm64: rust: Enable PAC support for Rust Jamie Cunliffe
@ 2023-01-25 16:37 ` Jamie Cunliffe
  2023-01-25 17:49   ` Miguel Ojeda
                     ` (2 more replies)
  2023-01-25 18:01 ` [PATCH 0/3] Rust enablement for AArch64 Miguel Ojeda
  2023-03-07  9:32 ` Asahi Lina
  4 siblings, 3 replies; 21+ messages in thread
From: Jamie Cunliffe @ 2023-01-25 16:37 UTC (permalink / raw)
  To: linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

Disable the neon and fp target features to avoid fp & simd
registers. The use of fp-armv8 will cause a warning from rustc about
an unknown feature that is specified. The target feature is still
passed through to LLVM, this behaviour is documented as part of the
warning. This will be fixed in a future version of the rustc
toolchain.

Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
---
 arch/arm64/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index b53ab6aa2dfe..33ae20fc3f56 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -41,6 +41,8 @@ KBUILD_CFLAGS	+= -mgeneral-regs-only	\
 KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
 KBUILD_AFLAGS	+= $(compat_vdso)
 
+KBUILD_RUSTFLAGS += -C target-feature="-neon,-fp-armv8"
+
 KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
 KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
 
-- 
2.30.2


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

* Re: [PATCH 3/3] arm64: rust: Disable neon and fp target features.
  2023-01-25 16:37 ` [PATCH 3/3] arm64: rust: Disable neon and fp target features Jamie Cunliffe
@ 2023-01-25 17:49   ` Miguel Ojeda
  2023-01-25 19:55   ` Vincenzo Palazzo
  2023-01-26 16:37   ` Will Deacon
  2 siblings, 0 replies; 21+ messages in thread
From: Miguel Ojeda @ 2023-01-25 17:49 UTC (permalink / raw)
  To: Jamie Cunliffe
  Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas,
	Will Deacon, steve.capper

On Wed, Jan 25, 2023 at 5:38 PM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote:
>
> Disable the neon and fp target features to avoid fp & simd
> registers. The use of fp-armv8 will cause a warning from rustc about
> an unknown feature that is specified.

This would be https://github.com/rust-lang/rust/issues/96472, right?
(if I misunderstood and it is something else, please let me know!)

> The target feature is still
> passed through to LLVM, this behaviour is documented as part of the
> warning. This will be fixed in a future version of the rustc
> toolchain.

The cover letter had the link, which could be nice to have here in a
`Link: ` tag maybe.

Cheers,
Miguel

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

* Re: [PATCH 0/3] Rust enablement for AArch64
  2023-01-25 16:37 [PATCH 0/3] Rust enablement for AArch64 Jamie Cunliffe
                   ` (2 preceding siblings ...)
  2023-01-25 16:37 ` [PATCH 3/3] arm64: rust: Disable neon and fp target features Jamie Cunliffe
@ 2023-01-25 18:01 ` Miguel Ojeda
  2023-03-07  9:32 ` Asahi Lina
  4 siblings, 0 replies; 21+ messages in thread
From: Miguel Ojeda @ 2023-01-25 18:01 UTC (permalink / raw)
  To: Jamie Cunliffe
  Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas,
	Will Deacon, steve.capper

Hi Jamie,

On Wed, Jan 25, 2023 at 5:37 PM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote:
>
> The first patch is from Miguel's tree to enable Rust support for
> AArch64. This has been tested with the Rust samples, and the generated
> code has also been manually inspected.

Thanks a lot for this -- it is great to hear the prototype arm64
support we had at least made some basic sense :)

I imagine eventually we will need more changes on the target like BE
vs. LE, shadow call stack, extensions, etc., right?

> The second patch enables the PAC ret and BTI options in the Rust build
> flags to match the options that are used when building C.
>
> The third patch disables the neon and fp target features to avoid fp &
> simd registers. The use of fp-armv8 will cause a warning from rustc
> about an unknown feature that is specified. The target feature is
> still passed through to LLVM, this behaviour is documented as part of
> the warning. This will be fixed in a future version of the rustc
> toolchain. This pull request should address it,
> https://github.com/rust-lang/rust/pull/107294

Great, thanks a lot. I have linked this one at
https://github.com/Rust-for-Linux/linux/issues/355 (if you have
others, please let me know, it would be ideal to track them there)

On upstreaming: it would be great if ARM64 maintainers can take a look
(and please feel free to take it through your tree as well!).

Cheers,
Miguel

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
@ 2023-01-25 19:50   ` Vincenzo Palazzo
  2023-01-25 19:56   ` Vincenzo Palazzo
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 21+ messages in thread
From: Vincenzo Palazzo @ 2023-01-25 19:50 UTC (permalink / raw)
  To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

On Wed Jan 25, 2023 at 5:37 PM CET, Jamie Cunliffe wrote:
> From: Miguel Ojeda <ojeda@kernel.org>
>
> This commit provides the build flags for Rust for AArch64. The core Rust
> support already in the kernel does the rest.
>
> The Rust samples have been tested with this commit.
>
> [jcunliffe: Arm specific parts taken from Miguel's upstream tree]
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> Co-developed-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
> ---
>  Documentation/rust/arch-support.rst |  1 +
>  arch/arm64/Kconfig                  |  1 +
>  scripts/generate_rust_target.rs     | 13 ++++++++++++-
>  3 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst
> index 6982b63775da..3776059a385a 100644
> --- a/Documentation/rust/arch-support.rst
> +++ b/Documentation/rust/arch-support.rst
> @@ -15,5 +15,6 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
>  ============  ================  ==============================================
>  Architecture  Level of support  Constraints
>  ============  ================  ==============================================
> +``arm64``     Maintained        None.
>  ``x86``       Maintained        ``x86_64`` only.
>  ============  ================  ==============================================
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 03934808b2ed..fc3800e82802 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -209,6 +209,7 @@ config ARM64
>  	select HAVE_FUNCTION_ARG_ACCESS_API
>  	select MMU_GATHER_RCU_TABLE_FREE
>  	select HAVE_RSEQ
> +	select HAVE_RUST
>  	select HAVE_STACKPROTECTOR
>  	select HAVE_SYSCALL_TRACEPOINTS
>  	select HAVE_KPROBES
> diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> index 3c6cbe2b278d..fe0e4ba54492 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -148,7 +148,18 @@ fn main() {
>      let mut ts = TargetSpec::new();
>  
>      // `llvm-target`s are taken from `scripts/Makefile.clang`.
> -    if cfg.has("X86_64") {
> +    if cfg.has("ARM64") {
> +        ts.push("arch", "aarch64");
> +        ts.push(
> +            "data-layout",
> +            "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
> +        );
> +        ts.push("disable-redzone", true);
> +        ts.push("features", "+strict-align,+neon,+fp-armv8");
> +        ts.push("llvm-target", "aarch64-linux-gnu");
> +        ts.push("max-atomic-width", 128);
> +        ts.push("target-pointer-width", "64");
> +    } else if cfg.has("X86_64") {
>          ts.push("arch", "x86_64");
>          ts.push(
>              "data-layout",
> -- 
> 2.30.2


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

* Re: [PATCH 2/3] arm64: rust: Enable PAC support for Rust.
  2023-01-25 16:37 ` [PATCH 2/3] arm64: rust: Enable PAC support for Rust Jamie Cunliffe
@ 2023-01-25 19:54   ` Vincenzo Palazzo
  0 siblings, 0 replies; 21+ messages in thread
From: Vincenzo Palazzo @ 2023-01-25 19:54 UTC (permalink / raw)
  To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

On Wed Jan 25, 2023 at 5:37 PM CET, Jamie Cunliffe wrote:
> Enable the PAC ret and BTI options in the Rust build flags to match
> the options that are used when building C.
>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

> ---
>  arch/arm64/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index d62bd221828f..b53ab6aa2dfe 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -85,8 +85,10 @@ PACRET-$(CONFIG_UNWIND_PATCH_PAC_INTO_SCS) := pac-ret
>  
>  ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
>  branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protection=$(PACRET-y)+bti
> +KBUILD_RUSTFLAGS += -Z branch-protection=bti,pac-ret,leaf
>  else
>  branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=$(PACRET-y)
> +KBUILD_RUSTFLAGS += -Z branch-protection=pac-ret,leaf
>  endif
>  # -march=armv8.3-a enables the non-nops instructions for PAC, to avoid the
>  # compiler to generate them and consequently to break the single image contract
> -- 
> 2.30.2


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

* Re: [PATCH 3/3] arm64: rust: Disable neon and fp target features.
  2023-01-25 16:37 ` [PATCH 3/3] arm64: rust: Disable neon and fp target features Jamie Cunliffe
  2023-01-25 17:49   ` Miguel Ojeda
@ 2023-01-25 19:55   ` Vincenzo Palazzo
  2023-01-26 16:37   ` Will Deacon
  2 siblings, 0 replies; 21+ messages in thread
From: Vincenzo Palazzo @ 2023-01-25 19:55 UTC (permalink / raw)
  To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

On Wed Jan 25, 2023 at 5:37 PM CET, Jamie Cunliffe wrote:
> Disable the neon and fp target features to avoid fp & simd
> registers. The use of fp-armv8 will cause a warning from rustc about
> an unknown feature that is specified. The target feature is still
> passed through to LLVM, this behaviour is documented as part of the
> warning. This will be fixed in a future version of the rustc
> toolchain.
>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
> ---
>  arch/arm64/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index b53ab6aa2dfe..33ae20fc3f56 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -41,6 +41,8 @@ KBUILD_CFLAGS	+= -mgeneral-regs-only	\
>  KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
>  KBUILD_AFLAGS	+= $(compat_vdso)
>  
> +KBUILD_RUSTFLAGS += -C target-feature="-neon,-fp-armv8"
> +
>  KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
>  KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
>  
> -- 
> 2.30.2


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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
  2023-01-25 19:50   ` Vincenzo Palazzo
@ 2023-01-25 19:56   ` Vincenzo Palazzo
  2023-01-26 16:35   ` Will Deacon
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 21+ messages in thread
From: Vincenzo Palazzo @ 2023-01-25 19:56 UTC (permalink / raw)
  To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

On Wed Jan 25, 2023 at 5:37 PM CET, Jamie Cunliffe wrote:
> From: Miguel Ojeda <ojeda@kernel.org>
>
> This commit provides the build flags for Rust for AArch64. The core Rust
> support already in the kernel does the rest.
>
> The Rust samples have been tested with this commit.
>
> [jcunliffe: Arm specific parts taken from Miguel's upstream tree]
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> Co-developed-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

P.S: wrong answer template in the prev mail :)
> ---
>  Documentation/rust/arch-support.rst |  1 +
>  arch/arm64/Kconfig                  |  1 +
>  scripts/generate_rust_target.rs     | 13 ++++++++++++-
>  3 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst
> index 6982b63775da..3776059a385a 100644
> --- a/Documentation/rust/arch-support.rst
> +++ b/Documentation/rust/arch-support.rst
> @@ -15,5 +15,6 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
>  ============  ================  ==============================================
>  Architecture  Level of support  Constraints
>  ============  ================  ==============================================
> +``arm64``     Maintained        None.
>  ``x86``       Maintained        ``x86_64`` only.
>  ============  ================  ==============================================
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 03934808b2ed..fc3800e82802 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -209,6 +209,7 @@ config ARM64
>  	select HAVE_FUNCTION_ARG_ACCESS_API
>  	select MMU_GATHER_RCU_TABLE_FREE
>  	select HAVE_RSEQ
> +	select HAVE_RUST
>  	select HAVE_STACKPROTECTOR
>  	select HAVE_SYSCALL_TRACEPOINTS
>  	select HAVE_KPROBES
> diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> index 3c6cbe2b278d..fe0e4ba54492 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -148,7 +148,18 @@ fn main() {
>      let mut ts = TargetSpec::new();
>  
>      // `llvm-target`s are taken from `scripts/Makefile.clang`.
> -    if cfg.has("X86_64") {
> +    if cfg.has("ARM64") {
> +        ts.push("arch", "aarch64");
> +        ts.push(
> +            "data-layout",
> +            "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
> +        );
> +        ts.push("disable-redzone", true);
> +        ts.push("features", "+strict-align,+neon,+fp-armv8");
> +        ts.push("llvm-target", "aarch64-linux-gnu");
> +        ts.push("max-atomic-width", 128);
> +        ts.push("target-pointer-width", "64");
> +    } else if cfg.has("X86_64") {
>          ts.push("arch", "x86_64");
>          ts.push(
>              "data-layout",
> -- 
> 2.30.2


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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
  2023-01-25 19:50   ` Vincenzo Palazzo
  2023-01-25 19:56   ` Vincenzo Palazzo
@ 2023-01-26 16:35   ` Will Deacon
  2023-01-26 17:56     ` Miguel Ojeda
  2023-01-27 14:09   ` Gary Guo
  2023-05-02 13:41   ` Asahi Lina
  4 siblings, 1 reply; 21+ messages in thread
From: Will Deacon @ 2023-01-26 16:35 UTC (permalink / raw)
  To: Jamie Cunliffe
  Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas,
	steve.capper

On Wed, Jan 25, 2023 at 04:37:37PM +0000, Jamie Cunliffe wrote:
> From: Miguel Ojeda <ojeda@kernel.org>
> 
> This commit provides the build flags for Rust for AArch64. The core Rust
> support already in the kernel does the rest.
> 
> The Rust samples have been tested with this commit.
> 
> [jcunliffe: Arm specific parts taken from Miguel's upstream tree]
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> Co-developed-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> ---
>  Documentation/rust/arch-support.rst |  1 +
>  arch/arm64/Kconfig                  |  1 +
>  scripts/generate_rust_target.rs     | 13 ++++++++++++-
>  3 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst
> index 6982b63775da..3776059a385a 100644
> --- a/Documentation/rust/arch-support.rst
> +++ b/Documentation/rust/arch-support.rst
> @@ -15,5 +15,6 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
>  ============  ================  ==============================================
>  Architecture  Level of support  Constraints
>  ============  ================  ==============================================
> +``arm64``     Maintained        None.
>  ``x86``       Maintained        ``x86_64`` only.
>  ============  ================  ==============================================
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 03934808b2ed..fc3800e82802 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -209,6 +209,7 @@ config ARM64
>  	select HAVE_FUNCTION_ARG_ACCESS_API
>  	select MMU_GATHER_RCU_TABLE_FREE
>  	select HAVE_RSEQ
> +	select HAVE_RUST
>  	select HAVE_STACKPROTECTOR
>  	select HAVE_SYSCALL_TRACEPOINTS
>  	select HAVE_KPROBES
> diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> index 3c6cbe2b278d..fe0e4ba54492 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -148,7 +148,18 @@ fn main() {
>      let mut ts = TargetSpec::new();
>  
>      // `llvm-target`s are taken from `scripts/Makefile.clang`.
> -    if cfg.has("X86_64") {
> +    if cfg.has("ARM64") {
> +        ts.push("arch", "aarch64");
> +        ts.push(
> +            "data-layout",
> +            "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
> +        );
> +        ts.push("disable-redzone", true);
> +        ts.push("features", "+strict-align,+neon,+fp-armv8");
> +        ts.push("llvm-target", "aarch64-linux-gnu");
> +        ts.push("max-atomic-width", 128);
> +        ts.push("target-pointer-width", "64");

Why do we need to specify this stuff here? LLVM already knows about AArch64
and can compute the data-layout string in computeDataLayout(). Can we have
the tools figure this out for us instead, please?

Will

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

* Re: [PATCH 3/3] arm64: rust: Disable neon and fp target features.
  2023-01-25 16:37 ` [PATCH 3/3] arm64: rust: Disable neon and fp target features Jamie Cunliffe
  2023-01-25 17:49   ` Miguel Ojeda
  2023-01-25 19:55   ` Vincenzo Palazzo
@ 2023-01-26 16:37   ` Will Deacon
  2 siblings, 0 replies; 21+ messages in thread
From: Will Deacon @ 2023-01-26 16:37 UTC (permalink / raw)
  To: Jamie Cunliffe
  Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas,
	steve.capper

On Wed, Jan 25, 2023 at 04:37:39PM +0000, Jamie Cunliffe wrote:
> Disable the neon and fp target features to avoid fp & simd
> registers. The use of fp-armv8 will cause a warning from rustc about
> an unknown feature that is specified. The target feature is still
> passed through to LLVM, this behaviour is documented as part of the
> warning. This will be fixed in a future version of the rustc
> toolchain.
> 
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> ---
>  arch/arm64/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index b53ab6aa2dfe..33ae20fc3f56 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -41,6 +41,8 @@ KBUILD_CFLAGS	+= -mgeneral-regs-only	\
>  KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
>  KBUILD_AFLAGS	+= $(compat_vdso)
>  
> +KBUILD_RUSTFLAGS += -C target-feature="-neon,-fp-armv8"

Why do we advertise these features as present in
scripts/generate_rust_target.rs?

Will

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-26 16:35   ` Will Deacon
@ 2023-01-26 17:56     ` Miguel Ojeda
  2023-01-31 16:19       ` Will Deacon
  0 siblings, 1 reply; 21+ messages in thread
From: Miguel Ojeda @ 2023-01-26 17:56 UTC (permalink / raw)
  To: Will Deacon
  Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda,
	Catalin Marinas, steve.capper

On Thu, Jan 26, 2023 at 5:35 PM Will Deacon <will@kernel.org> wrote:
>
> Why do we need to specify this stuff here? LLVM already knows about AArch64
> and can compute the data-layout string in computeDataLayout(). Can we have
> the tools figure this out for us instead, please?

I agree -- the reason we have this for the moment is to provide full
control of the target spec, in particular for cases where `rustc` may
not provide enough flags to customize exiting builtin target specs
and/or may emit warnings for unknown target features etc.

If it is already enough for arm64 to use e.g. the
`aarch64-unknown-none` target spec plus flags on top, then we should
go for that, because that is the end goal: these target spec files are
unstable in the Rust compiler (and not intended to become stable).

For context, upstream Rust so far has been willing to merge support
for flags and target features that we needed, which is great.

Cheers,
Miguel

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
                     ` (2 preceding siblings ...)
  2023-01-26 16:35   ` Will Deacon
@ 2023-01-27 14:09   ` Gary Guo
  2023-05-02 13:41   ` Asahi Lina
  4 siblings, 0 replies; 21+ messages in thread
From: Gary Guo @ 2023-01-27 14:09 UTC (permalink / raw)
  To: Jamie Cunliffe
  Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas,
	Will Deacon, steve.capper

On Wed, 25 Jan 2023 16:37:37 +0000
Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote:

> From: Miguel Ojeda <ojeda@kernel.org>
> 
> This commit provides the build flags for Rust for AArch64. The core Rust
> support already in the kernel does the rest.
> 
> The Rust samples have been tested with this commit.
> 
> [jcunliffe: Arm specific parts taken from Miguel's upstream tree]
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> Co-developed-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>

Reviewed-by: Gary Guo <gary@garyguo.net>

> ---
>  Documentation/rust/arch-support.rst |  1 +
>  arch/arm64/Kconfig                  |  1 +
>  scripts/generate_rust_target.rs     | 13 ++++++++++++-
>  3 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst
> index 6982b63775da..3776059a385a 100644
> --- a/Documentation/rust/arch-support.rst
> +++ b/Documentation/rust/arch-support.rst
> @@ -15,5 +15,6 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
>  ============  ================  ==============================================
>  Architecture  Level of support  Constraints
>  ============  ================  ==============================================
> +``arm64``     Maintained        None.
>  ``x86``       Maintained        ``x86_64`` only.
>  ============  ================  ==============================================
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 03934808b2ed..fc3800e82802 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -209,6 +209,7 @@ config ARM64
>  	select HAVE_FUNCTION_ARG_ACCESS_API
>  	select MMU_GATHER_RCU_TABLE_FREE
>  	select HAVE_RSEQ
> +	select HAVE_RUST
>  	select HAVE_STACKPROTECTOR
>  	select HAVE_SYSCALL_TRACEPOINTS
>  	select HAVE_KPROBES
> diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> index 3c6cbe2b278d..fe0e4ba54492 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -148,7 +148,18 @@ fn main() {
>      let mut ts = TargetSpec::new();
>  
>      // `llvm-target`s are taken from `scripts/Makefile.clang`.
> -    if cfg.has("X86_64") {
> +    if cfg.has("ARM64") {
> +        ts.push("arch", "aarch64");
> +        ts.push(
> +            "data-layout",
> +            "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
> +        );
> +        ts.push("disable-redzone", true);
> +        ts.push("features", "+strict-align,+neon,+fp-armv8");
> +        ts.push("llvm-target", "aarch64-linux-gnu");
> +        ts.push("max-atomic-width", 128);
> +        ts.push("target-pointer-width", "64");
> +    } else if cfg.has("X86_64") {
>          ts.push("arch", "x86_64");
>          ts.push(
>              "data-layout",


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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-26 17:56     ` Miguel Ojeda
@ 2023-01-31 16:19       ` Will Deacon
  2023-01-31 16:49         ` Björn Roy Baron
  2023-01-31 18:55         ` Miguel Ojeda
  0 siblings, 2 replies; 21+ messages in thread
From: Will Deacon @ 2023-01-31 16:19 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda,
	Catalin Marinas, steve.capper

On Thu, Jan 26, 2023 at 06:56:01PM +0100, Miguel Ojeda wrote:
> On Thu, Jan 26, 2023 at 5:35 PM Will Deacon <will@kernel.org> wrote:
> >
> > Why do we need to specify this stuff here? LLVM already knows about AArch64
> > and can compute the data-layout string in computeDataLayout(). Can we have
> > the tools figure this out for us instead, please?
> 
> I agree -- the reason we have this for the moment is to provide full
> control of the target spec, in particular for cases where `rustc` may
> not provide enough flags to customize exiting builtin target specs
> and/or may emit warnings for unknown target features etc.
> 
> If it is already enough for arm64 to use e.g. the
> `aarch64-unknown-none` target spec plus flags on top, then we should
> go for that, because that is the end goal: these target spec files are
> unstable in the Rust compiler (and not intended to become stable).

Please confirm that this is the case, but I really think we should be
aiming for that rather than starting off my specifying this stuff manually.

> For context, upstream Rust so far has been willing to merge support
> for flags and target features that we needed, which is great.

One thing I ran into while playing around is that 128-bit types aren't
supported with ffi unless '-A improper-ctypes' is passed. Given that we
use '__uint128_t' to represent the fpsimd state, I think this is probably
something which will crop up as an issue.

Will

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-31 16:19       ` Will Deacon
@ 2023-01-31 16:49         ` Björn Roy Baron
  2023-01-31 18:55         ` Miguel Ojeda
  1 sibling, 0 replies; 21+ messages in thread
From: Björn Roy Baron @ 2023-01-31 16:49 UTC (permalink / raw)
  To: Will Deacon
  Cc: Miguel Ojeda, Jamie Cunliffe, linux-arm-kernel, rust-for-linux,
	Miguel Ojeda, Catalin Marinas, steve.capper

On Tuesday, January 31st, 2023 at 17:19, Will Deacon <will@kernel.org> wrote:

> On Thu, Jan 26, 2023 at 06:56:01PM +0100, Miguel Ojeda wrote:
> 
> > On Thu, Jan 26, 2023 at 5:35 PM Will Deacon will@kernel.org wrote:
> > 
> > > Why do we need to specify this stuff here? LLVM already knows about AArch64
> > > and can compute the data-layout string in computeDataLayout(). Can we have
> > > the tools figure this out for us instead, please?
> > 
> > I agree -- the reason we have this for the moment is to provide full
> > control of the target spec, in particular for cases where `rustc` may
> > not provide enough flags to customize exiting builtin target specs
> > and/or may emit warnings for unknown target features etc.
> > 
> > If it is already enough for arm64 to use e.g. the
> > `aarch64-unknown-none` target spec plus flags on top, then we should
> > go for that, because that is the end goal: these target spec files are
> > unstable in the Rust compiler (and not intended to become stable).
> 
> 
> Please confirm that this is the case, but I really think we should be
> aiming for that rather than starting off my specifying this stuff manually.
> 
> > For context, upstream Rust so far has been willing to merge support
> > for flags and target features that we needed, which is great.
> 
> 
> One thing I ran into while playing around is that 128-bit types aren't
> supported with ffi unless '-A improper-ctypes' is passed. Given that we
> use '__uint128_t' to represent the fpsimd state, I think this is probably
> something which will crop up as an issue.

This lint exists because u/i128 are indeed not compatible with their C counterpart on many targets including x86_64 with the SysV ABI. As it turns out however, it is compatible on AArch64. A little under a year ago 128bit int type aliases were added to the libc crate on AArch64 (except on Windows) which are equal to u/i128 [1]. In addition it has const assertions for the correct size and alignment. As such if rustc every regresses on non-Windows AArch64, this will show up in a crater run and almost definitively be fixed. Because of this I don't think there will be any problem with assuming __uint128_t and u128 are compatible when compiling for AArch64.

> 
> Will

Cheers,
Bjorn

[1]: https://github.com/rust-lang/libc/pull/2719/files

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-31 16:19       ` Will Deacon
  2023-01-31 16:49         ` Björn Roy Baron
@ 2023-01-31 18:55         ` Miguel Ojeda
  2023-04-18 15:06           ` Jamie Cunliffe
  1 sibling, 1 reply; 21+ messages in thread
From: Miguel Ojeda @ 2023-01-31 18:55 UTC (permalink / raw)
  To: Will Deacon
  Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda,
	Catalin Marinas, steve.capper

On Tue, Jan 31, 2023 at 5:19 PM Will Deacon <will@kernel.org> wrote:
>
> Please confirm that this is the case, but I really think we should be
> aiming for that rather than starting off my specifying this stuff manually.

Let's see what Jamie thinks and if he can give it a try.

> One thing I ran into while playing around is that 128-bit types aren't
> supported with ffi unless '-A improper-ctypes' is passed. Given that we
> use '__uint128_t' to represent the fpsimd state, I think this is probably
> something which will crop up as an issue.

Thanks for giving it a go. With what Björn has explained (I see the PR
he linked has `user_fpsimd_struct` as a test case, which is nice), I
guess it should be fine. We could also add some tests on our side to
make sure (which we probably want to do anyway for other reasons).

Added to https://github.com/Rust-for-Linux/linux/issues/355.

Cheers,
Miguel

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

* Re: [PATCH 0/3] Rust enablement for AArch64
  2023-01-25 16:37 [PATCH 0/3] Rust enablement for AArch64 Jamie Cunliffe
                   ` (3 preceding siblings ...)
  2023-01-25 18:01 ` [PATCH 0/3] Rust enablement for AArch64 Miguel Ojeda
@ 2023-03-07  9:32 ` Asahi Lina
  2023-03-07 12:17   ` Miguel Ojeda
  4 siblings, 1 reply; 21+ messages in thread
From: Asahi Lina @ 2023-03-07  9:32 UTC (permalink / raw)
  To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

On 26/01/2023 01.37, Jamie Cunliffe wrote:
> The first patch is from Miguel's tree to enable Rust support for
> AArch64. This has been tested with the Rust samples, and the generated
> code has also been manually inspected.
> 
> The second patch enables the PAC ret and BTI options in the Rust build
> flags to match the options that are used when building C.
> 
> The third patch disables the neon and fp target features to avoid fp &
> simd registers. The use of fp-armv8 will cause a warning from rustc
> about an unknown feature that is specified. The target feature is
> still passed through to LLVM, this behaviour is documented as part of
> the warning. This will be fixed in a future version of the rustc
> toolchain. This pull request should address it,
> https://github.com/rust-lang/rust/pull/107294
> 
> 
> Jamie Cunliffe (2):
>   arm64: rust: Enable PAC support for Rust.
>   arm64: rust: Disable neon and fp target features.
> 
> Miguel Ojeda (1):
>   arm64: rust: Enable Rust support for AArch64
> 
>  Documentation/rust/arch-support.rst |  1 +
>  arch/arm64/Kconfig                  |  1 +
>  arch/arm64/Makefile                 |  4 ++++
>  scripts/generate_rust_target.rs     | 13 ++++++++++++-
>  4 files changed, 18 insertions(+), 1 deletion(-)
> 

Just as a note, we ran into an issue with this patchset. There is a
missing `BINDGEN_TARGET_arm64` in rust/Makefile (around line 255).
Without that, bindgen fails.

 # Derived from `scripts/Makefile.clang`.
 BINDGEN_TARGET_x86     := x86_64-linux-gnu
+BINDGEN_TARGET_arm64   := aarch64-linux-gnu
 BINDGEN_TARGET         := $(BINDGEN_TARGET_$(SRCARCH))

(No need to credit us for that ^^)

Thanks!
~~ Lina

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

* Re: [PATCH 0/3] Rust enablement for AArch64
  2023-03-07  9:32 ` Asahi Lina
@ 2023-03-07 12:17   ` Miguel Ojeda
  0 siblings, 0 replies; 21+ messages in thread
From: Miguel Ojeda @ 2023-03-07 12:17 UTC (permalink / raw)
  To: Asahi Lina
  Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda,
	Catalin Marinas, Will Deacon, steve.capper

On Tue, Mar 7, 2023 at 10:32 AM Asahi Lina <lina@asahilina.net> wrote:
>
> Just as a note, we ran into an issue with this patchset. There is a
> missing `BINDGEN_TARGET_arm64` in rust/Makefile (around line 255).
> Without that, bindgen fails.

For GCC builds, indeed, it is needed. Same applies to the RISC-V patch
series. Thanks!

Cheers,
Miguel

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-31 18:55         ` Miguel Ojeda
@ 2023-04-18 15:06           ` Jamie Cunliffe
  0 siblings, 0 replies; 21+ messages in thread
From: Jamie Cunliffe @ 2023-04-18 15:06 UTC (permalink / raw)
  To: miguel.ojeda.sandonis
  Cc: Jamie.Cunliffe, catalin.marinas, linux-arm-kernel, ojeda,
	rust-for-linux, steve.capper, will

On Tue, Jan 31, 2023 at 5:19 PM Will Deacon <will@kernel.org> wrote:
> On Thu, Jan 26, 2023 at 06:56:01PM +0100, Miguel Ojeda wrote:
> > On Thu, Jan 26, 2023 at 5:35 PM Will Deacon <will at kernel.org> wrote:
> > >
> > > Why do we need to specify this stuff here? LLVM already knows about AArch64
> > > and can compute the data-layout string in computeDataLayout(). Can we have
> > > the tools figure this out for us instead, please?
> > 
> > I agree -- the reason we have this for the moment is to provide full
> > control of the target spec, in particular for cases where `rustc` may
> > not provide enough flags to customize exiting builtin target specs
> > and/or may emit warnings for unknown target features etc.
> > 
> > If it is already enough for arm64 to use e.g. the
> > `aarch64-unknown-none` target spec plus flags on top, then we should
> > go for that, because that is the end goal: these target spec files are
> > unstable in the Rust compiler (and not intended to become stable).
> 
> Please confirm that this is the case, but I really think we should be
> aiming for that rather than starting off my specifying this stuff manually.

The json that we generate looks to be almost equivalent (that's why patch 3
exists, to answer your question on that patch). The only difference is the
`aarch64-unknown-none` rustc target sets the LLVM target to also be
`aarch64-unknown-none`, whereas the current target.json uses the
`aarch64-linux-gnu` LLVM target as does Makefile.clang for C code. As you have
been talking about the unknown-none target throughout this thread, I just wanted
to double check that's your intention?

Happy to switch over to using the rustc definition though. I just did it this
way to keep it consistent with the other architectures and not add any more
complexity into the build. On a quick test it does seem to be OK, but I'll
prepare a patch and do some proper testing that it's actually fine to use the
rustc definition though.

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

* Re: [PATCH 1/3] arm64: rust: Enable Rust support for AArch64
  2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
                     ` (3 preceding siblings ...)
  2023-01-27 14:09   ` Gary Guo
@ 2023-05-02 13:41   ` Asahi Lina
  4 siblings, 0 replies; 21+ messages in thread
From: Asahi Lina @ 2023-05-02 13:41 UTC (permalink / raw)
  To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux
  Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper

Hi!

On 26/01/2023 01.37, Jamie Cunliffe wrote:
> From: Miguel Ojeda <ojeda@kernel.org>
> 
> This commit provides the build flags for Rust for AArch64. The core Rust
> support already in the kernel does the rest.
> 
> The Rust samples have been tested with this commit.
> 
> [jcunliffe: Arm specific parts taken from Miguel's upstream tree]
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> Co-developed-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
> ---
>   Documentation/rust/arch-support.rst |  1 +
>   arch/arm64/Kconfig                  |  1 +
>   scripts/generate_rust_target.rs     | 13 ++++++++++++-
>   3 files changed, 14 insertions(+), 1 deletion(-)
> 

I'm curious, do you have a timeline for submitting the next revision of 
this patch? We're trying to aim to upstream the drm/asahi driver for 6.6 
or so, but that would depend on CONFIG_ARM64, so it would be lovely if 
we could get this in for 6.5 (and it looks like there shouldn't be too 
many issues left) ^^

~~ Lina


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

end of thread, other threads:[~2023-05-02 13:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 16:37 [PATCH 0/3] Rust enablement for AArch64 Jamie Cunliffe
2023-01-25 16:37 ` [PATCH 1/3] arm64: rust: Enable Rust support " Jamie Cunliffe
2023-01-25 19:50   ` Vincenzo Palazzo
2023-01-25 19:56   ` Vincenzo Palazzo
2023-01-26 16:35   ` Will Deacon
2023-01-26 17:56     ` Miguel Ojeda
2023-01-31 16:19       ` Will Deacon
2023-01-31 16:49         ` Björn Roy Baron
2023-01-31 18:55         ` Miguel Ojeda
2023-04-18 15:06           ` Jamie Cunliffe
2023-01-27 14:09   ` Gary Guo
2023-05-02 13:41   ` Asahi Lina
2023-01-25 16:37 ` [PATCH 2/3] arm64: rust: Enable PAC support for Rust Jamie Cunliffe
2023-01-25 19:54   ` Vincenzo Palazzo
2023-01-25 16:37 ` [PATCH 3/3] arm64: rust: Disable neon and fp target features Jamie Cunliffe
2023-01-25 17:49   ` Miguel Ojeda
2023-01-25 19:55   ` Vincenzo Palazzo
2023-01-26 16:37   ` Will Deacon
2023-01-25 18:01 ` [PATCH 0/3] Rust enablement for AArch64 Miguel Ojeda
2023-03-07  9:32 ` Asahi Lina
2023-03-07 12:17   ` Miguel Ojeda

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).