Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] libuecc: add new package
@ 2015-10-29  7:13 Alexander Dahl
  2015-10-29  7:13 ` [Buildroot] [PATCH 2/2] fastd: " Alexander Dahl
  2015-11-04 20:48 ` [Buildroot] [PATCH 1/2] libuecc: " Thomas Petazzoni
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Dahl @ 2015-10-29  7:13 UTC (permalink / raw)
  To: buildroot

This package is a small library used for the Freifunk Gluon project and
will be used by other upcoming packages. It's my first buildroot package
and I tried to follow the documentation as close as possible, however as
you might suppose I'm open for any suggestions.

Signed-off-by: Alexander Dahl <post@lespocky.de>
---
 package/Config.in          |  1 +
 package/libuecc/Config.in  |  6 ++++++
 package/libuecc/libuecc.mk | 13 +++++++++++++
 3 files changed, 20 insertions(+)
 create mode 100644 package/libuecc/Config.in
 create mode 100644 package/libuecc/libuecc.mk

diff --git a/package/Config.in b/package/Config.in
index 10ff94e..64b7b50 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -763,6 +763,7 @@ menu "Crypto"
 	source "package/libsodium/Config.in"
 	source "package/libssh/Config.in"
 	source "package/libssh2/Config.in"
+	source "package/libuecc/Config.in"
 	source "package/nettle/Config.in"
 	source "package/openssl/Config.in"
 	source "package/polarssl/Config.in"
diff --git a/package/libuecc/Config.in b/package/libuecc/Config.in
new file mode 100644
index 0000000..8922898
--- /dev/null
+++ b/package/libuecc/Config.in
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_LIBUECC
+	bool "libuecc"
+	help
+	  Very small Elliptic Curve Cryptography library
+	
+	  http://git.universe-factory.net/libuecc
diff --git a/package/libuecc/libuecc.mk b/package/libuecc/libuecc.mk
new file mode 100644
index 0000000..bddb7d5
--- /dev/null
+++ b/package/libuecc/libuecc.mk
@@ -0,0 +1,13 @@
+################################################################################
+#
+# libuecc
+#
+################################################################################
+
+LIBUECC_VERSION = v6
+LIBUECC_SITE = git://git.universe-factory.net/libuecc
+LIBUECC_LICENSE = BSD-2c
+LIBUECC_LICENSE_FILES = COPYRIGHT
+LIBUECC_INSTALL_STAGING = YES
+
+$(eval $(cmake-package))
-- 
2.1.4

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

* [Buildroot] [PATCH 2/2] fastd: add new package
  2015-10-29  7:13 [Buildroot] [PATCH 1/2] libuecc: add new package Alexander Dahl
@ 2015-10-29  7:13 ` Alexander Dahl
  2015-11-04 21:21   ` Thomas Petazzoni
  2015-11-04 20:48 ` [Buildroot] [PATCH 1/2] libuecc: " Thomas Petazzoni
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Dahl @ 2015-10-29  7:13 UTC (permalink / raw)
  To: buildroot

This is a new package for the fastd "Fast and Secure Tunneling Daemon"
which was developed for the Freifunk Gluon project in the first place.
It's one of my first buildroot packages and I tried to follow the
developer guide, if something can be improved I'm open for suggestions.
I hope I covered the necessary build options and set reasonable
defaults. Included is a patch to allow cross compiling with toolchains
without LTO support which fails with the unpatched version due to some
ugly cmake hacks in fastd v17, details in the patch.

Signed-off-by: Alexander Dahl <post@lespocky.de>
---
Compiles succesfully with the following default configs:
* beaglebone_defconfig
* cubieboard_defconfig
* qemu_x86_64_defconfig
* qemu_x86_defconfig
* raspberrypi2_defconfig
* raspberrypi_defconfig
* wandboard_defconfig
---
 package/Config.in                                  |  1 +
 ...NTERPROCEDURAL_OPTIMIZATION-target-proper.patch | 84 ++++++++++++++++++++++
 package/fastd/Config.in                            | 30 ++++++++
 package/fastd/fastd.mk                             | 40 +++++++++++
 4 files changed, 155 insertions(+)
 create mode 100644 package/fastd/0001-cmake-use-INTERPROCEDURAL_OPTIMIZATION-target-proper.patch
 create mode 100644 package/fastd/Config.in
 create mode 100644 package/fastd/fastd.mk

diff --git a/package/Config.in b/package/Config.in
index 64b7b50..a868798 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1249,6 +1249,7 @@ endif
 	source "package/ejabberd/Config.in"
 	source "package/ethtool/Config.in"
 	source "package/faifa/Config.in"
+	source "package/fastd/Config.in"
 	source "package/fcgiwrap/Config.in"
 	source "package/fmc/Config.in"
 	source "package/foomatic-filters/Config.in"
diff --git a/package/fastd/0001-cmake-use-INTERPROCEDURAL_OPTIMIZATION-target-proper.patch b/package/fastd/0001-cmake-use-INTERPROCEDURAL_OPTIMIZATION-target-proper.patch
new file mode 100644
index 0000000..99d20c6
--- /dev/null
+++ b/package/fastd/0001-cmake-use-INTERPROCEDURAL_OPTIMIZATION-target-proper.patch
@@ -0,0 +1,84 @@
+From: Alexander Dahl <alex@netz39.de>
+Date: Wed, 28 Oct 2015 16:04:13 +0100
+Subject: [PATCH] cmake: use INTERPROCEDURAL_OPTIMIZATION target property
+
+Instead of hacking on compiler flags use the cmake way for handling
+interprocedural optimization. Tests showed cmake currently ignores this
+for gcc and clang, at least on Debian Wheezy and Jessie. This actually
+results in no interprocedural optimization for the moment. However it
+allows to compile fastd against a toolchain without LTO support, which
+was broken because of a hack included here for finding binutils.
+
+According to the upstream author of fastd the main reason for enabling
+LTO was binary size on an OpenWRT target for Freifunk Gluon, where they
+have very few space left on devices with only 4 MB flash memory.
+
+Signed-off-by: Alexander Dahl <post@lespocky.de>
+---
+ cmake/CMakeFindBinUtils.cmake |  7 -------
+ cmake/checks.cmake            | 14 --------------
+ src/CMakeLists.txt            |  9 +++++++++
+ 3 files changed, 9 insertions(+), 21 deletions(-)
+ delete mode 100644 cmake/CMakeFindBinUtils.cmake
+
+diff --git a/cmake/CMakeFindBinUtils.cmake b/cmake/CMakeFindBinUtils.cmake
+deleted file mode 100644
+index 753577a..0000000
+--- a/cmake/CMakeFindBinUtils.cmake
++++ /dev/null
+@@ -1,7 +0,0 @@
+-if(CMAKE_COMPILER_IS_GNUCC)
+-  find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+-  find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+-  find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+-endif(CMAKE_COMPILER_IS_GNUCC)
+-
+-include(${CMAKE_ROOT}/Modules/CMakeFindBinUtils.cmake)
+diff --git a/cmake/checks.cmake b/cmake/checks.cmake
+index f9f0399..3c1f38b 100644
+--- a/cmake/checks.cmake
++++ b/cmake/checks.cmake
+@@ -10,20 +10,6 @@ if(ARCH_X86 OR ARCH_X86_64)
+ endif(ARCH_X86 OR ARCH_X86_64)
+ 
+ 
+-
+-if(ENABLE_LTO)
+-  set(CFLAGS_LTO "-flto")
+-  set(CFLAGS_NO_LTO "-fno-lto")
+-
+-  check_c_compiler_flag("-fwhole-program" HAVE_FLAG_WHOLE_PROGRAM)
+-  if(HAVE_FLAG_WHOLE_PROGRAM)
+-    set(LDFLAGS_LTO "-flto -fwhole-program")
+-  else(HAVE_FLAG_WHOLE_PROGRAM)
+-    set(LDFLAGS_LTO "-flto")
+-  endif(HAVE_FLAG_WHOLE_PROGRAM)
+-endif(ENABLE_LTO)
+-
+-
+ check_c_source_compiles("
+ #include <sys/types.h>
+ #include <sys/socket.h>
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index e7dd5d1..4991656 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -47,6 +47,15 @@ add_executable(fastd
+ set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
+ set_property(TARGET fastd PROPERTY LINK_FLAGS "${PTHREAD_LDFLAGS} ${UECC_LDFLAGS_OTHER} ${NACL_LDFLAGS_OTHER} ${OPENSSL_CRYPTO_LDFLAGS_OTHER} ${JSONC_LDFLAGS_OTHER} ${LDFLAGS_LTO}")
+ set_property(TARGET fastd APPEND PROPERTY INCLUDE_DIRECTORIES ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS} ${JSONC_INCLUDE_DIRS})
++if(ENABLE_LTO)
++	set_target_properties(fastd PROPERTIES
++		INTERPROCEDURAL_OPTIMIZATION ON
++	)
++else(ENABLE_LTO)
++	set_target_properties(fastd PROPERTIES
++		INTERPROCEDURAL_OPTIMIZATION OFF
++	)
++endif(ENABLE_LTO)
+ target_link_libraries(fastd protocols methods ciphers macs ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} ${JSONC_LIBRARIES})
+ 
+ add_dependencies(fastd version)
+-- 
+2.1.4
+
diff --git a/package/fastd/Config.in b/package/fastd/Config.in
new file mode 100644
index 0000000..9b3dfe2
--- /dev/null
+++ b/package/fastd/Config.in
@@ -0,0 +1,30 @@
+config BR2_PACKAGE_FASTD
+	bool "fastd"
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_LIBUECC
+	select BR2_PACKAGE_LIBSODIUM
+	select BR2_PACKAGE_LIBCAP
+	help
+	  Fast and Secure Tunneling Daemon
+	
+	  https://projects.universe-factory.net/projects/fastd/wiki
+
+if BR2_PACKAGE_FASTD
+
+config BR2_PACKAGE_FASTD_OPENSSL
+	bool "OpenSSL support"
+	select BR2_PACKAGE_OPENSSL
+	help
+	  Build with OpenSSL support.
+
+config BR2_PACKAGE_FASTD_STATUS_SOCKET
+	bool "with status socket"
+	default y
+	select BR2_PACKAGE_JSON_C
+	help
+	  Enable support for a socket to get fastd's status.
+
+endif
+
+comment "fastd needs a toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/fastd/fastd.mk b/package/fastd/fastd.mk
new file mode 100644
index 0000000..a6a1f63
--- /dev/null
+++ b/package/fastd/fastd.mk
@@ -0,0 +1,40 @@
+################################################################################
+#
+# fastd
+#
+################################################################################
+
+FASTD_VERSION = v17
+FASTD_SITE = git://git.universe-factory.net/fastd
+FASTD_LICENSE = BSD-2c
+FASTD_LICENSE_FILES = COPYRIGHT
+FASTD_CONF_OPTS = -DENABLE_LIBSODIUM=ON -DWITH_CAPABILITIES=TRUE
+FASTD_DEPENDENCIES = libuecc libsodium libcap
+
+ifeq ($(BR2_PACKAGE_OPENSSL),y)
+FASTD_CONF_OPTS += -DENABLE_OPENSSL=ON
+FASTD_DEPENDENCIES += openssl
+else
+FASTD_CONF_OPTS += -DENABLE_OPENSSL=OFF
+endif
+
+ifeq ($(BR2_PACKAGE_FASTD_STATUS_SOCKET),y)
+FASTD_CONF_OPTS += -DWITH_STATUS_SOCKET=TRUE
+FASTD_DEPENDENCIES += json-c
+else
+FASTD_CONF_OPTS += -DWITH_STATUS_SOCKET=FALSE
+endif
+
+ifeq ($(BR2_INIT_SYSTEMD),y)
+FASTD_CONF_OPTS += -DENABLE_SYSTEMD=ON
+else
+FASTD_CONF_OPTS += -DENABLE_SYSTEMD=OFF
+endif
+
+ifeq ($(BR2_GCC_ENABLE_LTO),y)
+FASTD_CONF_OPTS += -DENABLE_LTO=ON
+else
+FASTD_CONF_OPTS += -DENABLE_LTO=OFF
+endif
+
+$(eval $(cmake-package))
-- 
2.1.4

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

* [Buildroot] [PATCH 1/2] libuecc: add new package
  2015-10-29  7:13 [Buildroot] [PATCH 1/2] libuecc: add new package Alexander Dahl
  2015-10-29  7:13 ` [Buildroot] [PATCH 2/2] fastd: " Alexander Dahl
@ 2015-11-04 20:48 ` Thomas Petazzoni
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Petazzoni @ 2015-11-04 20:48 UTC (permalink / raw)
  To: buildroot

Dear Alexander Dahl,

On Thu, 29 Oct 2015 08:13:01 +0100, Alexander Dahl wrote:
> This package is a small library used for the Freifunk Gluon project and
> will be used by other upcoming packages. It's my first buildroot package
> and I tried to follow the documentation as close as possible, however as
> you might suppose I'm open for any suggestions.
> 
> Signed-off-by: Alexander Dahl <post@lespocky.de>
> ---
>  package/Config.in          |  1 +
>  package/libuecc/Config.in  |  6 ++++++
>  package/libuecc/libuecc.mk | 13 +++++++++++++
>  3 files changed, 20 insertions(+)
>  create mode 100644 package/libuecc/Config.in
>  create mode 100644 package/libuecc/libuecc.mk

I've applied your patch, thanks! There were two minor issues:

 - The commit log should not contain some "personal" messages such as
   "It's my first buildroot package...". The contents of the commit log
   is kept forever in the project history. If you want to include such
   "personal/contextual" messages, put them either in a separate e-mail
   (called the cover letter) or under the --- sign below the
   Signed-off-by line.

 - There was a line with trailing spaces in Config.in.

Other than that, looked good to, so applied!

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 2/2] fastd: add new package
  2015-10-29  7:13 ` [Buildroot] [PATCH 2/2] fastd: " Alexander Dahl
@ 2015-11-04 21:21   ` Thomas Petazzoni
  2015-11-05  8:31     ` Alexander Dahl
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2015-11-04 21:21 UTC (permalink / raw)
  To: buildroot

Dear Alexander Dahl,

On Thu, 29 Oct 2015 08:13:02 +0100, Alexander Dahl wrote:
> This is a new package for the fastd "Fast and Secure Tunneling Daemon"
> which was developed for the Freifunk Gluon project in the first place.
> It's one of my first buildroot packages and I tried to follow the
> developer guide, if something can be improved I'm open for suggestions.
> I hope I covered the necessary build options and set reasonable
> defaults. Included is a patch to allow cross compiling with toolchains
> without LTO support which fails with the unpatched version due to some
> ugly cmake hacks in fastd v17, details in the patch.

This commit log again contained some "personal" messages, so I reworded
it.

I also did a few other changes:

    [Thomas:
     - Get rid of trailing spaces in Config.in
     - Remove the BR2_PACKAGE_FASTD_OPENSSL, and simply rely on
       BR2_PACKAGE_OPENSSL
     - Remove -DWITH_CAPABILITIES=TRUE, since libcap support is anyway
       mandatory.
     - Use ON/OFF instead of TRUE/FALSE.]

and then applied your patch.

Could you submit your LTO related patch to the upstream project and get it merged, so that next time we update the fastd package we can get rid of the patch?

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 2/2] fastd: add new package
  2015-11-04 21:21   ` Thomas Petazzoni
@ 2015-11-05  8:31     ` Alexander Dahl
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Dahl @ 2015-11-05  8:31 UTC (permalink / raw)
  To: buildroot

Hei Thomas,

Am 2015-11-04 22:21, schrieb Thomas Petazzoni:
> This commit log again contained some "personal" messages, so I reworded
> it.

Okay, I understand. :-)

> I also did a few other changes:
> 
>     [Thomas:
>      - Get rid of trailing spaces in Config.in

Sorry, I usually check this before committing. :-/

>      - Remove the BR2_PACKAGE_FASTD_OPENSSL, and simply rely on
>        BR2_PACKAGE_OPENSSL

I'm not sure if I like this, because it is less flexible, but if this is
common practice in buildroot, okay.

>      - Remove -DWITH_CAPABILITIES=TRUE, since libcap support is anyway
>        mandatory.

Buildroot builds only Linux based systems, right? Then fastd sets this
to ON by itself in cmake/config.cmake so it can be removed, okay.

> Could you submit your LTO related patch to the upstream project and
> get it merged, so that next time we update the fastd package we can
> get rid of the patch?

I suppose the upstream author will not apply it. I had a somewhat long
discussion in IRC with him. As stated in the patch his goal is to use
LTO to reduce binary size (binaries compiled with lto are actually
smaller and on a device with 4 MB flash this matters). However the cmake
approach (as I understood the cmake docs, which are very thin on this
topic) is like presented in my patch (which in fact does not work, but I
would just wait for an upcoming cmake version getting this right). 

What I tried first was just setting -DENABLE_LTO=OFF which was not
enough, compiling failed, because of the cmake hacks included in fastd
choosing wrong binutils. This hack is removed by my patch. In OpenWRT
the fastd author got a patch upstream enabling the plugins option in the
toolchain. I assumed this would not work with buildroot where you have
fine grained options to configure the toolchain.

Another option would for the fastd buildroot package could be to require
a toolchain with LTO support and just enable the related cmake option.

Thanks for review. :-)

Alex

-- 
?With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.? (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***

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

end of thread, other threads:[~2015-11-05  8:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29  7:13 [Buildroot] [PATCH 1/2] libuecc: add new package Alexander Dahl
2015-10-29  7:13 ` [Buildroot] [PATCH 2/2] fastd: " Alexander Dahl
2015-11-04 21:21   ` Thomas Petazzoni
2015-11-05  8:31     ` Alexander Dahl
2015-11-04 20:48 ` [Buildroot] [PATCH 1/2] libuecc: " Thomas Petazzoni

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