* [PATCH] Makefile: Make $(LLVM) more flexible
@ 2025-04-30 23:38 Charlie Jenkins
2025-05-01 0:04 ` Jessica Clarke
2025-06-14 7:34 ` Anup Patel
0 siblings, 2 replies; 4+ messages in thread
From: Charlie Jenkins @ 2025-04-30 23:38 UTC (permalink / raw)
To: opensbi; +Cc: Charlie Jenkins
Introduce a way for developers to easily switch between LLVM versions
with LLVM=/path/to/llvm/ and LLVM=-version. This is a useful
addition to the existing LLVM=1 variable which will select the first
clang and llvm binutils available on the path.
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
---
Makefile | 14 ++++++++++----
README.md | 12 ++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index e90836c7c4ad16c30d4d80649ff8b228413190ad..37d4cf41a2214e0a829f1d4a53f3f4f9ae09ee41 100644
--- a/Makefile
+++ b/Makefile
@@ -104,10 +104,16 @@ endif
# Setup compilation commands
ifneq ($(LLVM),)
-CC = clang
-AR = llvm-ar
-LD = ld.lld
-OBJCOPY = llvm-objcopy
+ifneq ($(filter %/,$(LLVM)),)
+LLVM_PREFIX := $(LLVM)
+else ifneq ($(filter -%,$(LLVM)),)
+LLVM_SUFFIX := $(LLVM)
+endif
+
+CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
+AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
+LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
+OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
else
ifdef CROSS_COMPILE
CC = $(CROSS_COMPILE)gcc
diff --git a/README.md b/README.md
index 2795cc1a5ff0df62d83a4b5c3062ff2b682dbcab..fd40be0b4988815d8d02386271aeaeb787541215 100644
--- a/README.md
+++ b/README.md
@@ -252,6 +252,18 @@ option with:
make LLVM=1
```
+To build with a specific version of LLVM, a path to a directory containing the
+LLVM tools can be provided:
+```
+make LLVM=/path/to/llvm/
+```
+
+If you have versioned llvm tools you would like to use, such as `clang-17`, the LLVM variable can
+be set as:
+```
+make LLVM=-17
+```
+
When using Clang, *CROSS_COMPILE* often does not need to be defined unless
using GNU binutils with prefixed binary names. *PLATFORM_RISCV_XLEN* will be
used to infer a default triple to pass to Clang, so if *PLATFORM_RISCV_XLEN*
---
base-commit: 316daaf1c299c29ac46e52145f65521f48ec63b5
change-id: 20250430-improve_llvm_building-cff31918e1a6
--
- Charlie
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Makefile: Make $(LLVM) more flexible
2025-04-30 23:38 [PATCH] Makefile: Make $(LLVM) more flexible Charlie Jenkins
@ 2025-05-01 0:04 ` Jessica Clarke
2025-05-01 0:11 ` Charlie Jenkins
2025-06-14 7:34 ` Anup Patel
1 sibling, 1 reply; 4+ messages in thread
From: Jessica Clarke @ 2025-05-01 0:04 UTC (permalink / raw)
To: Charlie Jenkins; +Cc: opensbi
On 1 May 2025, at 00:38, Charlie Jenkins <charlie@rivosinc.com> wrote:
>
> Introduce a way for developers to easily switch between LLVM versions
> with LLVM=/path/to/llvm/ and LLVM=-version. This is a useful
FreeBSD doesn’t include a hyphen in its version number suffix, you get
clang20 etc. In the Linux world where you’ve copied this pattern from
verbatim that may well hold, but OpenSBI supports more than just Linux.
One could special-case LLVM=1 and treat anything else as a suffix I
suppose, though that would be a little weird.
Jess
> addition to the existing LLVM=1 variable which will select the first
> clang and llvm binutils available on the path.
>
> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> ---
> Makefile | 14 ++++++++++----
> README.md | 12 ++++++++++++
> 2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index e90836c7c4ad16c30d4d80649ff8b228413190ad..37d4cf41a2214e0a829f1d4a53f3f4f9ae09ee41 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -104,10 +104,16 @@ endif
>
> # Setup compilation commands
> ifneq ($(LLVM),)
> -CC = clang
> -AR = llvm-ar
> -LD = ld.lld
> -OBJCOPY = llvm-objcopy
> +ifneq ($(filter %/,$(LLVM)),)
> +LLVM_PREFIX := $(LLVM)
> +else ifneq ($(filter -%,$(LLVM)),)
> +LLVM_SUFFIX := $(LLVM)
> +endif
> +
> +CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> +AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
> +LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
> +OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
> else
> ifdef CROSS_COMPILE
> CC = $(CROSS_COMPILE)gcc
> diff --git a/README.md b/README.md
> index 2795cc1a5ff0df62d83a4b5c3062ff2b682dbcab..fd40be0b4988815d8d02386271aeaeb787541215 100644
> --- a/README.md
> +++ b/README.md
> @@ -252,6 +252,18 @@ option with:
> make LLVM=1
> ```
>
> +To build with a specific version of LLVM, a path to a directory containing the
> +LLVM tools can be provided:
> +```
> +make LLVM=/path/to/llvm/
> +```
> +
> +If you have versioned llvm tools you would like to use, such as `clang-17`, the LLVM variable can
> +be set as:
> +```
> +make LLVM=-17
> +```
> +
> When using Clang, *CROSS_COMPILE* often does not need to be defined unless
> using GNU binutils with prefixed binary names. *PLATFORM_RISCV_XLEN* will be
> used to infer a default triple to pass to Clang, so if *PLATFORM_RISCV_XLEN*
>
> ---
> base-commit: 316daaf1c299c29ac46e52145f65521f48ec63b5
> change-id: 20250430-improve_llvm_building-cff31918e1a6
> --
> - Charlie
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Makefile: Make $(LLVM) more flexible
2025-05-01 0:04 ` Jessica Clarke
@ 2025-05-01 0:11 ` Charlie Jenkins
0 siblings, 0 replies; 4+ messages in thread
From: Charlie Jenkins @ 2025-05-01 0:11 UTC (permalink / raw)
To: Jessica Clarke; +Cc: opensbi
On Thu, May 01, 2025 at 01:04:38AM +0100, Jessica Clarke wrote:
> On 1 May 2025, at 00:38, Charlie Jenkins <charlie@rivosinc.com> wrote:
> >
> > Introduce a way for developers to easily switch between LLVM versions
> > with LLVM=/path/to/llvm/ and LLVM=-version. This is a useful
>
> FreeBSD doesn’t include a hyphen in its version number suffix, you get
> clang20 etc. In the Linux world where you’ve copied this pattern from
> verbatim that may well hold, but OpenSBI supports more than just Linux.
>
> One could special-case LLVM=1 and treat anything else as a suffix I
> suppose, though that would be a little weird.
This pattern not being applicable for all systems doesn't invalidate the
usecase for systems that do support it. Developers can still manipulate
their PATH to get LLVM=1 to select the clang that they want.
- Charlie
>
> Jess
>
> > addition to the existing LLVM=1 variable which will select the first
> > clang and llvm binutils available on the path.
> >
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > ---
> > Makefile | 14 ++++++++++----
> > README.md | 12 ++++++++++++
> > 2 files changed, 22 insertions(+), 4 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index e90836c7c4ad16c30d4d80649ff8b228413190ad..37d4cf41a2214e0a829f1d4a53f3f4f9ae09ee41 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -104,10 +104,16 @@ endif
> >
> > # Setup compilation commands
> > ifneq ($(LLVM),)
> > -CC = clang
> > -AR = llvm-ar
> > -LD = ld.lld
> > -OBJCOPY = llvm-objcopy
> > +ifneq ($(filter %/,$(LLVM)),)
> > +LLVM_PREFIX := $(LLVM)
> > +else ifneq ($(filter -%,$(LLVM)),)
> > +LLVM_SUFFIX := $(LLVM)
> > +endif
> > +
> > +CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> > +AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
> > +LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
> > +OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
> > else
> > ifdef CROSS_COMPILE
> > CC = $(CROSS_COMPILE)gcc
> > diff --git a/README.md b/README.md
> > index 2795cc1a5ff0df62d83a4b5c3062ff2b682dbcab..fd40be0b4988815d8d02386271aeaeb787541215 100644
> > --- a/README.md
> > +++ b/README.md
> > @@ -252,6 +252,18 @@ option with:
> > make LLVM=1
> > ```
> >
> > +To build with a specific version of LLVM, a path to a directory containing the
> > +LLVM tools can be provided:
> > +```
> > +make LLVM=/path/to/llvm/
> > +```
> > +
> > +If you have versioned llvm tools you would like to use, such as `clang-17`, the LLVM variable can
> > +be set as:
> > +```
> > +make LLVM=-17
> > +```
> > +
> > When using Clang, *CROSS_COMPILE* often does not need to be defined unless
> > using GNU binutils with prefixed binary names. *PLATFORM_RISCV_XLEN* will be
> > used to infer a default triple to pass to Clang, so if *PLATFORM_RISCV_XLEN*
> >
> > ---
> > base-commit: 316daaf1c299c29ac46e52145f65521f48ec63b5
> > change-id: 20250430-improve_llvm_building-cff31918e1a6
> > --
> > - Charlie
> >
> >
> > --
> > opensbi mailing list
> > opensbi@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi
>
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Makefile: Make $(LLVM) more flexible
2025-04-30 23:38 [PATCH] Makefile: Make $(LLVM) more flexible Charlie Jenkins
2025-05-01 0:04 ` Jessica Clarke
@ 2025-06-14 7:34 ` Anup Patel
1 sibling, 0 replies; 4+ messages in thread
From: Anup Patel @ 2025-06-14 7:34 UTC (permalink / raw)
To: Charlie Jenkins; +Cc: opensbi
On Thu, May 1, 2025 at 5:09 AM Charlie Jenkins <charlie@rivosinc.com> wrote:
>
> Introduce a way for developers to easily switch between LLVM versions
> with LLVM=/path/to/llvm/ and LLVM=-version. This is a useful
> addition to the existing LLVM=1 variable which will select the first
> clang and llvm binutils available on the path.
>
> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
LGTM.
Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Anup Patel <anup@brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> Makefile | 14 ++++++++++----
> README.md | 12 ++++++++++++
> 2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index e90836c7c4ad16c30d4d80649ff8b228413190ad..37d4cf41a2214e0a829f1d4a53f3f4f9ae09ee41 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -104,10 +104,16 @@ endif
>
> # Setup compilation commands
> ifneq ($(LLVM),)
> -CC = clang
> -AR = llvm-ar
> -LD = ld.lld
> -OBJCOPY = llvm-objcopy
> +ifneq ($(filter %/,$(LLVM)),)
> +LLVM_PREFIX := $(LLVM)
> +else ifneq ($(filter -%,$(LLVM)),)
> +LLVM_SUFFIX := $(LLVM)
> +endif
> +
> +CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> +AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
> +LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
> +OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
> else
> ifdef CROSS_COMPILE
> CC = $(CROSS_COMPILE)gcc
> diff --git a/README.md b/README.md
> index 2795cc1a5ff0df62d83a4b5c3062ff2b682dbcab..fd40be0b4988815d8d02386271aeaeb787541215 100644
> --- a/README.md
> +++ b/README.md
> @@ -252,6 +252,18 @@ option with:
> make LLVM=1
> ```
>
> +To build with a specific version of LLVM, a path to a directory containing the
> +LLVM tools can be provided:
> +```
> +make LLVM=/path/to/llvm/
> +```
> +
> +If you have versioned llvm tools you would like to use, such as `clang-17`, the LLVM variable can
> +be set as:
> +```
> +make LLVM=-17
> +```
> +
> When using Clang, *CROSS_COMPILE* often does not need to be defined unless
> using GNU binutils with prefixed binary names. *PLATFORM_RISCV_XLEN* will be
> used to infer a default triple to pass to Clang, so if *PLATFORM_RISCV_XLEN*
>
> ---
> base-commit: 316daaf1c299c29ac46e52145f65521f48ec63b5
> change-id: 20250430-improve_llvm_building-cff31918e1a6
> --
> - Charlie
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-14 8:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 23:38 [PATCH] Makefile: Make $(LLVM) more flexible Charlie Jenkins
2025-05-01 0:04 ` Jessica Clarke
2025-05-01 0:11 ` Charlie Jenkins
2025-06-14 7:34 ` Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox