* [Buildroot] [PATCH 1/2] iperf: fix build on !MMU platforms
@ 2012-05-07 16:39 Thomas Petazzoni
2012-05-07 16:39 ` [Buildroot] [PATCH 2/2] dropbear: fix " Thomas Petazzoni
2012-05-07 20:47 ` [Buildroot] [PATCH 1/2] iperf: fix build " Peter Korsgaard
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2012-05-07 16:39 UTC (permalink / raw)
To: buildroot
Build tested on sh2a and blackfin architectures.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
package/iperf/iperf-add-pthread.patch | 25 +++++++++++++++
package/iperf/iperf-man-installation.patch | 15 +++++++++
package/iperf/iperf-no-mmu.patch | 48 ++++++++++++++++++++++++++++
package/iperf/iperf.mk | 2 +-
4 files changed, 89 insertions(+), 1 deletion(-)
create mode 100644 package/iperf/iperf-add-pthread.patch
create mode 100644 package/iperf/iperf-man-installation.patch
create mode 100644 package/iperf/iperf-no-mmu.patch
diff --git a/package/iperf/iperf-add-pthread.patch b/package/iperf/iperf-add-pthread.patch
new file mode 100644
index 0000000..4997b75
--- /dev/null
+++ b/package/iperf/iperf-add-pthread.patch
@@ -0,0 +1,25 @@
+Fix pthread link problem
+
+Some toolchains support linking against pthread by passing
+-pthread. For such toolchains, iperf was working because
+ at PTHREAD_CFLAGS@ was used.
+
+However, some other toolchains (ex: Renesas 2010.09) requires passing
+-lpthread to link against the pthread library. And this was breaking
+in iperf because @PTHREAD_LIBS@ wasn't used. We fix this here.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/src/Makefile.am
+===================================================================
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -12,7 +12,7 @@
+ AM_CXXFLAGS = -Wall
+ AM_CFLAGS = -Wall
+
+-iperf_LDFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @WEB100_CFLAGS@ @DEFS@
++iperf_LDFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ @WEB100_CFLAGS@ @DEFS@
+
+ iperf_SOURCES = \
+ Client.cpp \
diff --git a/package/iperf/iperf-man-installation.patch b/package/iperf/iperf-man-installation.patch
new file mode 100644
index 0000000..7c63b2d
--- /dev/null
+++ b/package/iperf/iperf-man-installation.patch
@@ -0,0 +1,15 @@
+Fix man installation
+
+Using man_MANS and dist_man_MANS is redundant, and makes the Makefile
+try to install twice the iperf.1 manpage, which fails.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/man/Makefile.am
+===================================================================
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,2 +1 @@
+-man_MANS = iperf.1
+-dist_man_MANS = $(man_MANS)
++dist_man_MANS = iperf.1
diff --git a/package/iperf/iperf-no-mmu.patch b/package/iperf/iperf-no-mmu.patch
new file mode 100644
index 0000000..b9f89b2
--- /dev/null
+++ b/package/iperf/iperf-no-mmu.patch
@@ -0,0 +1,48 @@
+Add support for building in no-MMU mode
+
+This adds a check for the fork() function in configure.ac, then
+conditionnally calls either fork() or vfork() depending on which one
+is available.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -66,6 +66,7 @@
+ dnl check for -lnsl, -lsocket
+ AC_CHECK_FUNC(gethostbyname,,AC_CHECK_LIB(nsl, gethostbyname))
+ AC_CHECK_FUNC(socket,,AC_CHECK_LIB(socket, socket))
++AC_CHECK_FUNC(fork)
+
+ dnl Checks for header files.
+ AC_HEADER_STDC
+Index: b/src/Listener.cpp
+===================================================================
+--- a/src/Listener.cpp
++++ b/src/Listener.cpp
+@@ -679,7 +679,11 @@
+ pid_t pid;
+
+ /* Create a child process & if successful, exit from the parent process */
++#ifndef HAVE_FORK
++ if ( (pid = vfork()) == -1 ) {
++#else
+ if ( (pid = fork()) == -1 ) {
++#endif
+ fprintf( stderr, "error in first child create\n");
+ exit(0);
+ } else if ( pid != 0 ) {
+@@ -695,7 +699,11 @@
+
+
+ /* Now fork() and get released from the terminal */
++#ifndef HAVE_FORK
++ if ( (pid = vfork()) == -1 ) {
++#else
+ if ( (pid = fork()) == -1 ) {
++#endif
+ fprintf( stderr, "error\n");
+ exit(0);
+ } else if ( pid != 0 ) {
diff --git a/package/iperf/iperf.mk b/package/iperf/iperf.mk
index 26cd3fb..614f8f6 100644
--- a/package/iperf/iperf.mk
+++ b/package/iperf/iperf.mk
@@ -6,7 +6,7 @@
IPERF_VERSION = 2.0.5
IPERF_SOURCE = iperf-$(IPERF_VERSION).tar.gz
IPERF_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/iperf
-
+IPERF_AUTORECONF = YES
IPERF_CONF_ENV = \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_type_bool=yes \
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 2/2] dropbear: fix on !MMU platforms
2012-05-07 16:39 [Buildroot] [PATCH 1/2] iperf: fix build on !MMU platforms Thomas Petazzoni
@ 2012-05-07 16:39 ` Thomas Petazzoni
2012-05-07 20:47 ` [Buildroot] [PATCH 1/2] iperf: fix build " Peter Korsgaard
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2012-05-07 16:39 UTC (permalink / raw)
To: buildroot
Build tested for sh2a and blackfin.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
package/dropbear/dropbear-better-fork-test.patch | 232 ++++++++++++++++++++++
package/dropbear/dropbear-no-mmu.patch | 21 ++
package/dropbear/dropbear.mk | 1 +
3 files changed, 254 insertions(+)
create mode 100644 package/dropbear/dropbear-better-fork-test.patch
create mode 100644 package/dropbear/dropbear-no-mmu.patch
diff --git a/package/dropbear/dropbear-better-fork-test.patch b/package/dropbear/dropbear-better-fork-test.patch
new file mode 100644
index 0000000..d7a8a66
--- /dev/null
+++ b/package/dropbear/dropbear-better-fork-test.patch
@@ -0,0 +1,232 @@
+Upstream patch, will be part of the next Dropbear release.
+
+# HG changeset patch
+# User Mike Frysinger <vapier@gentoo.org>
+# Date 1333864252 14400
+# Node ID 0ad95abf8d3c78d16203fa6e3609fccfdb1effba
+# Parent 4d9511f98462cf1fdcc9f657534669fd4dc571bd
+check for fork() and not __uClinux__
+
+diff -r 4d9511f98462 -r 0ad95abf8d3c configure.in
+--- a/configure.in Sun Apr 08 02:06:54 2012 -0400
++++ b/configure.in Sun Apr 08 01:50:52 2012 -0400
+@@ -616,7 +616,7 @@
+ AC_FUNC_MEMCMP
+ AC_FUNC_SELECT_ARGTYPES
+ AC_TYPE_SIGNAL
+-AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo])
++AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo fork])
+
+ AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
+
+diff -r 4d9511f98462 -r 0ad95abf8d3c dbutil.c
+--- a/dbutil.c Sun Apr 08 02:06:54 2012 -0400
++++ b/dbutil.c Sun Apr 08 01:50:52 2012 -0400
+@@ -443,7 +443,7 @@
+ return DROPBEAR_FAILURE;
+ }
+
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ pid = vfork();
+ #else
+ pid = fork();
+diff -r 4d9511f98462 -r 0ad95abf8d3c scp.c
+--- a/scp.c Sun Apr 08 02:06:54 2012 -0400
++++ b/scp.c Sun Apr 08 01:50:52 2012 -0400
+@@ -130,22 +130,22 @@
+ fprintf(stderr, " %s", a->list[i]);
+ fprintf(stderr, "\n");
+ }
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ pid = vfork();
+ #else
+ pid = fork();
+-#endif /* __uClinux__ */
++#endif
+ if (pid == -1)
+ fatal("do_local_cmd: fork: %s", strerror(errno));
+
+ if (pid == 0) {
+ execvp(a->list[0], a->list);
+ perror(a->list[0]);
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ _exit(1);
+ #else
+ exit(1);
+-#endif /* __uClinux__ */
++#endif
+ }
+
+ do_cmd_pid = pid;
+@@ -171,6 +171,16 @@
+ * assigns the input and output file descriptors on success.
+ */
+
++static void
++arg_setup(char *host, char *remuser, char *cmd)
++{
++ replacearg(&args, 0, "%s", ssh_program);
++ if (remuser != NULL)
++ addargs(&args, "-l%s", remuser);
++ addargs(&args, "%s", host);
++ addargs(&args, "%s", cmd);
++}
++
+ int
+ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
+ {
+@@ -198,22 +208,18 @@
+ close(reserved[0]);
+ close(reserved[1]);
+
+- /* uClinux needs to build the args here before vforking,
+- otherwise we do it later on. */
+-#ifdef __uClinux__
+- replacearg(&args, 0, "%s", ssh_program);
+- if (remuser != NULL)
+- addargs(&args, "-l%s", remuser);
+- addargs(&args, "%s", host);
+- addargs(&args, "%s", cmd);
+-#endif /* __uClinux__ */
++ /* uClinux needs to build the args here before vforking,
++ otherwise we do it later on. */
++#ifndef HAVE_FORK
++ arg_setup(host, remuser, cmd);
++#endif
+
+ /* Fork a child to execute the command on the remote host using ssh. */
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ do_cmd_pid = vfork();
+ #else
+ do_cmd_pid = fork();
+-#endif /* __uClinux__ */
++#endif
+
+ if (do_cmd_pid == 0) {
+ /* Child. */
+@@ -224,27 +230,22 @@
+ close(pin[0]);
+ close(pout[1]);
+
+-#ifndef __uClinux__
+- replacearg(&args, 0, "%s", ssh_program);
+- if (remuser != NULL)
+- addargs(&args, "-l%s", remuser);
+- addargs(&args, "%s", host);
+- addargs(&args, "%s", cmd);
+-#endif /* __uClinux__ */
++#ifndef HAVE_FORK
++ arg_setup(host, remuser, cmd);
++#endif
+
+ execvp(ssh_program, args.list);
+ perror(ssh_program);
+-#ifndef __uClinux__
++#ifndef HAVE_FORK
++ _exit(1);
++#else
+ exit(1);
+-#else
+- _exit(1);
+-#endif /* __uClinux__ */
++#endif
+ } else if (do_cmd_pid == -1) {
+ fatal("fork: %s", strerror(errno));
+ }
+
+-
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ /* clean up command */
+ /* pop cmd */
+ xfree(args.list[args.num-1]);
+@@ -260,7 +261,7 @@
+ args.list[args.num-1]=NULL;
+ args.num--;
+ }
+-#endif /* __uClinux__ */
++#endif
+
+ /* Parent. Close the other side, and return the local side. */
+ close(pin[0]);
+diff -r 4d9511f98462 -r 0ad95abf8d3c session.h
+--- a/session.h Sun Apr 08 02:06:54 2012 -0400
++++ b/session.h Sun Apr 08 01:50:52 2012 -0400
+@@ -218,7 +218,7 @@
+ /* The resolved remote address, used for lastlog etc */
+ char *remotehost;
+
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ pid_t server_pid;
+ #endif
+
+diff -r 4d9511f98462 -r 0ad95abf8d3c svr-chansession.c
+--- a/svr-chansession.c Sun Apr 08 02:06:54 2012 -0400
++++ b/svr-chansession.c Sun Apr 08 01:50:52 2012 -0400
+@@ -658,7 +658,7 @@
+
+ /* uClinux will vfork(), so there'll be a race as
+ connection_string is freed below. */
+-#ifndef __uClinux__
++#ifdef HAVE_FORK
+ chansess->connection_string = make_connection_string();
+ #endif
+
+@@ -670,7 +670,7 @@
+ ret = ptycommand(channel, chansess);
+ }
+
+-#ifndef __uClinux__
++#ifdef HAVE_FORK
+ m_free(chansess->connection_string);
+ #endif
+
+@@ -745,7 +745,7 @@
+ return DROPBEAR_FAILURE;
+ }
+
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ pid = vfork();
+ #else
+ pid = fork();
+@@ -863,9 +863,9 @@
+ struct ChanSess *chansess = user_data;
+ char *usershell = NULL;
+
+- /* with uClinux we'll have vfork()ed, so don't want to overwrite the
+- * hostkey. can't think of a workaround to clear it */
+-#ifndef __uClinux__
++ /* with uClinux we'll have vfork()ed, so don't want to overwrite the
++ * hostkey. can't think of a workaround to clear it */
++#ifdef HAVE_FORK
+ /* wipe the hostkey */
+ sign_key_free(svr_opts.hostkey);
+ svr_opts.hostkey = NULL;
+diff -r 4d9511f98462 -r 0ad95abf8d3c svr-session.c
+--- a/svr-session.c Sun Apr 08 02:06:54 2012 -0400
++++ b/svr-session.c Sun Apr 08 01:50:52 2012 -0400
+@@ -84,7 +84,7 @@
+
+ /* Initialise server specific parts of the session */
+ svr_ses.childpipe = childpipe;
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ svr_ses.server_pid = getpid();
+ #endif
+ svr_authinitialise();
+@@ -157,7 +157,7 @@
+
+ _dropbear_log(LOG_INFO, fmtbuf, param);
+
+-#ifdef __uClinux__
++#ifndef HAVE_FORK
+ /* only the main server process should cleanup - we don't want
+ * forked children doing that */
+ if (svr_ses.server_pid == getpid())
+
diff --git a/package/dropbear/dropbear-no-mmu.patch b/package/dropbear/dropbear-no-mmu.patch
new file mode 100644
index 0000000..28d1ea3
--- /dev/null
+++ b/package/dropbear/dropbear-no-mmu.patch
@@ -0,0 +1,21 @@
+Fix fork() usage
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/svr-main.c
+===================================================================
+--- a/svr-main.c
++++ b/svr-main.c
+@@ -262,8 +262,12 @@
+ #ifdef DEBUG_NOFORK
+ fork_ret = 0;
+ #else
++#ifndef HAVE_FORK
++ fork_ret = vfork();
++#else
+ fork_ret = fork();
+ #endif
++#endif
+ if (fork_ret < 0) {
+ dropbear_log(LOG_WARNING, "Error forking: %s", strerror(errno));
+ goto out;
diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk
index fea96d6..a5e177c 100644
--- a/package/dropbear/dropbear.mk
+++ b/package/dropbear/dropbear.mk
@@ -9,6 +9,7 @@ DROPBEAR_SITE = http://matt.ucc.asn.au/dropbear/releases
DROPBEAR_TARGET_BINS = dbclient dropbearkey dropbearconvert scp ssh
DROPBEAR_MAKE = $(MAKE) MULTI=1 SCPPROGRESS=1 \
PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"
+DROPBEAR_AUTORECONF = YES
ifeq ($(BR2_PREFER_STATIC_LIB),y)
DROPBEAR_MAKE += STATIC=1
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 1/2] iperf: fix build on !MMU platforms
2012-05-07 16:39 [Buildroot] [PATCH 1/2] iperf: fix build on !MMU platforms Thomas Petazzoni
2012-05-07 16:39 ` [Buildroot] [PATCH 2/2] dropbear: fix " Thomas Petazzoni
@ 2012-05-07 20:47 ` Peter Korsgaard
2012-05-11 20:23 ` Arnout Vandecappelle
1 sibling, 1 reply; 4+ messages in thread
From: Peter Korsgaard @ 2012-05-07 20:47 UTC (permalink / raw)
To: buildroot
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:
Thomas> Build tested on sh2a and blackfin architectures.
Thanks. Have you sent these patches upstream?
Thomas> ++++ b/src/Listener.cpp
Thomas> +@@ -679,7 +679,11 @@
Thomas> + pid_t pid;
Thomas> +
Thomas> + /* Create a child process & if successful, exit from the parent process */
Thomas> ++#ifndef HAVE_FORK
Thomas> ++ if ( (pid = vfork()) == -1 ) {
Thomas> ++#else
Thomas> + if ( (pid = fork()) == -1 ) {
Thomas> ++#endif
Thomas> + fprintf( stderr, "error in first child create\n");
Thomas> + exit(0);
I believe you aren't allowed to call exit() after vfork (but should use
_exit() instead).
http://unix.stackexchange.com/questions/5364/why-should-a-child-of-a-vfork-or-fork-call-exit-instead-of-exit
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 1/2] iperf: fix build on !MMU platforms
2012-05-07 20:47 ` [Buildroot] [PATCH 1/2] iperf: fix build " Peter Korsgaard
@ 2012-05-11 20:23 ` Arnout Vandecappelle
0 siblings, 0 replies; 4+ messages in thread
From: Arnout Vandecappelle @ 2012-05-11 20:23 UTC (permalink / raw)
To: buildroot
On 05/07/12 22:47, Peter Korsgaard wrote:
>>>>>> "Thomas" == Thomas Petazzoni<thomas.petazzoni@free-electrons.com> writes:
>
> Thomas> Build tested on sh2a and blackfin architectures.
>
> Thanks. Have you sent these patches upstream?
>
> Thomas> ++++ b/src/Listener.cpp
> Thomas> +@@ -679,7 +679,11 @@
> Thomas> + pid_t pid;
> Thomas> +
> Thomas> + /* Create a child process& if successful, exit from the parent process */
> Thomas> ++#ifndef HAVE_FORK
> Thomas> ++ if ( (pid = vfork()) == -1 ) {
> Thomas> ++#else
> Thomas> + if ( (pid = fork()) == -1 ) {
> Thomas> ++#endif
> Thomas> + fprintf( stderr, "error in first child create\n");
> Thomas> + exit(0);
>
> I believe you aren't allowed to call exit() after vfork (but should use
> _exit() instead).
>
> http://unix.stackexchange.com/questions/5364/why-should-a-child-of-a-vfork-or-fork-call-exit-instead-of-exit
This particular exit is OK, because it is in the error case.
It's the one below that is not OK. Or rather, nothing is OK, because
the child process after a vfork is not supposed to do anything except
exec() or _exit() - it certainly shouldn't return from the function.
In fact, on Linux the parent process is suspended until the child either
_exit()s or exec()s, so it doesn't daemonize at all.
I'm not sure how you can daemonize in a posixly-correct way on a NOMMU
target. But since we're running on Linux, we can just use daemon(),
right? Both glibc and uclibc define it AFAIK.
Regards,
Arnout
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286540
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-11 20:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-07 16:39 [Buildroot] [PATCH 1/2] iperf: fix build on !MMU platforms Thomas Petazzoni
2012-05-07 16:39 ` [Buildroot] [PATCH 2/2] dropbear: fix " Thomas Petazzoni
2012-05-07 20:47 ` [Buildroot] [PATCH 1/2] iperf: fix build " Peter Korsgaard
2012-05-11 20:23 ` Arnout Vandecappelle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox