Skip to contentSkip to conversation

Add support for the D programming language

PATCH New Eric Le Bihan 3 participants 9 messages Oct 24, 2019 – Oct 25, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for the D programming language

This small series add supports for the D programming language, available in GCC since version 9.1.

v1 -> v2:

- restrict support for Buildroot toolchain to some architectures.
- add support for external toolchain.

Eric Le Bihan (3):
toolchain: add support for D language
package/gcc: add support for D language
toolchain-external: add support for D language

 package/gcc/Config.in.host                    | 22 +++++++++++++++++++
 package/gcc/gcc-final/gcc-final.mk            |  5 +++++
 toolchain/Config.in                           |  3 +++
 .../pkg-toolchain-external.mk                 |  4 ++++
 .../Config.in.options                         |  8 +++++++
 5 files changed, 42 insertions(+)

--
2.21.0

#1 lore raw

PATCH v2 1/3 toolchain: add support for D language

Since version 9.1, GCC provides support for the D programming language [1].

So add an option to indicate the selected toolchain supports this language.

[1] https://dlang.org/

---
 toolchain/Config.in | 3 +++
 1 file changed, 3 insertions(+)
toolchain/Config.in +3 -0
index 3bc3b1b4b0..c9aa95985f 100644
@@ -171,6 +171,9 @@ config BR2_ENABLE_LOCALE
 config BR2_INSTALL_LIBSTDCPP
 	bool
 
+config BR2_TOOLCHAIN_HAS_DLANG
+	bool
+
 config BR2_TOOLCHAIN_HAS_FORTRAN
 	bool
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 1/3 toolchain: add support for D language

Quoted 11 lines · On Thu, 24 Oct 2019 20:16:19 +0200 Eric Le Bihan <[email protected]>…

Since version 9.1, GCC provides support for the D programming language [1].

So add an option to indicate the selected toolchain supports this language.

[1] https://dlang.org/

---
 toolchain/Config.in | 3 +++
 1 file changed, 3 insertions(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH v2 2/3 package/gcc: add support for D language

In reply to Eric Le Bihan

Since version 9.1, GCC provides support for the D programming language [1].

So add a Kconfig entry to enable support for it.

[1] https://dlang.org/

---
 package/gcc/Config.in.host         | 22 ++++++++++++++++++++++
 package/gcc/gcc-final/gcc-final.mk |  5 +++++
 2 files changed, 27 insertions(+)
package/gcc/Config.in.host +22 -0
index 75be7c48cc..aeea21c0fb 100644
@@ -77,6 +77,19 @@ config BR2_GCC_SUPPORTS_LIBCILKRTS
 	bool
 	default y if !BR2_TOOLCHAIN_GCC_AT_LEAST_8
 
+config BR2_GCC_SUPPORTS_DLANG
+	bool
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_9
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	default y if BR2_aarch64
+	default y if BR2_arm
+	default y if BR2_i386
+	default y if BR2_mips || BR2_mipsel
+	default y if BR2_mips64 || BR2_mips64el
+	default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
+	default y if BR2_x86_64
+	default y if BR2_riscv && !BR2_RISCV_64
+
 config BR2_GCC_VERSION
 	string
 	default "5.5.0"     if BR2_GCC_VERSION_5_X
@@ -118,6 +131,15 @@ config BR2_TOOLCHAIN_BUILDROOT_FORTRAN
 	  Fortran language and you want Fortran libraries to be
 	  installed on your target system.
 
+config BR2_TOOLCHAIN_BUILDROOT_DLANG
+	bool "Enable D language support"
+	depends on BR2_GCC_SUPPORTS_DLANG
+	select BR2_TOOLCHAIN_HAS_DLANG
+	help
+	  Enable this option if you want your toolchain to support the
+	  D language and you want D libraries to be installed on your
+	  target system.
+
 config BR2_GCC_ENABLE_LTO
 	bool "Enable compiler link-time-optimization support"
 	select BR2_BINUTILS_ENABLE_LTO
package/gcc/gcc-final/gcc-final.mk +5 -0
index f478fde0d7..79c88a5d60 100644
@@ -55,6 +55,7 @@ endef
 # Languages supported by the cross-compiler
 GCC_FINAL_CROSS_LANGUAGES-y = c
 GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_LIBSTDCPP) += c++
+GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_BUILDROOT_DLANG) += d
 GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_BUILDROOT_FORTRAN) += fortran
 GCC_FINAL_CROSS_LANGUAGES = $(subst $(space),$(comma),$(GCC_FINAL_CROSS_LANGUAGES-y))
 
@@ -172,6 +173,10 @@ ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 HOST_GCC_FINAL_USR_LIBS += libstdc++
 endif
 
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_DLANG),y)
+HOST_GCC_FINAL_USR_LIBS += libgdruntime libgphobos
+endif
+
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_FORTRAN),y)
 HOST_GCC_FINAL_USR_LIBS += libgfortran
 # fortran needs quadmath on x86 and x86_64
Signature · 1 line
2.21.0
#4 lore raw

PATCH v2 2/3 package/gcc: add support for D language

Quoted 11 lines · On Thu, 24 Oct 2019 20:16:20 +0200 Eric Le Bihan <[email protected]>…

Since version 9.1, GCC provides support for the D programming language [1].

So add a Kconfig entry to enable support for it.

[1] https://dlang.org/

---
 package/gcc/Config.in.host         | 22 ++++++++++++++++++++++
 package/gcc/gcc-final/gcc-final.mk |  5 +++++
 2 files changed, 27 insertions(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH v2 3/3 toolchain-external: add support for D language

In reply to Eric Le Bihan
---
 toolchain/toolchain-external/pkg-toolchain-external.mk    | 4 ++++
 .../toolchain-external-custom/Config.in.options           | 8 ++++++++
 2 files changed, 12 insertions(+)
toolchain/toolchain-external/pkg-toolchain-external.mk +4 -0
index c00211d59c..9c5321ea36 100644
@@ -148,6 +148,10 @@ ifeq ($(BR2_TOOLCHAIN_HAS_OPENMP),y)
 TOOLCHAIN_EXTERNAL_LIBS += libgomp.so.*
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_DLANG),y)
+TOOLCHAIN_EXTERNAL_LIBS += libgdruntime.so* libgphobos.so*
+endif
+
 TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
 
 
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +8 -0
index 83d9ed61d7..f686cb3305 100644
@@ -415,6 +415,14 @@ config BR2_TOOLCHAIN_EXTERNAL_CXX
 	  support. If you don't know, leave the default value,
 	  Buildroot will tell you if it's correct or not.
 
+config BR2_TOOLCHAIN_EXTERNAL_DLANG
+	bool "Toolchain has D support?"
+	select BR2_TOOLCHAIN_HAS_DLANG
+	help
+	  Select this option if your external toolchain has D
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+
 config BR2_TOOLCHAIN_EXTERNAL_FORTRAN
 	bool "Toolchain has Fortran support?"
 	select BR2_TOOLCHAIN_HAS_FORTRAN
Signature · 1 line
2.21.0
#6 lore raw

PATCH v2 3/3 toolchain-external: add support for D language

Hi Eric,

Le 24/10/2019 ? 20:16, Eric Le Bihan a ?crit?:

Quoted 27 lines
---
 toolchain/toolchain-external/pkg-toolchain-external.mk    | 4 ++++
 .../toolchain-external-custom/Config.in.options           | 8 ++++++++
 2 files changed, 12 insertions(+)
toolchain/toolchain-external/pkg-toolchain-external.mk +4 -0
index c00211d59c..9c5321ea36 100644
@@ -148,6 +148,10 @@ ifeq ($(BR2_TOOLCHAIN_HAS_OPENMP),y)
 TOOLCHAIN_EXTERNAL_LIBS += libgomp.so.*
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_DLANG),y)
+TOOLCHAIN_EXTERNAL_LIBS += libgdruntime.so* libgphobos.so*
+endif
+
 TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
 
 
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +0 -0
index 83d9ed61d7..f686cb3305 100644
@@ -415,6 +415,14 @@ config BR2_TOOLCHAIN_EXTERNAL_CXX
 	  support. If you don't know, leave the default value,

toolchain/toolchain-external/toolchain-external-custom/Config.in.options config BR2_TOOLCHAIN_EXTERNAL_CXX · line 425

Quoted 10 lines
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +8 -0
 	  Buildroot will tell you if it's correct or not.
 
+config BR2_TOOLCHAIN_EXTERNAL_DLANG
+	bool "Toolchain has D support?"
+	select BR2_TOOLCHAIN_HAS_DLANG
+	help
+	  Select this option if your external toolchain has D
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+

I believe we need to add a check in the toolchain helper to check if D compiler is present and is working (as for other language C++ and Fortran [1])

Also D support should be listed in the manual, at least in the "dependencies target toolchain options" [2].

While adding GCC 9 in Buildroot, I did not add D support because there is currently not package using it. Did you plan to add new packages using this language?

[1]:
https://git.buildroot.net/buildroot/tree/toolchain/helpers.mk?id=03fb00f2175cdb4565e26fcb9b3da1c1059de1bd#n339

[2] http://nightly.buildroot.org/manual.html#dependencies-target-toolchain-options

Best regards,
Romain

Quoted 4 lines
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +0 -0
 config BR2_TOOLCHAIN_EXTERNAL_FORTRAN
 	bool "Toolchain has Fortran support?"
 	select BR2_TOOLCHAIN_HAS_FORTRAN
#7 lore raw

PATCH v2 3/3 toolchain-external: add support for D language

Hi!

Quoted 44 lines · Romain Naour

Hi Eric,

Le 24/10/2019 ? 20:16, Eric Le Bihan a ?crit?:

Quoted 27 lines
---
 toolchain/toolchain-external/pkg-toolchain-external.mk    | 4 ++++
 .../toolchain-external-custom/Config.in.options           | 8 ++++++++
 2 files changed, 12 insertions(+)
toolchain/toolchain-external/pkg-toolchain-external.mk +4 -0
index c00211d59c..9c5321ea36 100644
@@ -148,6 +148,10 @@ ifeq ($(BR2_TOOLCHAIN_HAS_OPENMP),y)
 TOOLCHAIN_EXTERNAL_LIBS += libgomp.so.*
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_DLANG),y)
+TOOLCHAIN_EXTERNAL_LIBS += libgdruntime.so* libgphobos.so*
+endif
+
 TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
 
 
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +0 -0
index 83d9ed61d7..f686cb3305 100644
@@ -415,6 +415,14 @@ config BR2_TOOLCHAIN_EXTERNAL_CXX
 	  support. If you don't know, leave the default value,

toolchain/toolchain-external/toolchain-external-custom/Config.in.options config BR2_TOOLCHAIN_EXTERNAL_CXX · line 425

Quoted 10 lines
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +8 -0
 	  Buildroot will tell you if it's correct or not.
 
+config BR2_TOOLCHAIN_EXTERNAL_DLANG
+	bool "Toolchain has D support?"
+	select BR2_TOOLCHAIN_HAS_DLANG
+	help
+	  Select this option if your external toolchain has D
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+

I believe we need to add a check in the toolchain helper to check if D compiler is present and is working (as for other language C++ and Fortran [1])

Quoted 2 lines

Also D support should be listed in the manual, at least in the "dependencies target toolchain options" [2].

OK. It will be added in the next version.

Quoted 3 lines

While adding GCC 9 in Buildroot, I did not add D support because there is currently not package using it. Did you plan to add new packages using this language?

The D programming language has no "killer" application and may be considered as a niche programming language given that the reference compiler (DMD) was only targeting x86 and was not fully open-source until recently. But GDC (GCC-based compiler) and LDC (LLVM-based compiler) broaden the scope and may increase interest for this language.

DUB [1] the package and build manager is written in D. So adding a package to build it from source would require having a host variant of GDC at hand or providing one (which is kind of cumbersome). It is possible, though, to provide a package of the binary host variant of DUB (host-dub-bin), not unlike host-{rust,cargo}-bin for Rust.

Meson also supports D.

One popular program written in D is Vibe.d [2], a web and concurrency framework. Unfortunately, it relies on RDMD [3], a front-end to DMD for running D programs like scripts, which is not compatible with GDC.

GtkD [4], the binding for Gtk+, on the other hand, uses Make as its build system and is more GDC-friendly. Latest attempt at cross-compiling it ended up with some errors, but these should be fixable.

So, no new packages using D on the horizon ATM. I submitted this series because I think one of Buildroot's strengths is its ability to easily provide tools for embedded systems. So having a D cross-compiler at hand may benefit some users for creating new applications.

Thanks for the review!

[1] https://code.dlang.org/packages/dub
[2] https://vibed.org/
[3] https://dlang.org/rdmd.html
[4] https://gtkd.org/

Regards,

--
ELB

#8 lore raw

PATCH v2 3/3 toolchain-external: add support for D language

In reply to Eric Le Bihan

toolchain/toolchain-external/toolchain-external-custom/Config.in.options config BR2_TOOLCHAIN_EXTERNAL_CXX · line 424

Quoted 7 lines · On Thu, 24 Oct 2019 20:16:21 +0200 Eric Le Bihan <[email protected]>…
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +7 -0
+config BR2_TOOLCHAIN_EXTERNAL_DLANG
+	bool "Toolchain has D support?"
+	select BR2_TOOLCHAIN_HAS_DLANG
+	help
+	  Select this option if your external toolchain has D
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.

This last sentence is not actually true: Buildroot doesn't check if there is a really a D compiler in the external toolchain, as Romain pointed out. So I've dropped this last sentence, and applied.

Could you send follow-up patches to address the limitations/issues that Romain has raised ?

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com