diff mbox series

[4/5] package/openmpi-examples: new package

Message ID 20230207220941.58066-4-ju.o@free.fr
State Changes Requested
Headers show
Series [1/5] DEVELOPERS: add Julien Olivain for package/openmpi | expand

Commit Message

Julien Olivain Feb. 7, 2023, 10:09 p.m. UTC
This is a "meta" package reusing definitions and files from openmpi.
Openmpi examples are shipped in the main library sources, including
build wrappers. The library and the wrappers need to be built and
installed in staging prior trying to compile an example. This purpose if
this package is to handle cleanly those dependencies.

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 package/openmpi-examples/Config.in            |  8 +++++
 .../openmpi-examples/openmpi-examples.hash    |  1 +
 package/openmpi-examples/openmpi-examples.mk  | 29 +++++++++++++++++++
 5 files changed, 40 insertions(+)
 create mode 100644 package/openmpi-examples/Config.in
 create mode 120000 package/openmpi-examples/openmpi-examples.hash
 create mode 100644 package/openmpi-examples/openmpi-examples.mk

Comments

Thomas Petazzoni Feb. 21, 2023, 9:12 a.m. UTC | #1
Hello Julien,

On Tue,  7 Feb 2023 23:09:40 +0100
Julien Olivain <ju.o@free.fr> wrote:

> diff --git a/package/openmpi-examples/Config.in b/package/openmpi-examples/Config.in
> new file mode 100644
> index 0000000000..caaa02d802
> --- /dev/null
> +++ b/package/openmpi-examples/Config.in
> @@ -0,0 +1,8 @@
> +config BR2_PACKAGE_OPENMPI_EXAMPLES
> +	bool "openmpi-examples"
> +	select BR2_PACKAGE_OPENMPI
> +	help
> +	  This package includes the hello_c example from openmpi. It
> +	  is mainly used as a simple openmpi program to test the
> +	  libraries. It is also a recipe example for cross compiling
> +	  an openmpi program with the mpicc wrappers.
> diff --git a/package/openmpi-examples/openmpi-examples.hash b/package/openmpi-examples/openmpi-examples.hash
> new file mode 120000
> index 0000000000..b8afe5e2d9
> --- /dev/null
> +++ b/package/openmpi-examples/openmpi-examples.hash
> @@ -0,0 +1 @@
> +../openmpi/openmpi.hash
> \ No newline at end of file
> diff --git a/package/openmpi-examples/openmpi-examples.mk b/package/openmpi-examples/openmpi-examples.mk
> new file mode 100644
> index 0000000000..be679333c7
> --- /dev/null
> +++ b/package/openmpi-examples/openmpi-examples.mk
> @@ -0,0 +1,29 @@
> +################################################################################
> +#
> +# openmpi-examples
> +#
> +################################################################################
> +
> +OPENMPI_EXAMPLES_VERSION = $(OPENMPI_VERSION)
> +OPENMPI_EXAMPLES_SOURCE = $(OPENMPI_SOURCE)
> +OPENMPI_EXAMPLES_DL_SUBDIR = openmpi
> +OPENMPI_EXAMPLES_SITE = $(OPENMPI_SITE)
> +OPENMPI_EXAMPLES_LICENSE = $(OPENMPI_LINCENSE)
> +OPENMPI_EXAMPLES_LICENSE_FILES = $(OPENMPI_LICENSE_FILES)

Why is this a separate package? If those examples come with openmpi,
then building the examples should be a suboption of the openmpi package.

> +OPENMPI_EXAMPLES_DEPENDENCIES = openmpi
> +
> +define OPENMPI_EXAMPLES_BUILD_CMDS
> +	$(TARGET_MAKE_ENV) PATH=$(STAGING_DIR)/usr/bin:$(BR_PATH) OPAL_DESTDIR=$(STAGING_DIR)/usr \

Adding $(STAGING_DIR)/usr/bin in the PATH is a bad idea, as it contains
a lot of tools/binaries cross-compiled for the target.

> +	mpicc \
> +		$(TARGET_CFLAGS) $(TARGET_LDFLAGS) \
> +		-o $(@D)/examples/hello_c \
> +		$(@D)/examples/hello_c.c

So either, we need to change things so that mpicc is installed to
$(HOST_DIR), or you need to invoke it as $(STAGING_DIR)/usr/bin/mpicc.

Thanks!

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 156c5dac13..3d1c3a2a83 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1690,6 +1690,7 @@  F:	package/glslsandbox-player/
 F:	package/octave/
 F:	package/ola/
 F:	package/openmpi/
+F:	package/openmpi-examples/
 F:	package/perftest/
 F:	package/ptm2human/
 F:	package/python-distro/
diff --git a/package/Config.in b/package/Config.in
index 06d0a05854..e08511fd9a 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1961,6 +1961,7 @@  menu "Networking"
 	source "package/open62541/Config.in"
 	source "package/openldap/Config.in"
 	source "package/openmpi/Config.in"
+	source "package/openmpi-examples/Config.in"
 	source "package/openpgm/Config.in"
 	source "package/openzwave/Config.in"
 	source "package/ortp/Config.in"
diff --git a/package/openmpi-examples/Config.in b/package/openmpi-examples/Config.in
new file mode 100644
index 0000000000..caaa02d802
--- /dev/null
+++ b/package/openmpi-examples/Config.in
@@ -0,0 +1,8 @@ 
+config BR2_PACKAGE_OPENMPI_EXAMPLES
+	bool "openmpi-examples"
+	select BR2_PACKAGE_OPENMPI
+	help
+	  This package includes the hello_c example from openmpi. It
+	  is mainly used as a simple openmpi program to test the
+	  libraries. It is also a recipe example for cross compiling
+	  an openmpi program with the mpicc wrappers.
diff --git a/package/openmpi-examples/openmpi-examples.hash b/package/openmpi-examples/openmpi-examples.hash
new file mode 120000
index 0000000000..b8afe5e2d9
--- /dev/null
+++ b/package/openmpi-examples/openmpi-examples.hash
@@ -0,0 +1 @@ 
+../openmpi/openmpi.hash
\ No newline at end of file
diff --git a/package/openmpi-examples/openmpi-examples.mk b/package/openmpi-examples/openmpi-examples.mk
new file mode 100644
index 0000000000..be679333c7
--- /dev/null
+++ b/package/openmpi-examples/openmpi-examples.mk
@@ -0,0 +1,29 @@ 
+################################################################################
+#
+# openmpi-examples
+#
+################################################################################
+
+OPENMPI_EXAMPLES_VERSION = $(OPENMPI_VERSION)
+OPENMPI_EXAMPLES_SOURCE = $(OPENMPI_SOURCE)
+OPENMPI_EXAMPLES_DL_SUBDIR = openmpi
+OPENMPI_EXAMPLES_SITE = $(OPENMPI_SITE)
+OPENMPI_EXAMPLES_LICENSE = $(OPENMPI_LINCENSE)
+OPENMPI_EXAMPLES_LICENSE_FILES = $(OPENMPI_LICENSE_FILES)
+
+OPENMPI_EXAMPLES_DEPENDENCIES = openmpi
+
+define OPENMPI_EXAMPLES_BUILD_CMDS
+	$(TARGET_MAKE_ENV) PATH=$(STAGING_DIR)/usr/bin:$(BR_PATH) OPAL_DESTDIR=$(STAGING_DIR)/usr \
+	mpicc \
+		$(TARGET_CFLAGS) $(TARGET_LDFLAGS) \
+		-o $(@D)/examples/hello_c \
+		$(@D)/examples/hello_c.c
+endef
+
+define OPENMPI_EXAMPLES_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/examples/hello_c \
+		$(TARGET_DIR)/usr/bin/ompi_hello_c
+endef
+
+$(eval $(generic-package))