Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] nfs-utils: fix build error under tests folder
@ 2018-07-12  8:46 mingli.yu
  2018-07-30  2:15 ` Yu, Mingli
  2018-07-30 14:20 ` Burton, Ross
  0 siblings, 2 replies; 10+ messages in thread
From: mingli.yu @ 2018-07-12  8:46 UTC (permalink / raw)
  To: openembedded-core

From: Mingli Yu <Mingli.Yu@windriver.com>

* When enable the test as below in nfs-utils recipe,
  do_compile_append_class-target () {
        oe_runmake -C tests statdb_dump
        oe_runmake -C tests/nsm_client nsm_client
  }

  There comes some build error as:
  1,
  | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
  | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.

  2,
  | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
  | collect2: error: ld returned 1 exit status

* Redefine the reference path of libnfs.a to
 ../support/nfs/.libs/libnfs.a to fix the error 1 as
  above

* The function generic_make_pathname is introduced in
  nfs-utils 2.3.1
  Add the source file which defines function generic_make_pathname to
  libnsm_a_SOURCES of libnsm.a to fix the undefined reference
  error 2 as above

Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
---
 ...efile.am-update-the-path-of-libnfs.a.patch |  49 +++
 .../0001-fix-undefined-for-libnsm.a.patch     | 293 ++++++++++++++++++
 .../nfs-utils/nfs-utils_2.3.1.bb              |   2 +
 3 files changed, 344 insertions(+)
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
new file mode 100644
index 0000000000..b756ef6c5a
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
@@ -0,0 +1,49 @@
+From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Thu, 12 Jul 2018 15:19:41 +0800
+Subject: [PATCH] Makefile.am: update the path of libnfs.a
+
+The libnfs.a is under ../support/nfs/.libs/ now,
+update the reference path accordingly to fix below
+build error:
+| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
+
+| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
+
+Upstream-Status: Pending
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ tests/Makefile.am            | 2 +-
+ tests/nsm_client/Makefile.am | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 1f96264..74aa629 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -3,7 +3,7 @@
+ check_PROGRAMS = statdb_dump
+ statdb_dump_SOURCES = statdb_dump.c
+ 
+-statdb_dump_LDADD = ../support/nfs/libnfs.a \
++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
+ 		    ../support/nsm/libnsm.a $(LIBCAP)
+ 
+ SUBDIRS = nsm_client
+diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
+index a8fc131..43db9c2 100644
+--- a/tests/nsm_client/Makefile.am
++++ b/tests/nsm_client/Makefile.am
+@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
+ nsm_client_SOURCES = $(GENFILES) nsm_client.c
+ 
+ BUILT_SOURCES = $(GENFILES)
+-nsm_client_LDADD = ../../support/nfs/libnfs.a \
++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
+ 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
+ 
+ if CONFIG_RPCGEN
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
new file mode 100644
index 0000000000..bb210dbd1b
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
@@ -0,0 +1,293 @@
+From 7b945c3498b5f88640947c187460f8029a09751e Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Thu, 12 Jul 2018 14:57:53 +0800
+Subject: [PATCH] fix undefined function for libnsm.a
+
+The source file file.c of libnsm.a uses some function
+in ../support/misc/file.c, add ../support/misc/file.c
+to libnsm_a_SOURCES to fix build error:
+| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
+| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
+| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
+| collect2: error: ld returned 1 exit status
+
+As there is already one source file named file.c, so
+rename ../support/misc/file.c to ../support/misc/misc.c
+
+Upstream-Status: Pending
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ support/misc/Makefile.am |   2 +-
+ support/misc/file.c      | 111 -----------------------------------------------
+ support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
+ support/nsm/Makefile.am  |   2 +-
+ 4 files changed, 113 insertions(+), 113 deletions(-)
+ delete mode 100644 support/misc/file.c
+ create mode 100644 support/misc/misc.c
+
+diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
+index 8936b0d..d4c1f76 100644
+--- a/support/misc/Makefile.am
++++ b/support/misc/Makefile.am
+@@ -1,6 +1,6 @@
+ ## Process this file with automake to produce Makefile.in
+ 
+ noinst_LIBRARIES = libmisc.a
+-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
+ 
+ MAINTAINERCLEANFILES = Makefile.in
+diff --git a/support/misc/file.c b/support/misc/file.c
+deleted file mode 100644
+index d47e8be..0000000
+--- a/support/misc/file.c
++++ /dev/null
+@@ -1,111 +0,0 @@
+-/*
+- * Copyright 2009 Oracle.  All rights reserved.
+- * Copyright 2017 Red Hat, Inc.  All rights reserved.
+- *
+- * This file is part of nfs-utils.
+- *
+- * nfs-utils is free software; you can redistribute it and/or modify
+- * it under the terms of the GNU General Public License as published by
+- * the Free Software Foundation; either version 2 of the License, or
+- * (at your option) any later version.
+- *
+- * nfs-utils is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
+- */
+-
+-#include <sys/stat.h>
+-
+-#include <string.h>
+-#include <libgen.h>
+-#include <stdio.h>
+-#include <errno.h>
+-#include <dirent.h>
+-#include <stdlib.h>
+-#include <stdbool.h>
+-#include <limits.h>
+-
+-#include "xlog.h"
+-#include "misc.h"
+-
+-/*
+- * Returns a dynamically allocated, '\0'-terminated buffer
+- * containing an appropriate pathname, or NULL if an error
+- * occurs.  Caller must free the returned result with free(3).
+- */
+-__attribute__((__malloc__))
+-char *
+-generic_make_pathname(const char *base, const char *leaf)
+-{
+-	size_t size;
+-	char *path;
+-	int len;
+-
+-	size = strlen(base) + strlen(leaf) + 2;
+-	if (size > PATH_MAX)
+-		return NULL;
+-
+-	path = malloc(size);
+-	if (path == NULL)
+-		return NULL;
+-
+-	len = snprintf(path, size, "%s/%s", base, leaf);
+-	if ((len < 0) || ((size_t)len >= size)) {
+-		free(path);
+-		return NULL;
+-	}
+-
+-	return path;
+-}
+-
+-
+-/**
+- * generic_setup_basedir - set up basedir
+- * @progname: C string containing name of program, for error messages
+- * @parentdir: C string containing pathname to on-disk state, or NULL
+- * @base: character buffer to contain the basedir that is set up
+- * @baselen: size of @base in bytes
+- *
+- * This runs before logging is set up, so error messages are directed
+- * to stderr.
+- *
+- * Returns true and sets up our basedir, if @parentdir was valid
+- * and usable; otherwise false is returned.
+- */
+-_Bool
+-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
+-		      const size_t baselen)
+-{
+-	static char buf[PATH_MAX];
+-	struct stat st;
+-	char *path;
+-
+-	/* First: test length of name and whether it exists */
+-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
+-		(void)fprintf(stderr, "%s: Directory name too long: %s",
+-				progname, parentdir);
+-		return false;
+-	}
+-	if (lstat(parentdir, &st) == -1) {
+-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
+-				progname, parentdir, strerror(errno));
+-		return false;
+-	}
+-
+-	/* Ensure we have a clean directory pathname */
+-	strncpy(buf, parentdir, sizeof(buf));
+-	path = dirname(buf);
+-	if (*path == '.') {
+-		(void)fprintf(stderr, "%s: Unusable directory %s",
+-				progname, parentdir);
+-		return false;
+-	}
+-
+-	xlog(D_CALL, "Using %s as the state directory", parentdir);
+-	strcpy(base, parentdir);
+-	return true;
+-}
+diff --git a/support/misc/misc.c b/support/misc/misc.c
+new file mode 100644
+index 0000000..d47e8be
+--- /dev/null
++++ b/support/misc/misc.c
+@@ -0,0 +1,111 @@
++/*
++ * Copyright 2009 Oracle.  All rights reserved.
++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
++ *
++ * This file is part of nfs-utils.
++ *
++ * nfs-utils is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * nfs-utils is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <sys/stat.h>
++
++#include <string.h>
++#include <libgen.h>
++#include <stdio.h>
++#include <errno.h>
++#include <dirent.h>
++#include <stdlib.h>
++#include <stdbool.h>
++#include <limits.h>
++
++#include "xlog.h"
++#include "misc.h"
++
++/*
++ * Returns a dynamically allocated, '\0'-terminated buffer
++ * containing an appropriate pathname, or NULL if an error
++ * occurs.  Caller must free the returned result with free(3).
++ */
++__attribute__((__malloc__))
++char *
++generic_make_pathname(const char *base, const char *leaf)
++{
++	size_t size;
++	char *path;
++	int len;
++
++	size = strlen(base) + strlen(leaf) + 2;
++	if (size > PATH_MAX)
++		return NULL;
++
++	path = malloc(size);
++	if (path == NULL)
++		return NULL;
++
++	len = snprintf(path, size, "%s/%s", base, leaf);
++	if ((len < 0) || ((size_t)len >= size)) {
++		free(path);
++		return NULL;
++	}
++
++	return path;
++}
++
++
++/**
++ * generic_setup_basedir - set up basedir
++ * @progname: C string containing name of program, for error messages
++ * @parentdir: C string containing pathname to on-disk state, or NULL
++ * @base: character buffer to contain the basedir that is set up
++ * @baselen: size of @base in bytes
++ *
++ * This runs before logging is set up, so error messages are directed
++ * to stderr.
++ *
++ * Returns true and sets up our basedir, if @parentdir was valid
++ * and usable; otherwise false is returned.
++ */
++_Bool
++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
++		      const size_t baselen)
++{
++	static char buf[PATH_MAX];
++	struct stat st;
++	char *path;
++
++	/* First: test length of name and whether it exists */
++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
++		(void)fprintf(stderr, "%s: Directory name too long: %s",
++				progname, parentdir);
++		return false;
++	}
++	if (lstat(parentdir, &st) == -1) {
++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
++				progname, parentdir, strerror(errno));
++		return false;
++	}
++
++	/* Ensure we have a clean directory pathname */
++	strncpy(buf, parentdir, sizeof(buf));
++	path = dirname(buf);
++	if (*path == '.') {
++		(void)fprintf(stderr, "%s: Unusable directory %s",
++				progname, parentdir);
++		return false;
++	}
++
++	xlog(D_CALL, "Using %s as the state directory", parentdir);
++	strcpy(base, parentdir);
++	return true;
++}
+diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
+index 2038e68..864348d 100644
+--- a/support/nsm/Makefile.am
++++ b/support/nsm/Makefile.am
+@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
+ EXTRA_DIST	= sm_inter.x
+ 
+ noinst_LIBRARIES = libnsm.a
+-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
+ 
+ BUILT_SOURCES = $(GENFILES)
+ 
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
index 6390c324f8..ed4aa5f430 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
@@ -30,6 +30,8 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
            file://nfs-utils-debianize-start-statd.patch \
            file://bugfix-adjust-statd-service-name.patch \
            file://nfs-utils-musl-limits.patch \
+           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
+           file://0001-fix-undefined-for-libnsm.a.patch \
 "
 
 SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
-- 
2.17.1



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

* Re: [PATCH] nfs-utils: fix build error under tests folder
  2018-07-12  8:46 [PATCH] " mingli.yu
@ 2018-07-30  2:15 ` Yu, Mingli
  2018-07-30 14:20 ` Burton, Ross
  1 sibling, 0 replies; 10+ messages in thread
From: Yu, Mingli @ 2018-07-30  2:15 UTC (permalink / raw)
  To: openembedded-core

Ping.

Thanks,

On 2018年07月12日 16:46, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
>
> * When enable the test as below in nfs-utils recipe,
>    do_compile_append_class-target () {
>          oe_runmake -C tests statdb_dump
>          oe_runmake -C tests/nsm_client nsm_client
>    }
>
>    There comes some build error as:
>    1,
>    | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
>    | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
>
>    2,
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
>    | collect2: error: ld returned 1 exit status
>
> * Redefine the reference path of libnfs.a to
>   ../support/nfs/.libs/libnfs.a to fix the error 1 as
>    above
>
> * The function generic_make_pathname is introduced in
>    nfs-utils 2.3.1
>    Add the source file which defines function generic_make_pathname to
>    libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>    error 2 as above
>
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>   ...efile.am-update-the-path-of-libnfs.a.patch |  49 +++
>   .../0001-fix-undefined-for-libnsm.a.patch     | 293 ++++++++++++++++++
>   .../nfs-utils/nfs-utils_2.3.1.bb              |   2 +
>   3 files changed, 344 insertions(+)
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
>
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> new file mode 100644
> index 0000000000..b756ef6c5a
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> @@ -0,0 +1,49 @@
> +From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 15:19:41 +0800
> +Subject: [PATCH] Makefile.am: update the path of libnfs.a
> +
> +The libnfs.a is under ../support/nfs/.libs/ now,
> +update the reference path accordingly to fix below
> +build error:
> +| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
> +
> +| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + tests/Makefile.am            | 2 +-
> + tests/nsm_client/Makefile.am | 2 +-
> + 2 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/Makefile.am b/tests/Makefile.am
> +index 1f96264..74aa629 100644
> +--- a/tests/Makefile.am
> ++++ b/tests/Makefile.am
> +@@ -3,7 +3,7 @@
> + check_PROGRAMS = statdb_dump
> + statdb_dump_SOURCES = statdb_dump.c
> +
> +-statdb_dump_LDADD = ../support/nfs/libnfs.a \
> ++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
> + 		    ../support/nsm/libnsm.a $(LIBCAP)
> +
> + SUBDIRS = nsm_client
> +diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
> +index a8fc131..43db9c2 100644
> +--- a/tests/nsm_client/Makefile.am
> ++++ b/tests/nsm_client/Makefile.am
> +@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
> + nsm_client_SOURCES = $(GENFILES) nsm_client.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +-nsm_client_LDADD = ../../support/nfs/libnfs.a \
> ++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
> + 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
> +
> + if CONFIG_RPCGEN
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
> new file mode 100644
> index 0000000000..bb210dbd1b
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
> @@ -0,0 +1,293 @@
> +From 7b945c3498b5f88640947c187460f8029a09751e Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 14:57:53 +0800
> +Subject: [PATCH] fix undefined function for libnsm.a
> +
> +The source file file.c of libnsm.a uses some function
> +in ../support/misc/file.c, add ../support/misc/file.c
> +to libnsm_a_SOURCES to fix build error:
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
> +| collect2: error: ld returned 1 exit status
> +
> +As there is already one source file named file.c, so
> +rename ../support/misc/file.c to ../support/misc/misc.c
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + support/misc/Makefile.am |   2 +-
> + support/misc/file.c      | 111 -----------------------------------------------
> + support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
> + support/nsm/Makefile.am  |   2 +-
> + 4 files changed, 113 insertions(+), 113 deletions(-)
> + delete mode 100644 support/misc/file.c
> + create mode 100644 support/misc/misc.c
> +
> +diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
> +index 8936b0d..d4c1f76 100644
> +--- a/support/misc/Makefile.am
> ++++ b/support/misc/Makefile.am
> +@@ -1,6 +1,6 @@
> + ## Process this file with automake to produce Makefile.in
> +
> + noinst_LIBRARIES = libmisc.a
> +-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
> ++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
> +
> + MAINTAINERCLEANFILES = Makefile.in
> +diff --git a/support/misc/file.c b/support/misc/file.c
> +deleted file mode 100644
> +index d47e8be..0000000
> +--- a/support/misc/file.c
> ++++ /dev/null
> +@@ -1,111 +0,0 @@
> +-/*
> +- * Copyright 2009 Oracle.  All rights reserved.
> +- * Copyright 2017 Red Hat, Inc.  All rights reserved.
> +- *
> +- * This file is part of nfs-utils.
> +- *
> +- * nfs-utils is free software; you can redistribute it and/or modify
> +- * it under the terms of the GNU General Public License as published by
> +- * the Free Software Foundation; either version 2 of the License, or
> +- * (at your option) any later version.
> +- *
> +- * nfs-utils is distributed in the hope that it will be useful,
> +- * but WITHOUT ANY WARRANTY; without even the implied warranty of
> +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +- * GNU General Public License for more details.
> +- *
> +- * You should have received a copy of the GNU General Public License
> +- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> +- */
> +-
> +-#include <sys/stat.h>
> +-
> +-#include <string.h>
> +-#include <libgen.h>
> +-#include <stdio.h>
> +-#include <errno.h>
> +-#include <dirent.h>
> +-#include <stdlib.h>
> +-#include <stdbool.h>
> +-#include <limits.h>
> +-
> +-#include "xlog.h"
> +-#include "misc.h"
> +-
> +-/*
> +- * Returns a dynamically allocated, '\0'-terminated buffer
> +- * containing an appropriate pathname, or NULL if an error
> +- * occurs.  Caller must free the returned result with free(3).
> +- */
> +-__attribute__((__malloc__))
> +-char *
> +-generic_make_pathname(const char *base, const char *leaf)
> +-{
> +-	size_t size;
> +-	char *path;
> +-	int len;
> +-
> +-	size = strlen(base) + strlen(leaf) + 2;
> +-	if (size > PATH_MAX)
> +-		return NULL;
> +-
> +-	path = malloc(size);
> +-	if (path == NULL)
> +-		return NULL;
> +-
> +-	len = snprintf(path, size, "%s/%s", base, leaf);
> +-	if ((len < 0) || ((size_t)len >= size)) {
> +-		free(path);
> +-		return NULL;
> +-	}
> +-
> +-	return path;
> +-}
> +-
> +-
> +-/**
> +- * generic_setup_basedir - set up basedir
> +- * @progname: C string containing name of program, for error messages
> +- * @parentdir: C string containing pathname to on-disk state, or NULL
> +- * @base: character buffer to contain the basedir that is set up
> +- * @baselen: size of @base in bytes
> +- *
> +- * This runs before logging is set up, so error messages are directed
> +- * to stderr.
> +- *
> +- * Returns true and sets up our basedir, if @parentdir was valid
> +- * and usable; otherwise false is returned.
> +- */
> +-_Bool
> +-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> +-		      const size_t baselen)
> +-{
> +-	static char buf[PATH_MAX];
> +-	struct stat st;
> +-	char *path;
> +-
> +-	/* First: test length of name and whether it exists */
> +-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> +-		(void)fprintf(stderr, "%s: Directory name too long: %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-	if (lstat(parentdir, &st) == -1) {
> +-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> +-				progname, parentdir, strerror(errno));
> +-		return false;
> +-	}
> +-
> +-	/* Ensure we have a clean directory pathname */
> +-	strncpy(buf, parentdir, sizeof(buf));
> +-	path = dirname(buf);
> +-	if (*path == '.') {
> +-		(void)fprintf(stderr, "%s: Unusable directory %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-
> +-	xlog(D_CALL, "Using %s as the state directory", parentdir);
> +-	strcpy(base, parentdir);
> +-	return true;
> +-}
> +diff --git a/support/misc/misc.c b/support/misc/misc.c
> +new file mode 100644
> +index 0000000..d47e8be
> +--- /dev/null
> ++++ b/support/misc/misc.c
> +@@ -0,0 +1,111 @@
> ++/*
> ++ * Copyright 2009 Oracle.  All rights reserved.
> ++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
> ++ *
> ++ * This file is part of nfs-utils.
> ++ *
> ++ * nfs-utils is free software; you can redistribute it and/or modify
> ++ * it under the terms of the GNU General Public License as published by
> ++ * the Free Software Foundation; either version 2 of the License, or
> ++ * (at your option) any later version.
> ++ *
> ++ * nfs-utils is distributed in the hope that it will be useful,
> ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ++ * GNU General Public License for more details.
> ++ *
> ++ * You should have received a copy of the GNU General Public License
> ++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> ++ */
> ++
> ++#include <sys/stat.h>
> ++
> ++#include <string.h>
> ++#include <libgen.h>
> ++#include <stdio.h>
> ++#include <errno.h>
> ++#include <dirent.h>
> ++#include <stdlib.h>
> ++#include <stdbool.h>
> ++#include <limits.h>
> ++
> ++#include "xlog.h"
> ++#include "misc.h"
> ++
> ++/*
> ++ * Returns a dynamically allocated, '\0'-terminated buffer
> ++ * containing an appropriate pathname, or NULL if an error
> ++ * occurs.  Caller must free the returned result with free(3).
> ++ */
> ++__attribute__((__malloc__))
> ++char *
> ++generic_make_pathname(const char *base, const char *leaf)
> ++{
> ++	size_t size;
> ++	char *path;
> ++	int len;
> ++
> ++	size = strlen(base) + strlen(leaf) + 2;
> ++	if (size > PATH_MAX)
> ++		return NULL;
> ++
> ++	path = malloc(size);
> ++	if (path == NULL)
> ++		return NULL;
> ++
> ++	len = snprintf(path, size, "%s/%s", base, leaf);
> ++	if ((len < 0) || ((size_t)len >= size)) {
> ++		free(path);
> ++		return NULL;
> ++	}
> ++
> ++	return path;
> ++}
> ++
> ++
> ++/**
> ++ * generic_setup_basedir - set up basedir
> ++ * @progname: C string containing name of program, for error messages
> ++ * @parentdir: C string containing pathname to on-disk state, or NULL
> ++ * @base: character buffer to contain the basedir that is set up
> ++ * @baselen: size of @base in bytes
> ++ *
> ++ * This runs before logging is set up, so error messages are directed
> ++ * to stderr.
> ++ *
> ++ * Returns true and sets up our basedir, if @parentdir was valid
> ++ * and usable; otherwise false is returned.
> ++ */
> ++_Bool
> ++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> ++		      const size_t baselen)
> ++{
> ++	static char buf[PATH_MAX];
> ++	struct stat st;
> ++	char *path;
> ++
> ++	/* First: test length of name and whether it exists */
> ++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> ++		(void)fprintf(stderr, "%s: Directory name too long: %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++	if (lstat(parentdir, &st) == -1) {
> ++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> ++				progname, parentdir, strerror(errno));
> ++		return false;
> ++	}
> ++
> ++	/* Ensure we have a clean directory pathname */
> ++	strncpy(buf, parentdir, sizeof(buf));
> ++	path = dirname(buf);
> ++	if (*path == '.') {
> ++		(void)fprintf(stderr, "%s: Unusable directory %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++
> ++	xlog(D_CALL, "Using %s as the state directory", parentdir);
> ++	strcpy(base, parentdir);
> ++	return true;
> ++}
> +diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
> +index 2038e68..864348d 100644
> +--- a/support/nsm/Makefile.am
> ++++ b/support/nsm/Makefile.am
> +@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
> + EXTRA_DIST	= sm_inter.x
> +
> + noinst_LIBRARIES = libnsm.a
> +-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
> ++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
> index 6390c324f8..ed4aa5f430 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
> @@ -30,6 +30,8 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>              file://nfs-utils-debianize-start-statd.patch \
>              file://bugfix-adjust-statd-service-name.patch \
>              file://nfs-utils-musl-limits.patch \
> +           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
> +           file://0001-fix-undefined-for-libnsm.a.patch \
>   "
>
>   SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
>


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

* Re: [PATCH] nfs-utils: fix build error under tests folder
  2018-07-12  8:46 [PATCH] " mingli.yu
  2018-07-30  2:15 ` Yu, Mingli
@ 2018-07-30 14:20 ` Burton, Ross
  1 sibling, 0 replies; 10+ messages in thread
From: Burton, Ross @ 2018-07-30 14:20 UTC (permalink / raw)
  To: Mingli Yu; +Cc: OE-core

That's a complicated patch to enable tests that we don't enable.  Can
you get it upstream first so we're not carrying this?

Ross

On 12 July 2018 at 09:46,  <mingli.yu@windriver.com> wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
>
> * When enable the test as below in nfs-utils recipe,
>   do_compile_append_class-target () {
>         oe_runmake -C tests statdb_dump
>         oe_runmake -C tests/nsm_client nsm_client
>   }
>
>   There comes some build error as:
>   1,
>   | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
>   | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
>
>   2,
>   | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>   | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
>   | collect2: error: ld returned 1 exit status
>
> * Redefine the reference path of libnfs.a to
>  ../support/nfs/.libs/libnfs.a to fix the error 1 as
>   above
>
> * The function generic_make_pathname is introduced in
>   nfs-utils 2.3.1
>   Add the source file which defines function generic_make_pathname to
>   libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>   error 2 as above
>
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>  ...efile.am-update-the-path-of-libnfs.a.patch |  49 +++
>  .../0001-fix-undefined-for-libnsm.a.patch     | 293 ++++++++++++++++++
>  .../nfs-utils/nfs-utils_2.3.1.bb              |   2 +
>  3 files changed, 344 insertions(+)
>  create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
>  create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
>
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> new file mode 100644
> index 0000000000..b756ef6c5a
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> @@ -0,0 +1,49 @@
> +From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 15:19:41 +0800
> +Subject: [PATCH] Makefile.am: update the path of libnfs.a
> +
> +The libnfs.a is under ../support/nfs/.libs/ now,
> +update the reference path accordingly to fix below
> +build error:
> +| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
> +
> +| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + tests/Makefile.am            | 2 +-
> + tests/nsm_client/Makefile.am | 2 +-
> + 2 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/Makefile.am b/tests/Makefile.am
> +index 1f96264..74aa629 100644
> +--- a/tests/Makefile.am
> ++++ b/tests/Makefile.am
> +@@ -3,7 +3,7 @@
> + check_PROGRAMS = statdb_dump
> + statdb_dump_SOURCES = statdb_dump.c
> +
> +-statdb_dump_LDADD = ../support/nfs/libnfs.a \
> ++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
> +                   ../support/nsm/libnsm.a $(LIBCAP)
> +
> + SUBDIRS = nsm_client
> +diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
> +index a8fc131..43db9c2 100644
> +--- a/tests/nsm_client/Makefile.am
> ++++ b/tests/nsm_client/Makefile.am
> +@@ -13,7 +13,7 @@ check_PROGRAMS       = nsm_client
> + nsm_client_SOURCES = $(GENFILES) nsm_client.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +-nsm_client_LDADD = ../../support/nfs/libnfs.a \
> ++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
> +                  ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
> +
> + if CONFIG_RPCGEN
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
> new file mode 100644
> index 0000000000..bb210dbd1b
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-fix-undefined-for-libnsm.a.patch
> @@ -0,0 +1,293 @@
> +From 7b945c3498b5f88640947c187460f8029a09751e Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 14:57:53 +0800
> +Subject: [PATCH] fix undefined function for libnsm.a
> +
> +The source file file.c of libnsm.a uses some function
> +in ../support/misc/file.c, add ../support/misc/file.c
> +to libnsm_a_SOURCES to fix build error:
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
> +| /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
> +| collect2: error: ld returned 1 exit status
> +
> +As there is already one source file named file.c, so
> +rename ../support/misc/file.c to ../support/misc/misc.c
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + support/misc/Makefile.am |   2 +-
> + support/misc/file.c      | 111 -----------------------------------------------
> + support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
> + support/nsm/Makefile.am  |   2 +-
> + 4 files changed, 113 insertions(+), 113 deletions(-)
> + delete mode 100644 support/misc/file.c
> + create mode 100644 support/misc/misc.c
> +
> +diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
> +index 8936b0d..d4c1f76 100644
> +--- a/support/misc/Makefile.am
> ++++ b/support/misc/Makefile.am
> +@@ -1,6 +1,6 @@
> + ## Process this file with automake to produce Makefile.in
> +
> + noinst_LIBRARIES = libmisc.a
> +-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
> ++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
> +
> + MAINTAINERCLEANFILES = Makefile.in
> +diff --git a/support/misc/file.c b/support/misc/file.c
> +deleted file mode 100644
> +index d47e8be..0000000
> +--- a/support/misc/file.c
> ++++ /dev/null
> +@@ -1,111 +0,0 @@
> +-/*
> +- * Copyright 2009 Oracle.  All rights reserved.
> +- * Copyright 2017 Red Hat, Inc.  All rights reserved.
> +- *
> +- * This file is part of nfs-utils.
> +- *
> +- * nfs-utils is free software; you can redistribute it and/or modify
> +- * it under the terms of the GNU General Public License as published by
> +- * the Free Software Foundation; either version 2 of the License, or
> +- * (at your option) any later version.
> +- *
> +- * nfs-utils is distributed in the hope that it will be useful,
> +- * but WITHOUT ANY WARRANTY; without even the implied warranty of
> +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +- * GNU General Public License for more details.
> +- *
> +- * You should have received a copy of the GNU General Public License
> +- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> +- */
> +-
> +-#include <sys/stat.h>
> +-
> +-#include <string.h>
> +-#include <libgen.h>
> +-#include <stdio.h>
> +-#include <errno.h>
> +-#include <dirent.h>
> +-#include <stdlib.h>
> +-#include <stdbool.h>
> +-#include <limits.h>
> +-
> +-#include "xlog.h"
> +-#include "misc.h"
> +-
> +-/*
> +- * Returns a dynamically allocated, '\0'-terminated buffer
> +- * containing an appropriate pathname, or NULL if an error
> +- * occurs.  Caller must free the returned result with free(3).
> +- */
> +-__attribute__((__malloc__))
> +-char *
> +-generic_make_pathname(const char *base, const char *leaf)
> +-{
> +-      size_t size;
> +-      char *path;
> +-      int len;
> +-
> +-      size = strlen(base) + strlen(leaf) + 2;
> +-      if (size > PATH_MAX)
> +-              return NULL;
> +-
> +-      path = malloc(size);
> +-      if (path == NULL)
> +-              return NULL;
> +-
> +-      len = snprintf(path, size, "%s/%s", base, leaf);
> +-      if ((len < 0) || ((size_t)len >= size)) {
> +-              free(path);
> +-              return NULL;
> +-      }
> +-
> +-      return path;
> +-}
> +-
> +-
> +-/**
> +- * generic_setup_basedir - set up basedir
> +- * @progname: C string containing name of program, for error messages
> +- * @parentdir: C string containing pathname to on-disk state, or NULL
> +- * @base: character buffer to contain the basedir that is set up
> +- * @baselen: size of @base in bytes
> +- *
> +- * This runs before logging is set up, so error messages are directed
> +- * to stderr.
> +- *
> +- * Returns true and sets up our basedir, if @parentdir was valid
> +- * and usable; otherwise false is returned.
> +- */
> +-_Bool
> +-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> +-                    const size_t baselen)
> +-{
> +-      static char buf[PATH_MAX];
> +-      struct stat st;
> +-      char *path;
> +-
> +-      /* First: test length of name and whether it exists */
> +-      if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> +-              (void)fprintf(stderr, "%s: Directory name too long: %s",
> +-                              progname, parentdir);
> +-              return false;
> +-      }
> +-      if (lstat(parentdir, &st) == -1) {
> +-              (void)fprintf(stderr, "%s: Failed to stat %s: %s",
> +-                              progname, parentdir, strerror(errno));
> +-              return false;
> +-      }
> +-
> +-      /* Ensure we have a clean directory pathname */
> +-      strncpy(buf, parentdir, sizeof(buf));
> +-      path = dirname(buf);
> +-      if (*path == '.') {
> +-              (void)fprintf(stderr, "%s: Unusable directory %s",
> +-                              progname, parentdir);
> +-              return false;
> +-      }
> +-
> +-      xlog(D_CALL, "Using %s as the state directory", parentdir);
> +-      strcpy(base, parentdir);
> +-      return true;
> +-}
> +diff --git a/support/misc/misc.c b/support/misc/misc.c
> +new file mode 100644
> +index 0000000..d47e8be
> +--- /dev/null
> ++++ b/support/misc/misc.c
> +@@ -0,0 +1,111 @@
> ++/*
> ++ * Copyright 2009 Oracle.  All rights reserved.
> ++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
> ++ *
> ++ * This file is part of nfs-utils.
> ++ *
> ++ * nfs-utils is free software; you can redistribute it and/or modify
> ++ * it under the terms of the GNU General Public License as published by
> ++ * the Free Software Foundation; either version 2 of the License, or
> ++ * (at your option) any later version.
> ++ *
> ++ * nfs-utils is distributed in the hope that it will be useful,
> ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ++ * GNU General Public License for more details.
> ++ *
> ++ * You should have received a copy of the GNU General Public License
> ++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> ++ */
> ++
> ++#include <sys/stat.h>
> ++
> ++#include <string.h>
> ++#include <libgen.h>
> ++#include <stdio.h>
> ++#include <errno.h>
> ++#include <dirent.h>
> ++#include <stdlib.h>
> ++#include <stdbool.h>
> ++#include <limits.h>
> ++
> ++#include "xlog.h"
> ++#include "misc.h"
> ++
> ++/*
> ++ * Returns a dynamically allocated, '\0'-terminated buffer
> ++ * containing an appropriate pathname, or NULL if an error
> ++ * occurs.  Caller must free the returned result with free(3).
> ++ */
> ++__attribute__((__malloc__))
> ++char *
> ++generic_make_pathname(const char *base, const char *leaf)
> ++{
> ++      size_t size;
> ++      char *path;
> ++      int len;
> ++
> ++      size = strlen(base) + strlen(leaf) + 2;
> ++      if (size > PATH_MAX)
> ++              return NULL;
> ++
> ++      path = malloc(size);
> ++      if (path == NULL)
> ++              return NULL;
> ++
> ++      len = snprintf(path, size, "%s/%s", base, leaf);
> ++      if ((len < 0) || ((size_t)len >= size)) {
> ++              free(path);
> ++              return NULL;
> ++      }
> ++
> ++      return path;
> ++}
> ++
> ++
> ++/**
> ++ * generic_setup_basedir - set up basedir
> ++ * @progname: C string containing name of program, for error messages
> ++ * @parentdir: C string containing pathname to on-disk state, or NULL
> ++ * @base: character buffer to contain the basedir that is set up
> ++ * @baselen: size of @base in bytes
> ++ *
> ++ * This runs before logging is set up, so error messages are directed
> ++ * to stderr.
> ++ *
> ++ * Returns true and sets up our basedir, if @parentdir was valid
> ++ * and usable; otherwise false is returned.
> ++ */
> ++_Bool
> ++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> ++                    const size_t baselen)
> ++{
> ++      static char buf[PATH_MAX];
> ++      struct stat st;
> ++      char *path;
> ++
> ++      /* First: test length of name and whether it exists */
> ++      if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> ++              (void)fprintf(stderr, "%s: Directory name too long: %s",
> ++                              progname, parentdir);
> ++              return false;
> ++      }
> ++      if (lstat(parentdir, &st) == -1) {
> ++              (void)fprintf(stderr, "%s: Failed to stat %s: %s",
> ++                              progname, parentdir, strerror(errno));
> ++              return false;
> ++      }
> ++
> ++      /* Ensure we have a clean directory pathname */
> ++      strncpy(buf, parentdir, sizeof(buf));
> ++      path = dirname(buf);
> ++      if (*path == '.') {
> ++              (void)fprintf(stderr, "%s: Unusable directory %s",
> ++                              progname, parentdir);
> ++              return false;
> ++      }
> ++
> ++      xlog(D_CALL, "Using %s as the state directory", parentdir);
> ++      strcpy(base, parentdir);
> ++      return true;
> ++}
> +diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
> +index 2038e68..864348d 100644
> +--- a/support/nsm/Makefile.am
> ++++ b/support/nsm/Makefile.am
> +@@ -10,7 +10,7 @@ GENFILES     = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
> + EXTRA_DIST    = sm_inter.x
> +
> + noinst_LIBRARIES = libnsm.a
> +-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
> ++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
> index 6390c324f8..ed4aa5f430 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.1.bb
> @@ -30,6 +30,8 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>             file://nfs-utils-debianize-start-statd.patch \
>             file://bugfix-adjust-statd-service-name.patch \
>             file://nfs-utils-musl-limits.patch \
> +           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
> +           file://0001-fix-undefined-for-libnsm.a.patch \
>  "
>
>  SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
> --
> 2.17.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


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

* [PATCH] nfs-utils: fix build error under tests folder
@ 2018-12-17  8:47 mingli.yu
  2018-12-17 17:16 ` richard.purdie
  0 siblings, 1 reply; 10+ messages in thread
From: mingli.yu @ 2018-12-17  8:47 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

From: Mingli Yu <Mingli.Yu@windriver.com>

* Redefine the reference path of libnfs.a to
  ../support/nfs/.libs/libnfs.a to fix below
  error when run "make -C tests statdb_dump".
  | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
  | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.

* The function generic_make_pathname is introduced in
  nfs-utils 2.3.1.
  Add the source file which defines function generic_make_pathname to
  libnsm_a_SOURCES of libnsm.a to fix the undefined reference
  when run "make -C tests statdb_dump"
  | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
  | collect2: error: ld returned 1 exit status

* After the logic of commit[dbb643e Removed missing-prototypes warnings.]
  introduced, there comes below error when run
  "make -C tests/nsm_client nsm_client"
  | nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]

  It is because rpcgen doesn't generate -Wmissing-prototypes
  free code for nlm_sm_inter_svc.c with below logic
  in tests/nsm_client/Makefile.am
  [snip]
  GENFILES_SVC    = nlm_sm_inter_svc.c
  [snip]
  $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
        test -f $@ && rm -rf $@ || true
        $(RPCGEN) -m -o $@ $<
 So add the patch to not fatalize -Wmissing-prototypes.

Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
---
 ...-fix-undefined-function-for-libnsm.a.patch | 295 ++++++++++++++++++
 ...efile.am-update-the-path-of-libnfs.a.patch |  50 +++
 ...-Do-not-fatalize-Wmissing-prototypes.patch |  43 +++
 .../nfs-utils/nfs-utils_2.3.3.bb              |   3 +
 4 files changed, 391 insertions(+)
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
new file mode 100644
index 00000000000..aa551ebd191
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
@@ -0,0 +1,295 @@
+From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Fri, 14 Dec 2018 17:44:32 +0800
+Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
+
+The source file of libnsm.a uses some function
+in ../support/misc/file.c, add ../support/misc/file.c
+to libnsm_a_SOURCES to fix build error when run
+"make -C tests statdb_dump":
+| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
+| collect2: error: ld returned 1 exit status
+
+As there is already one source file named file.c
+as support/nsm/file.c in support/nsm/Makefile.am,
+so rename ../support/misc/file.c to ../support/misc/misc.c.
+
+Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ support/misc/Makefile.am |   2 +-
+ support/misc/file.c      | 111 -----------------------------------------------
+ support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
+ support/nsm/Makefile.am  |   2 +-
+ 4 files changed, 113 insertions(+), 113 deletions(-)
+ delete mode 100644 support/misc/file.c
+ create mode 100644 support/misc/misc.c
+
+diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
+index 8936b0d..d4c1f76 100644
+--- a/support/misc/Makefile.am
++++ b/support/misc/Makefile.am
+@@ -1,6 +1,6 @@
+ ## Process this file with automake to produce Makefile.in
+ 
+ noinst_LIBRARIES = libmisc.a
+-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
+ 
+ MAINTAINERCLEANFILES = Makefile.in
+diff --git a/support/misc/file.c b/support/misc/file.c
+deleted file mode 100644
+index e7c3819..0000000
+--- a/support/misc/file.c
++++ /dev/null
+@@ -1,111 +0,0 @@
+-/*
+- * Copyright 2009 Oracle.  All rights reserved.
+- * Copyright 2017 Red Hat, Inc.  All rights reserved.
+- *
+- * This file is part of nfs-utils.
+- *
+- * nfs-utils is free software; you can redistribute it and/or modify
+- * it under the terms of the GNU General Public License as published by
+- * the Free Software Foundation; either version 2 of the License, or
+- * (at your option) any later version.
+- *
+- * nfs-utils is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
+- */
+-
+-#include <sys/stat.h>
+-
+-#include <string.h>
+-#include <libgen.h>
+-#include <stdio.h>
+-#include <errno.h>
+-#include <dirent.h>
+-#include <stdlib.h>
+-#include <stdbool.h>
+-#include <limits.h>
+-
+-#include "xlog.h"
+-#include "misc.h"
+-
+-/*
+- * Returns a dynamically allocated, '\0'-terminated buffer
+- * containing an appropriate pathname, or NULL if an error
+- * occurs.  Caller must free the returned result with free(3).
+- */
+-__attribute__((__malloc__))
+-char *
+-generic_make_pathname(const char *base, const char *leaf)
+-{
+-	size_t size;
+-	char *path;
+-	int len;
+-
+-	size = strlen(base) + strlen(leaf) + 2;
+-	if (size > PATH_MAX)
+-		return NULL;
+-
+-	path = malloc(size);
+-	if (path == NULL)
+-		return NULL;
+-
+-	len = snprintf(path, size, "%s/%s", base, leaf);
+-	if ((len < 0) || ((size_t)len >= size)) {
+-		free(path);
+-		return NULL;
+-	}
+-
+-	return path;
+-}
+-
+-
+-/**
+- * generic_setup_basedir - set up basedir
+- * @progname: C string containing name of program, for error messages
+- * @parentdir: C string containing pathname to on-disk state, or NULL
+- * @base: character buffer to contain the basedir that is set up
+- * @baselen: size of @base in bytes
+- *
+- * This runs before logging is set up, so error messages are directed
+- * to stderr.
+- *
+- * Returns true and sets up our basedir, if @parentdir was valid
+- * and usable; otherwise false is returned.
+- */
+-_Bool
+-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
+-		      const size_t baselen)
+-{
+-	static char buf[PATH_MAX];
+-	struct stat st;
+-	char *path;
+-
+-	/* First: test length of name and whether it exists */
+-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
+-		(void)fprintf(stderr, "%s: Directory name too long: %s",
+-				progname, parentdir);
+-		return false;
+-	}
+-	if (lstat(parentdir, &st) == -1) {
+-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
+-				progname, parentdir, strerror(errno));
+-		return false;
+-	}
+-
+-	/* Ensure we have a clean directory pathname */
+-	strncpy(buf, parentdir, sizeof(buf)-1);
+-	path = dirname(buf);
+-	if (*path == '.') {
+-		(void)fprintf(stderr, "%s: Unusable directory %s",
+-				progname, parentdir);
+-		return false;
+-	}
+-
+-	xlog(D_CALL, "Using %s as the state directory", parentdir);
+-	strcpy(base, parentdir);
+-	return true;
+-}
+diff --git a/support/misc/misc.c b/support/misc/misc.c
+new file mode 100644
+index 0000000..e7c3819
+--- /dev/null
++++ b/support/misc/misc.c
+@@ -0,0 +1,111 @@
++/*
++ * Copyright 2009 Oracle.  All rights reserved.
++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
++ *
++ * This file is part of nfs-utils.
++ *
++ * nfs-utils is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * nfs-utils is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <sys/stat.h>
++
++#include <string.h>
++#include <libgen.h>
++#include <stdio.h>
++#include <errno.h>
++#include <dirent.h>
++#include <stdlib.h>
++#include <stdbool.h>
++#include <limits.h>
++
++#include "xlog.h"
++#include "misc.h"
++
++/*
++ * Returns a dynamically allocated, '\0'-terminated buffer
++ * containing an appropriate pathname, or NULL if an error
++ * occurs.  Caller must free the returned result with free(3).
++ */
++__attribute__((__malloc__))
++char *
++generic_make_pathname(const char *base, const char *leaf)
++{
++	size_t size;
++	char *path;
++	int len;
++
++	size = strlen(base) + strlen(leaf) + 2;
++	if (size > PATH_MAX)
++		return NULL;
++
++	path = malloc(size);
++	if (path == NULL)
++		return NULL;
++
++	len = snprintf(path, size, "%s/%s", base, leaf);
++	if ((len < 0) || ((size_t)len >= size)) {
++		free(path);
++		return NULL;
++	}
++
++	return path;
++}
++
++
++/**
++ * generic_setup_basedir - set up basedir
++ * @progname: C string containing name of program, for error messages
++ * @parentdir: C string containing pathname to on-disk state, or NULL
++ * @base: character buffer to contain the basedir that is set up
++ * @baselen: size of @base in bytes
++ *
++ * This runs before logging is set up, so error messages are directed
++ * to stderr.
++ *
++ * Returns true and sets up our basedir, if @parentdir was valid
++ * and usable; otherwise false is returned.
++ */
++_Bool
++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
++		      const size_t baselen)
++{
++	static char buf[PATH_MAX];
++	struct stat st;
++	char *path;
++
++	/* First: test length of name and whether it exists */
++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
++		(void)fprintf(stderr, "%s: Directory name too long: %s",
++				progname, parentdir);
++		return false;
++	}
++	if (lstat(parentdir, &st) == -1) {
++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
++				progname, parentdir, strerror(errno));
++		return false;
++	}
++
++	/* Ensure we have a clean directory pathname */
++	strncpy(buf, parentdir, sizeof(buf)-1);
++	path = dirname(buf);
++	if (*path == '.') {
++		(void)fprintf(stderr, "%s: Unusable directory %s",
++				progname, parentdir);
++		return false;
++	}
++
++	xlog(D_CALL, "Using %s as the state directory", parentdir);
++	strcpy(base, parentdir);
++	return true;
++}
+diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
+index 8f5874e..68f1a46 100644
+--- a/support/nsm/Makefile.am
++++ b/support/nsm/Makefile.am
+@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
+ EXTRA_DIST	= sm_inter.x
+ 
+ noinst_LIBRARIES = libnsm.a
+-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
+ 
+ BUILT_SOURCES = $(GENFILES)
+ 
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
new file mode 100644
index 00000000000..906ac0f9054
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
@@ -0,0 +1,50 @@
+From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Thu, 12 Jul 2018 15:19:41 +0800
+Subject: [PATCH] Makefile.am: update the path of libnfs.a
+
+The libnfs.a is under ../support/nfs/.libs/ now,
+update the reference path accordingly to fix below
+build error when run "make -C tests statdb_dump":
+| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
+
+And below error when run "make -C tests/nsm_client nsm_client"
+| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
+
+Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502636522745&w=2]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ tests/Makefile.am            | 2 +-
+ tests/nsm_client/Makefile.am | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 1f96264..74aa629 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -3,7 +3,7 @@
+ check_PROGRAMS = statdb_dump
+ statdb_dump_SOURCES = statdb_dump.c
+ 
+-statdb_dump_LDADD = ../support/nfs/libnfs.a \
++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
+ 		    ../support/nsm/libnsm.a $(LIBCAP)
+ 
+ SUBDIRS = nsm_client
+diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
+index a8fc131..43db9c2 100644
+--- a/tests/nsm_client/Makefile.am
++++ b/tests/nsm_client/Makefile.am
+@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
+ nsm_client_SOURCES = $(GENFILES) nsm_client.c
+ 
+ BUILT_SOURCES = $(GENFILES)
+-nsm_client_LDADD = ../../support/nfs/libnfs.a \
++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
+ 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
+ 
+ if CONFIG_RPCGEN
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
new file mode 100644
index 00000000000..17aabb9e4dc
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
@@ -0,0 +1,43 @@
+From 66471fbf7106917da7a1536b18a0a77d07479779 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Mon, 17 Dec 2018 15:29:47 +0800
+Subject: [PATCH] configure.ac: Do not fatalize -Wmissing-prototypes
+
+There comes below error when run "make -C tests/nsm_client nsm_client"
+| nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
+
+It is because rpcgen doesn't generate -Wmissing-prototypes
+free code for nlm_sm_inter_svc.c with below logic
+in tests/nsm_client/Makefile.am
+[snip]
+GENFILES_SVC    = nlm_sm_inter_svc.c
+[snip]
+$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
+        test -f $@ && rm -rf $@ || true
+        $(RPCGEN) -m -o $@ $<
+
+So add the logic not to fatalize -Wmissing-prototypes.
+
+Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154503260323936&w=2]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index e82ff14..d0cc5d5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -548,7 +548,7 @@ my_am_cflags="\
+  -Wall \
+  -Wextra \
+  -Werror=strict-prototypes \
+- -Werror=missing-prototypes \
++ -Wmissing-prototypes \
+  -Werror=missing-declarations \
+  -Werror=format=2 \
+  -Werror=undef \
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
index 6be2aab47c1..cabfc02c7e4 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
@@ -33,6 +33,9 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
            file://0001-cacheio-use-intmax_t-for-formatted-IO.patch \
            file://0001-Do-not-pass-null-pointer-to-freeaddrinfo.patch \
            file://clang-format-string.patch \
+           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
+           file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
+           file://0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch \
 "
 SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
 
-- 
2.17.1



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

* Re: [PATCH] nfs-utils: fix build error under tests folder
  2018-12-17  8:47 [PATCH] nfs-utils: fix build error under tests folder mingli.yu
@ 2018-12-17 17:16 ` richard.purdie
  2018-12-18  2:31   ` Yu, Mingli
  2018-12-18  5:21   ` [PATCH v2] " mingli.yu
  0 siblings, 2 replies; 10+ messages in thread
From: richard.purdie @ 2018-12-17 17:16 UTC (permalink / raw)
  To: mingli.yu, openembedded-core

On Mon, 2018-12-17 at 00:47 -0800, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
> 
> * Redefine the reference path of libnfs.a to
>   ../support/nfs/.libs/libnfs.a to fix below
>   error when run "make -C tests statdb_dump".
>   | make: *** No rule to make target '../support/nfs/libnfs.a',
> needed by 'statdb_dump'.  Stop.
>   | make: *** No rule to make target '../../support/nfs/libnfs.a',
> needed by 'nsm_client'.  Stop.
> 
> * The function generic_make_pathname is introduced in
>   nfs-utils 2.3.1.
>   Add the source file which defines function generic_make_pathname to
>   libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>   when run "make -C tests statdb_dump"
>   | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
> 2.3.1/support/nsm/file.c:175: undefined reference to
> `generic_make_pathname'
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
> 2.3.1/support/nsm/file.c:175: undefined reference to
> `generic_make_pathname'
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
> 2.3.1/support/nsm/file.c:175: undefined reference to
> `generic_make_pathname'
>   | ../support/nsm/libnsm.a(file.o): In function
> `nsm_setup_pathnames':
>   | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
> 2.3.1/support/nsm/file.c:280: undefined reference to
> `generic_setup_basedir'
>   | collect2: error: ld returned 1 exit status
> 
> * After the logic of commit[dbb643e Removed missing-prototypes
> warnings.]
>   introduced, there comes below error when run
>   "make -C tests/nsm_client nsm_client"
>   | nlm_sm_inter_svc.c:20:1: error: no previous prototype for
> 'nlm_sm_prog_3' [-Werror=missing-prototypes]
> 
>   It is because rpcgen doesn't generate -Wmissing-prototypes
>   free code for nlm_sm_inter_svc.c with below logic
>   in tests/nsm_client/Makefile.am
>   [snip]
>   GENFILES_SVC    = nlm_sm_inter_svc.c
>   [snip]
>   $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
>         test -f $@ && rm -rf $@ || true
>         $(RPCGEN) -m -o $@ $<
>  So add the patch to not fatalize -Wmissing-prototypes.

Fails on musl:

https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/104

Cheers,

Richard



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

* Re: [PATCH] nfs-utils: fix build error under tests folder
  2018-12-17 17:16 ` richard.purdie
@ 2018-12-18  2:31   ` Yu, Mingli
  2018-12-18  5:21   ` [PATCH v2] " mingli.yu
  1 sibling, 0 replies; 10+ messages in thread
From: Yu, Mingli @ 2018-12-18  2:31 UTC (permalink / raw)
  To: richard.purdie, openembedded-core



On 2018年12月18日 01:16, richard.purdie@linuxfoundation.org wrote:
> On Mon, 2018-12-17 at 00:47 -0800, mingli.yu@windriver.com wrote:
>> From: Mingli Yu <Mingli.Yu@windriver.com>
>>
>> * Redefine the reference path of libnfs.a to
>>    ../support/nfs/.libs/libnfs.a to fix below
>>    error when run "make -C tests statdb_dump".
>>    | make: *** No rule to make target '../support/nfs/libnfs.a',
>> needed by 'statdb_dump'.  Stop.
>>    | make: *** No rule to make target '../../support/nfs/libnfs.a',
>> needed by 'nsm_client'.  Stop.
>>
>> * The function generic_make_pathname is introduced in
>>    nfs-utils 2.3.1.
>>    Add the source file which defines function generic_make_pathname to
>>    libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>>    when run "make -C tests statdb_dump"
>>    | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
>> 2.3.1/support/nsm/file.c:175: undefined reference to
>> `generic_make_pathname'
>>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
>> 2.3.1/support/nsm/file.c:175: undefined reference to
>> `generic_make_pathname'
>>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
>> 2.3.1/support/nsm/file.c:175: undefined reference to
>> `generic_make_pathname'
>>    | ../support/nsm/libnsm.a(file.o): In function
>> `nsm_setup_pathnames':
>>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-
>> 2.3.1/support/nsm/file.c:280: undefined reference to
>> `generic_setup_basedir'
>>    | collect2: error: ld returned 1 exit status
>>
>> * After the logic of commit[dbb643e Removed missing-prototypes
>> warnings.]
>>    introduced, there comes below error when run
>>    "make -C tests/nsm_client nsm_client"
>>    | nlm_sm_inter_svc.c:20:1: error: no previous prototype for
>> 'nlm_sm_prog_3' [-Werror=missing-prototypes]
>>
>>    It is because rpcgen doesn't generate -Wmissing-prototypes
>>    free code for nlm_sm_inter_svc.c with below logic
>>    in tests/nsm_client/Makefile.am
>>    [snip]
>>    GENFILES_SVC    = nlm_sm_inter_svc.c
>>    [snip]
>>    $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
>>          test -f $@ && rm -rf $@ || true
>>          $(RPCGEN) -m -o $@ $<
>>   So add the patch to not fatalize -Wmissing-prototypes.
>
> Fails on musl:

Will send out V2 to fix it.

>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/104
>
> Cheers,
>
> Richard
>
>


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

* [PATCH v2] nfs-utils: fix build error under tests folder
  2018-12-17 17:16 ` richard.purdie
  2018-12-18  2:31   ` Yu, Mingli
@ 2018-12-18  5:21   ` mingli.yu
  2018-12-27  6:53     ` Yu, Mingli
                       ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: mingli.yu @ 2018-12-18  5:21 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

From: Mingli Yu <Mingli.Yu@windriver.com>

* Redefine the reference path of libnfs.a to
  ../support/nfs/.libs/libnfs.a to fix below
  error when run "make -C tests statdb_dump".
  | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
  | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.

* The function generic_make_pathname is introduced in
  nfs-utils 2.3.1.
  Add the source file which defines function generic_make_pathname to
  libnsm_a_SOURCES of libnsm.a to fix the undefined reference
  when run "make -C tests statdb_dump"
  | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
  | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
  | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
  | collect2: error: ld returned 1 exit status

* After the logic of commit[dbb643e Removed missing-prototypes warnings.]
  introduced, there comes below error when run
  "make -C tests/nsm_client nsm_client"
  | nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]

  It is because rpcgen doesn't generate -Wmissing-prototypes
  free code for nlm_sm_inter_svc.c with below logic
  in tests/nsm_client/Makefile.am
  [snip]
  GENFILES_SVC    = nlm_sm_inter_svc.c
  [snip]
  $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
        test -f $@ && rm -rf $@ || true
        $(RPCGEN) -m -o $@ $<
 So add the patch to not fatalize -Wmissing-prototypes.

Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
---
 ...-fix-undefined-function-for-libnsm.a.patch | 295 ++++++++++++++++++
 ...efile.am-update-the-path-of-libnfs.a.patch |  50 +++
 ...-Do-not-fatalize-Wmissing-prototypes.patch |  43 +++
 .../nfs-utils/nfs-utils_2.3.3.bb              |   3 +
 4 files changed, 391 insertions(+)
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
new file mode 100644
index 00000000000..aa551ebd191
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
@@ -0,0 +1,295 @@
+From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Fri, 14 Dec 2018 17:44:32 +0800
+Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
+
+The source file of libnsm.a uses some function
+in ../support/misc/file.c, add ../support/misc/file.c
+to libnsm_a_SOURCES to fix build error when run
+"make -C tests statdb_dump":
+| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
+| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
+| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
+| collect2: error: ld returned 1 exit status
+
+As there is already one source file named file.c
+as support/nsm/file.c in support/nsm/Makefile.am,
+so rename ../support/misc/file.c to ../support/misc/misc.c.
+
+Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ support/misc/Makefile.am |   2 +-
+ support/misc/file.c      | 111 -----------------------------------------------
+ support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
+ support/nsm/Makefile.am  |   2 +-
+ 4 files changed, 113 insertions(+), 113 deletions(-)
+ delete mode 100644 support/misc/file.c
+ create mode 100644 support/misc/misc.c
+
+diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
+index 8936b0d..d4c1f76 100644
+--- a/support/misc/Makefile.am
++++ b/support/misc/Makefile.am
+@@ -1,6 +1,6 @@
+ ## Process this file with automake to produce Makefile.in
+ 
+ noinst_LIBRARIES = libmisc.a
+-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
+ 
+ MAINTAINERCLEANFILES = Makefile.in
+diff --git a/support/misc/file.c b/support/misc/file.c
+deleted file mode 100644
+index e7c3819..0000000
+--- a/support/misc/file.c
++++ /dev/null
+@@ -1,111 +0,0 @@
+-/*
+- * Copyright 2009 Oracle.  All rights reserved.
+- * Copyright 2017 Red Hat, Inc.  All rights reserved.
+- *
+- * This file is part of nfs-utils.
+- *
+- * nfs-utils is free software; you can redistribute it and/or modify
+- * it under the terms of the GNU General Public License as published by
+- * the Free Software Foundation; either version 2 of the License, or
+- * (at your option) any later version.
+- *
+- * nfs-utils is distributed in the hope that it will be useful,
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+- * GNU General Public License for more details.
+- *
+- * You should have received a copy of the GNU General Public License
+- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
+- */
+-
+-#include <sys/stat.h>
+-
+-#include <string.h>
+-#include <libgen.h>
+-#include <stdio.h>
+-#include <errno.h>
+-#include <dirent.h>
+-#include <stdlib.h>
+-#include <stdbool.h>
+-#include <limits.h>
+-
+-#include "xlog.h"
+-#include "misc.h"
+-
+-/*
+- * Returns a dynamically allocated, '\0'-terminated buffer
+- * containing an appropriate pathname, or NULL if an error
+- * occurs.  Caller must free the returned result with free(3).
+- */
+-__attribute__((__malloc__))
+-char *
+-generic_make_pathname(const char *base, const char *leaf)
+-{
+-	size_t size;
+-	char *path;
+-	int len;
+-
+-	size = strlen(base) + strlen(leaf) + 2;
+-	if (size > PATH_MAX)
+-		return NULL;
+-
+-	path = malloc(size);
+-	if (path == NULL)
+-		return NULL;
+-
+-	len = snprintf(path, size, "%s/%s", base, leaf);
+-	if ((len < 0) || ((size_t)len >= size)) {
+-		free(path);
+-		return NULL;
+-	}
+-
+-	return path;
+-}
+-
+-
+-/**
+- * generic_setup_basedir - set up basedir
+- * @progname: C string containing name of program, for error messages
+- * @parentdir: C string containing pathname to on-disk state, or NULL
+- * @base: character buffer to contain the basedir that is set up
+- * @baselen: size of @base in bytes
+- *
+- * This runs before logging is set up, so error messages are directed
+- * to stderr.
+- *
+- * Returns true and sets up our basedir, if @parentdir was valid
+- * and usable; otherwise false is returned.
+- */
+-_Bool
+-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
+-		      const size_t baselen)
+-{
+-	static char buf[PATH_MAX];
+-	struct stat st;
+-	char *path;
+-
+-	/* First: test length of name and whether it exists */
+-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
+-		(void)fprintf(stderr, "%s: Directory name too long: %s",
+-				progname, parentdir);
+-		return false;
+-	}
+-	if (lstat(parentdir, &st) == -1) {
+-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
+-				progname, parentdir, strerror(errno));
+-		return false;
+-	}
+-
+-	/* Ensure we have a clean directory pathname */
+-	strncpy(buf, parentdir, sizeof(buf)-1);
+-	path = dirname(buf);
+-	if (*path == '.') {
+-		(void)fprintf(stderr, "%s: Unusable directory %s",
+-				progname, parentdir);
+-		return false;
+-	}
+-
+-	xlog(D_CALL, "Using %s as the state directory", parentdir);
+-	strcpy(base, parentdir);
+-	return true;
+-}
+diff --git a/support/misc/misc.c b/support/misc/misc.c
+new file mode 100644
+index 0000000..e7c3819
+--- /dev/null
++++ b/support/misc/misc.c
+@@ -0,0 +1,111 @@
++/*
++ * Copyright 2009 Oracle.  All rights reserved.
++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
++ *
++ * This file is part of nfs-utils.
++ *
++ * nfs-utils is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * nfs-utils is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <sys/stat.h>
++
++#include <string.h>
++#include <libgen.h>
++#include <stdio.h>
++#include <errno.h>
++#include <dirent.h>
++#include <stdlib.h>
++#include <stdbool.h>
++#include <limits.h>
++
++#include "xlog.h"
++#include "misc.h"
++
++/*
++ * Returns a dynamically allocated, '\0'-terminated buffer
++ * containing an appropriate pathname, or NULL if an error
++ * occurs.  Caller must free the returned result with free(3).
++ */
++__attribute__((__malloc__))
++char *
++generic_make_pathname(const char *base, const char *leaf)
++{
++	size_t size;
++	char *path;
++	int len;
++
++	size = strlen(base) + strlen(leaf) + 2;
++	if (size > PATH_MAX)
++		return NULL;
++
++	path = malloc(size);
++	if (path == NULL)
++		return NULL;
++
++	len = snprintf(path, size, "%s/%s", base, leaf);
++	if ((len < 0) || ((size_t)len >= size)) {
++		free(path);
++		return NULL;
++	}
++
++	return path;
++}
++
++
++/**
++ * generic_setup_basedir - set up basedir
++ * @progname: C string containing name of program, for error messages
++ * @parentdir: C string containing pathname to on-disk state, or NULL
++ * @base: character buffer to contain the basedir that is set up
++ * @baselen: size of @base in bytes
++ *
++ * This runs before logging is set up, so error messages are directed
++ * to stderr.
++ *
++ * Returns true and sets up our basedir, if @parentdir was valid
++ * and usable; otherwise false is returned.
++ */
++_Bool
++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
++		      const size_t baselen)
++{
++	static char buf[PATH_MAX];
++	struct stat st;
++	char *path;
++
++	/* First: test length of name and whether it exists */
++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
++		(void)fprintf(stderr, "%s: Directory name too long: %s",
++				progname, parentdir);
++		return false;
++	}
++	if (lstat(parentdir, &st) == -1) {
++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
++				progname, parentdir, strerror(errno));
++		return false;
++	}
++
++	/* Ensure we have a clean directory pathname */
++	strncpy(buf, parentdir, sizeof(buf)-1);
++	path = dirname(buf);
++	if (*path == '.') {
++		(void)fprintf(stderr, "%s: Unusable directory %s",
++				progname, parentdir);
++		return false;
++	}
++
++	xlog(D_CALL, "Using %s as the state directory", parentdir);
++	strcpy(base, parentdir);
++	return true;
++}
+diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
+index 8f5874e..68f1a46 100644
+--- a/support/nsm/Makefile.am
++++ b/support/nsm/Makefile.am
+@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
+ EXTRA_DIST	= sm_inter.x
+ 
+ noinst_LIBRARIES = libnsm.a
+-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
+ 
+ BUILT_SOURCES = $(GENFILES)
+ 
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
new file mode 100644
index 00000000000..906ac0f9054
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
@@ -0,0 +1,50 @@
+From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Thu, 12 Jul 2018 15:19:41 +0800
+Subject: [PATCH] Makefile.am: update the path of libnfs.a
+
+The libnfs.a is under ../support/nfs/.libs/ now,
+update the reference path accordingly to fix below
+build error when run "make -C tests statdb_dump":
+| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
+
+And below error when run "make -C tests/nsm_client nsm_client"
+| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
+
+Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502636522745&w=2]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ tests/Makefile.am            | 2 +-
+ tests/nsm_client/Makefile.am | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 1f96264..74aa629 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -3,7 +3,7 @@
+ check_PROGRAMS = statdb_dump
+ statdb_dump_SOURCES = statdb_dump.c
+ 
+-statdb_dump_LDADD = ../support/nfs/libnfs.a \
++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
+ 		    ../support/nsm/libnsm.a $(LIBCAP)
+ 
+ SUBDIRS = nsm_client
+diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
+index a8fc131..43db9c2 100644
+--- a/tests/nsm_client/Makefile.am
++++ b/tests/nsm_client/Makefile.am
+@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
+ nsm_client_SOURCES = $(GENFILES) nsm_client.c
+ 
+ BUILT_SOURCES = $(GENFILES)
+-nsm_client_LDADD = ../../support/nfs/libnfs.a \
++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
+ 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
+ 
+ if CONFIG_RPCGEN
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
new file mode 100644
index 00000000000..17aabb9e4dc
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
@@ -0,0 +1,43 @@
+From 66471fbf7106917da7a1536b18a0a77d07479779 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Mon, 17 Dec 2018 15:29:47 +0800
+Subject: [PATCH] configure.ac: Do not fatalize -Wmissing-prototypes
+
+There comes below error when run "make -C tests/nsm_client nsm_client"
+| nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
+
+It is because rpcgen doesn't generate -Wmissing-prototypes
+free code for nlm_sm_inter_svc.c with below logic
+in tests/nsm_client/Makefile.am
+[snip]
+GENFILES_SVC    = nlm_sm_inter_svc.c
+[snip]
+$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
+        test -f $@ && rm -rf $@ || true
+        $(RPCGEN) -m -o $@ $<
+
+So add the logic not to fatalize -Wmissing-prototypes.
+
+Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154503260323936&w=2]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index e82ff14..d0cc5d5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -548,7 +548,7 @@ my_am_cflags="\
+  -Wall \
+  -Wextra \
+  -Werror=strict-prototypes \
+- -Werror=missing-prototypes \
++ -Wmissing-prototypes \
+  -Werror=missing-declarations \
+  -Werror=format=2 \
+  -Werror=undef \
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
index 6be2aab47c1..52c609adb45 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
@@ -33,7 +33,10 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
            file://0001-cacheio-use-intmax_t-for-formatted-IO.patch \
            file://0001-Do-not-pass-null-pointer-to-freeaddrinfo.patch \
            file://clang-format-string.patch \
+           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
+           file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
 "
+SRC_URI_append_libc-glibc = " file://0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch"
 SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
 
 SRC_URI[md5sum] = "b6c9c032995af1c08fea9fbcc1ce33e9"
-- 
2.17.1



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

* Re: [PATCH v2] nfs-utils: fix build error under tests folder
  2018-12-18  5:21   ` [PATCH v2] " mingli.yu
@ 2018-12-27  6:53     ` Yu, Mingli
  2019-01-03  2:22     ` Yu, Mingli
  2019-01-11  6:51     ` Yu, Mingli
  2 siblings, 0 replies; 10+ messages in thread
From: Yu, Mingli @ 2018-12-27  6:53 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

Ping.

On 2018年12月18日 13:21, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
>
> * Redefine the reference path of libnfs.a to
>    ../support/nfs/.libs/libnfs.a to fix below
>    error when run "make -C tests statdb_dump".
>    | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
>    | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
>
> * The function generic_make_pathname is introduced in
>    nfs-utils 2.3.1.
>    Add the source file which defines function generic_make_pathname to
>    libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>    when run "make -C tests statdb_dump"
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
>    | collect2: error: ld returned 1 exit status
>
> * After the logic of commit[dbb643e Removed missing-prototypes warnings.]
>    introduced, there comes below error when run
>    "make -C tests/nsm_client nsm_client"
>    | nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
>
>    It is because rpcgen doesn't generate -Wmissing-prototypes
>    free code for nlm_sm_inter_svc.c with below logic
>    in tests/nsm_client/Makefile.am
>    [snip]
>    GENFILES_SVC    = nlm_sm_inter_svc.c
>    [snip]
>    $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
>          test -f $@ && rm -rf $@ || true
>          $(RPCGEN) -m -o $@ $<
>   So add the patch to not fatalize -Wmissing-prototypes.
>
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>   ...-fix-undefined-function-for-libnsm.a.patch | 295 ++++++++++++++++++
>   ...efile.am-update-the-path-of-libnfs.a.patch |  50 +++
>   ...-Do-not-fatalize-Wmissing-prototypes.patch |  43 +++
>   .../nfs-utils/nfs-utils_2.3.3.bb              |   3 +
>   4 files changed, 391 insertions(+)
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
>
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
> new file mode 100644
> index 00000000000..aa551ebd191
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
> @@ -0,0 +1,295 @@
> +From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Fri, 14 Dec 2018 17:44:32 +0800
> +Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
> +
> +The source file of libnsm.a uses some function
> +in ../support/misc/file.c, add ../support/misc/file.c
> +to libnsm_a_SOURCES to fix build error when run
> +"make -C tests statdb_dump":
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
> +| collect2: error: ld returned 1 exit status
> +
> +As there is already one source file named file.c
> +as support/nsm/file.c in support/nsm/Makefile.am,
> +so rename ../support/misc/file.c to ../support/misc/misc.c.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + support/misc/Makefile.am |   2 +-
> + support/misc/file.c      | 111 -----------------------------------------------
> + support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
> + support/nsm/Makefile.am  |   2 +-
> + 4 files changed, 113 insertions(+), 113 deletions(-)
> + delete mode 100644 support/misc/file.c
> + create mode 100644 support/misc/misc.c
> +
> +diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
> +index 8936b0d..d4c1f76 100644
> +--- a/support/misc/Makefile.am
> ++++ b/support/misc/Makefile.am
> +@@ -1,6 +1,6 @@
> + ## Process this file with automake to produce Makefile.in
> +
> + noinst_LIBRARIES = libmisc.a
> +-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
> ++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
> +
> + MAINTAINERCLEANFILES = Makefile.in
> +diff --git a/support/misc/file.c b/support/misc/file.c
> +deleted file mode 100644
> +index e7c3819..0000000
> +--- a/support/misc/file.c
> ++++ /dev/null
> +@@ -1,111 +0,0 @@
> +-/*
> +- * Copyright 2009 Oracle.  All rights reserved.
> +- * Copyright 2017 Red Hat, Inc.  All rights reserved.
> +- *
> +- * This file is part of nfs-utils.
> +- *
> +- * nfs-utils is free software; you can redistribute it and/or modify
> +- * it under the terms of the GNU General Public License as published by
> +- * the Free Software Foundation; either version 2 of the License, or
> +- * (at your option) any later version.
> +- *
> +- * nfs-utils is distributed in the hope that it will be useful,
> +- * but WITHOUT ANY WARRANTY; without even the implied warranty of
> +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +- * GNU General Public License for more details.
> +- *
> +- * You should have received a copy of the GNU General Public License
> +- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> +- */
> +-
> +-#include <sys/stat.h>
> +-
> +-#include <string.h>
> +-#include <libgen.h>
> +-#include <stdio.h>
> +-#include <errno.h>
> +-#include <dirent.h>
> +-#include <stdlib.h>
> +-#include <stdbool.h>
> +-#include <limits.h>
> +-
> +-#include "xlog.h"
> +-#include "misc.h"
> +-
> +-/*
> +- * Returns a dynamically allocated, '\0'-terminated buffer
> +- * containing an appropriate pathname, or NULL if an error
> +- * occurs.  Caller must free the returned result with free(3).
> +- */
> +-__attribute__((__malloc__))
> +-char *
> +-generic_make_pathname(const char *base, const char *leaf)
> +-{
> +-	size_t size;
> +-	char *path;
> +-	int len;
> +-
> +-	size = strlen(base) + strlen(leaf) + 2;
> +-	if (size > PATH_MAX)
> +-		return NULL;
> +-
> +-	path = malloc(size);
> +-	if (path == NULL)
> +-		return NULL;
> +-
> +-	len = snprintf(path, size, "%s/%s", base, leaf);
> +-	if ((len < 0) || ((size_t)len >= size)) {
> +-		free(path);
> +-		return NULL;
> +-	}
> +-
> +-	return path;
> +-}
> +-
> +-
> +-/**
> +- * generic_setup_basedir - set up basedir
> +- * @progname: C string containing name of program, for error messages
> +- * @parentdir: C string containing pathname to on-disk state, or NULL
> +- * @base: character buffer to contain the basedir that is set up
> +- * @baselen: size of @base in bytes
> +- *
> +- * This runs before logging is set up, so error messages are directed
> +- * to stderr.
> +- *
> +- * Returns true and sets up our basedir, if @parentdir was valid
> +- * and usable; otherwise false is returned.
> +- */
> +-_Bool
> +-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> +-		      const size_t baselen)
> +-{
> +-	static char buf[PATH_MAX];
> +-	struct stat st;
> +-	char *path;
> +-
> +-	/* First: test length of name and whether it exists */
> +-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> +-		(void)fprintf(stderr, "%s: Directory name too long: %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-	if (lstat(parentdir, &st) == -1) {
> +-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> +-				progname, parentdir, strerror(errno));
> +-		return false;
> +-	}
> +-
> +-	/* Ensure we have a clean directory pathname */
> +-	strncpy(buf, parentdir, sizeof(buf)-1);
> +-	path = dirname(buf);
> +-	if (*path == '.') {
> +-		(void)fprintf(stderr, "%s: Unusable directory %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-
> +-	xlog(D_CALL, "Using %s as the state directory", parentdir);
> +-	strcpy(base, parentdir);
> +-	return true;
> +-}
> +diff --git a/support/misc/misc.c b/support/misc/misc.c
> +new file mode 100644
> +index 0000000..e7c3819
> +--- /dev/null
> ++++ b/support/misc/misc.c
> +@@ -0,0 +1,111 @@
> ++/*
> ++ * Copyright 2009 Oracle.  All rights reserved.
> ++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
> ++ *
> ++ * This file is part of nfs-utils.
> ++ *
> ++ * nfs-utils is free software; you can redistribute it and/or modify
> ++ * it under the terms of the GNU General Public License as published by
> ++ * the Free Software Foundation; either version 2 of the License, or
> ++ * (at your option) any later version.
> ++ *
> ++ * nfs-utils is distributed in the hope that it will be useful,
> ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ++ * GNU General Public License for more details.
> ++ *
> ++ * You should have received a copy of the GNU General Public License
> ++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> ++ */
> ++
> ++#include <sys/stat.h>
> ++
> ++#include <string.h>
> ++#include <libgen.h>
> ++#include <stdio.h>
> ++#include <errno.h>
> ++#include <dirent.h>
> ++#include <stdlib.h>
> ++#include <stdbool.h>
> ++#include <limits.h>
> ++
> ++#include "xlog.h"
> ++#include "misc.h"
> ++
> ++/*
> ++ * Returns a dynamically allocated, '\0'-terminated buffer
> ++ * containing an appropriate pathname, or NULL if an error
> ++ * occurs.  Caller must free the returned result with free(3).
> ++ */
> ++__attribute__((__malloc__))
> ++char *
> ++generic_make_pathname(const char *base, const char *leaf)
> ++{
> ++	size_t size;
> ++	char *path;
> ++	int len;
> ++
> ++	size = strlen(base) + strlen(leaf) + 2;
> ++	if (size > PATH_MAX)
> ++		return NULL;
> ++
> ++	path = malloc(size);
> ++	if (path == NULL)
> ++		return NULL;
> ++
> ++	len = snprintf(path, size, "%s/%s", base, leaf);
> ++	if ((len < 0) || ((size_t)len >= size)) {
> ++		free(path);
> ++		return NULL;
> ++	}
> ++
> ++	return path;
> ++}
> ++
> ++
> ++/**
> ++ * generic_setup_basedir - set up basedir
> ++ * @progname: C string containing name of program, for error messages
> ++ * @parentdir: C string containing pathname to on-disk state, or NULL
> ++ * @base: character buffer to contain the basedir that is set up
> ++ * @baselen: size of @base in bytes
> ++ *
> ++ * This runs before logging is set up, so error messages are directed
> ++ * to stderr.
> ++ *
> ++ * Returns true and sets up our basedir, if @parentdir was valid
> ++ * and usable; otherwise false is returned.
> ++ */
> ++_Bool
> ++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> ++		      const size_t baselen)
> ++{
> ++	static char buf[PATH_MAX];
> ++	struct stat st;
> ++	char *path;
> ++
> ++	/* First: test length of name and whether it exists */
> ++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> ++		(void)fprintf(stderr, "%s: Directory name too long: %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++	if (lstat(parentdir, &st) == -1) {
> ++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> ++				progname, parentdir, strerror(errno));
> ++		return false;
> ++	}
> ++
> ++	/* Ensure we have a clean directory pathname */
> ++	strncpy(buf, parentdir, sizeof(buf)-1);
> ++	path = dirname(buf);
> ++	if (*path == '.') {
> ++		(void)fprintf(stderr, "%s: Unusable directory %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++
> ++	xlog(D_CALL, "Using %s as the state directory", parentdir);
> ++	strcpy(base, parentdir);
> ++	return true;
> ++}
> +diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
> +index 8f5874e..68f1a46 100644
> +--- a/support/nsm/Makefile.am
> ++++ b/support/nsm/Makefile.am
> +@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
> + EXTRA_DIST	= sm_inter.x
> +
> + noinst_LIBRARIES = libnsm.a
> +-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
> ++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> new file mode 100644
> index 00000000000..906ac0f9054
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> @@ -0,0 +1,50 @@
> +From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 15:19:41 +0800
> +Subject: [PATCH] Makefile.am: update the path of libnfs.a
> +
> +The libnfs.a is under ../support/nfs/.libs/ now,
> +update the reference path accordingly to fix below
> +build error when run "make -C tests statdb_dump":
> +| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
> +
> +And below error when run "make -C tests/nsm_client nsm_client"
> +| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502636522745&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + tests/Makefile.am            | 2 +-
> + tests/nsm_client/Makefile.am | 2 +-
> + 2 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/Makefile.am b/tests/Makefile.am
> +index 1f96264..74aa629 100644
> +--- a/tests/Makefile.am
> ++++ b/tests/Makefile.am
> +@@ -3,7 +3,7 @@
> + check_PROGRAMS = statdb_dump
> + statdb_dump_SOURCES = statdb_dump.c
> +
> +-statdb_dump_LDADD = ../support/nfs/libnfs.a \
> ++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
> + 		    ../support/nsm/libnsm.a $(LIBCAP)
> +
> + SUBDIRS = nsm_client
> +diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
> +index a8fc131..43db9c2 100644
> +--- a/tests/nsm_client/Makefile.am
> ++++ b/tests/nsm_client/Makefile.am
> +@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
> + nsm_client_SOURCES = $(GENFILES) nsm_client.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +-nsm_client_LDADD = ../../support/nfs/libnfs.a \
> ++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
> + 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
> +
> + if CONFIG_RPCGEN
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
> new file mode 100644
> index 00000000000..17aabb9e4dc
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
> @@ -0,0 +1,43 @@
> +From 66471fbf7106917da7a1536b18a0a77d07479779 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Mon, 17 Dec 2018 15:29:47 +0800
> +Subject: [PATCH] configure.ac: Do not fatalize -Wmissing-prototypes
> +
> +There comes below error when run "make -C tests/nsm_client nsm_client"
> +| nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
> +
> +It is because rpcgen doesn't generate -Wmissing-prototypes
> +free code for nlm_sm_inter_svc.c with below logic
> +in tests/nsm_client/Makefile.am
> +[snip]
> +GENFILES_SVC    = nlm_sm_inter_svc.c
> +[snip]
> +$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
> +        test -f $@ && rm -rf $@ || true
> +        $(RPCGEN) -m -o $@ $<
> +
> +So add the logic not to fatalize -Wmissing-prototypes.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154503260323936&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + configure.ac | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/configure.ac b/configure.ac
> +index e82ff14..d0cc5d5 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -548,7 +548,7 @@ my_am_cflags="\
> +  -Wall \
> +  -Wextra \
> +  -Werror=strict-prototypes \
> +- -Werror=missing-prototypes \
> ++ -Wmissing-prototypes \
> +  -Werror=missing-declarations \
> +  -Werror=format=2 \
> +  -Werror=undef \
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> index 6be2aab47c1..52c609adb45 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> @@ -33,7 +33,10 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>              file://0001-cacheio-use-intmax_t-for-formatted-IO.patch \
>              file://0001-Do-not-pass-null-pointer-to-freeaddrinfo.patch \
>              file://clang-format-string.patch \
> +           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
> +           file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
>   "
> +SRC_URI_append_libc-glibc = " file://0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch"
>   SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
>
>   SRC_URI[md5sum] = "b6c9c032995af1c08fea9fbcc1ce33e9"
>


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

* Re: [PATCH v2] nfs-utils: fix build error under tests folder
  2018-12-18  5:21   ` [PATCH v2] " mingli.yu
  2018-12-27  6:53     ` Yu, Mingli
@ 2019-01-03  2:22     ` Yu, Mingli
  2019-01-11  6:51     ` Yu, Mingli
  2 siblings, 0 replies; 10+ messages in thread
From: Yu, Mingli @ 2019-01-03  2:22 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

Ping.

On 2018年12月18日 13:21, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
>
> * Redefine the reference path of libnfs.a to
>    ../support/nfs/.libs/libnfs.a to fix below
>    error when run "make -C tests statdb_dump".
>    | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
>    | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
>
> * The function generic_make_pathname is introduced in
>    nfs-utils 2.3.1.
>    Add the source file which defines function generic_make_pathname to
>    libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>    when run "make -C tests statdb_dump"
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
>    | collect2: error: ld returned 1 exit status
>
> * After the logic of commit[dbb643e Removed missing-prototypes warnings.]
>    introduced, there comes below error when run
>    "make -C tests/nsm_client nsm_client"
>    | nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
>
>    It is because rpcgen doesn't generate -Wmissing-prototypes
>    free code for nlm_sm_inter_svc.c with below logic
>    in tests/nsm_client/Makefile.am
>    [snip]
>    GENFILES_SVC    = nlm_sm_inter_svc.c
>    [snip]
>    $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
>          test -f $@ && rm -rf $@ || true
>          $(RPCGEN) -m -o $@ $<
>   So add the patch to not fatalize -Wmissing-prototypes.
>
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>   ...-fix-undefined-function-for-libnsm.a.patch | 295 ++++++++++++++++++
>   ...efile.am-update-the-path-of-libnfs.a.patch |  50 +++
>   ...-Do-not-fatalize-Wmissing-prototypes.patch |  43 +++
>   .../nfs-utils/nfs-utils_2.3.3.bb              |   3 +
>   4 files changed, 391 insertions(+)
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
>
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
> new file mode 100644
> index 00000000000..aa551ebd191
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
> @@ -0,0 +1,295 @@
> +From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Fri, 14 Dec 2018 17:44:32 +0800
> +Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
> +
> +The source file of libnsm.a uses some function
> +in ../support/misc/file.c, add ../support/misc/file.c
> +to libnsm_a_SOURCES to fix build error when run
> +"make -C tests statdb_dump":
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
> +| collect2: error: ld returned 1 exit status
> +
> +As there is already one source file named file.c
> +as support/nsm/file.c in support/nsm/Makefile.am,
> +so rename ../support/misc/file.c to ../support/misc/misc.c.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + support/misc/Makefile.am |   2 +-
> + support/misc/file.c      | 111 -----------------------------------------------
> + support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
> + support/nsm/Makefile.am  |   2 +-
> + 4 files changed, 113 insertions(+), 113 deletions(-)
> + delete mode 100644 support/misc/file.c
> + create mode 100644 support/misc/misc.c
> +
> +diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
> +index 8936b0d..d4c1f76 100644
> +--- a/support/misc/Makefile.am
> ++++ b/support/misc/Makefile.am
> +@@ -1,6 +1,6 @@
> + ## Process this file with automake to produce Makefile.in
> +
> + noinst_LIBRARIES = libmisc.a
> +-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
> ++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
> +
> + MAINTAINERCLEANFILES = Makefile.in
> +diff --git a/support/misc/file.c b/support/misc/file.c
> +deleted file mode 100644
> +index e7c3819..0000000
> +--- a/support/misc/file.c
> ++++ /dev/null
> +@@ -1,111 +0,0 @@
> +-/*
> +- * Copyright 2009 Oracle.  All rights reserved.
> +- * Copyright 2017 Red Hat, Inc.  All rights reserved.
> +- *
> +- * This file is part of nfs-utils.
> +- *
> +- * nfs-utils is free software; you can redistribute it and/or modify
> +- * it under the terms of the GNU General Public License as published by
> +- * the Free Software Foundation; either version 2 of the License, or
> +- * (at your option) any later version.
> +- *
> +- * nfs-utils is distributed in the hope that it will be useful,
> +- * but WITHOUT ANY WARRANTY; without even the implied warranty of
> +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +- * GNU General Public License for more details.
> +- *
> +- * You should have received a copy of the GNU General Public License
> +- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> +- */
> +-
> +-#include <sys/stat.h>
> +-
> +-#include <string.h>
> +-#include <libgen.h>
> +-#include <stdio.h>
> +-#include <errno.h>
> +-#include <dirent.h>
> +-#include <stdlib.h>
> +-#include <stdbool.h>
> +-#include <limits.h>
> +-
> +-#include "xlog.h"
> +-#include "misc.h"
> +-
> +-/*
> +- * Returns a dynamically allocated, '\0'-terminated buffer
> +- * containing an appropriate pathname, or NULL if an error
> +- * occurs.  Caller must free the returned result with free(3).
> +- */
> +-__attribute__((__malloc__))
> +-char *
> +-generic_make_pathname(const char *base, const char *leaf)
> +-{
> +-	size_t size;
> +-	char *path;
> +-	int len;
> +-
> +-	size = strlen(base) + strlen(leaf) + 2;
> +-	if (size > PATH_MAX)
> +-		return NULL;
> +-
> +-	path = malloc(size);
> +-	if (path == NULL)
> +-		return NULL;
> +-
> +-	len = snprintf(path, size, "%s/%s", base, leaf);
> +-	if ((len < 0) || ((size_t)len >= size)) {
> +-		free(path);
> +-		return NULL;
> +-	}
> +-
> +-	return path;
> +-}
> +-
> +-
> +-/**
> +- * generic_setup_basedir - set up basedir
> +- * @progname: C string containing name of program, for error messages
> +- * @parentdir: C string containing pathname to on-disk state, or NULL
> +- * @base: character buffer to contain the basedir that is set up
> +- * @baselen: size of @base in bytes
> +- *
> +- * This runs before logging is set up, so error messages are directed
> +- * to stderr.
> +- *
> +- * Returns true and sets up our basedir, if @parentdir was valid
> +- * and usable; otherwise false is returned.
> +- */
> +-_Bool
> +-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> +-		      const size_t baselen)
> +-{
> +-	static char buf[PATH_MAX];
> +-	struct stat st;
> +-	char *path;
> +-
> +-	/* First: test length of name and whether it exists */
> +-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> +-		(void)fprintf(stderr, "%s: Directory name too long: %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-	if (lstat(parentdir, &st) == -1) {
> +-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> +-				progname, parentdir, strerror(errno));
> +-		return false;
> +-	}
> +-
> +-	/* Ensure we have a clean directory pathname */
> +-	strncpy(buf, parentdir, sizeof(buf)-1);
> +-	path = dirname(buf);
> +-	if (*path == '.') {
> +-		(void)fprintf(stderr, "%s: Unusable directory %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-
> +-	xlog(D_CALL, "Using %s as the state directory", parentdir);
> +-	strcpy(base, parentdir);
> +-	return true;
> +-}
> +diff --git a/support/misc/misc.c b/support/misc/misc.c
> +new file mode 100644
> +index 0000000..e7c3819
> +--- /dev/null
> ++++ b/support/misc/misc.c
> +@@ -0,0 +1,111 @@
> ++/*
> ++ * Copyright 2009 Oracle.  All rights reserved.
> ++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
> ++ *
> ++ * This file is part of nfs-utils.
> ++ *
> ++ * nfs-utils is free software; you can redistribute it and/or modify
> ++ * it under the terms of the GNU General Public License as published by
> ++ * the Free Software Foundation; either version 2 of the License, or
> ++ * (at your option) any later version.
> ++ *
> ++ * nfs-utils is distributed in the hope that it will be useful,
> ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ++ * GNU General Public License for more details.
> ++ *
> ++ * You should have received a copy of the GNU General Public License
> ++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> ++ */
> ++
> ++#include <sys/stat.h>
> ++
> ++#include <string.h>
> ++#include <libgen.h>
> ++#include <stdio.h>
> ++#include <errno.h>
> ++#include <dirent.h>
> ++#include <stdlib.h>
> ++#include <stdbool.h>
> ++#include <limits.h>
> ++
> ++#include "xlog.h"
> ++#include "misc.h"
> ++
> ++/*
> ++ * Returns a dynamically allocated, '\0'-terminated buffer
> ++ * containing an appropriate pathname, or NULL if an error
> ++ * occurs.  Caller must free the returned result with free(3).
> ++ */
> ++__attribute__((__malloc__))
> ++char *
> ++generic_make_pathname(const char *base, const char *leaf)
> ++{
> ++	size_t size;
> ++	char *path;
> ++	int len;
> ++
> ++	size = strlen(base) + strlen(leaf) + 2;
> ++	if (size > PATH_MAX)
> ++		return NULL;
> ++
> ++	path = malloc(size);
> ++	if (path == NULL)
> ++		return NULL;
> ++
> ++	len = snprintf(path, size, "%s/%s", base, leaf);
> ++	if ((len < 0) || ((size_t)len >= size)) {
> ++		free(path);
> ++		return NULL;
> ++	}
> ++
> ++	return path;
> ++}
> ++
> ++
> ++/**
> ++ * generic_setup_basedir - set up basedir
> ++ * @progname: C string containing name of program, for error messages
> ++ * @parentdir: C string containing pathname to on-disk state, or NULL
> ++ * @base: character buffer to contain the basedir that is set up
> ++ * @baselen: size of @base in bytes
> ++ *
> ++ * This runs before logging is set up, so error messages are directed
> ++ * to stderr.
> ++ *
> ++ * Returns true and sets up our basedir, if @parentdir was valid
> ++ * and usable; otherwise false is returned.
> ++ */
> ++_Bool
> ++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> ++		      const size_t baselen)
> ++{
> ++	static char buf[PATH_MAX];
> ++	struct stat st;
> ++	char *path;
> ++
> ++	/* First: test length of name and whether it exists */
> ++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> ++		(void)fprintf(stderr, "%s: Directory name too long: %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++	if (lstat(parentdir, &st) == -1) {
> ++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> ++				progname, parentdir, strerror(errno));
> ++		return false;
> ++	}
> ++
> ++	/* Ensure we have a clean directory pathname */
> ++	strncpy(buf, parentdir, sizeof(buf)-1);
> ++	path = dirname(buf);
> ++	if (*path == '.') {
> ++		(void)fprintf(stderr, "%s: Unusable directory %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++
> ++	xlog(D_CALL, "Using %s as the state directory", parentdir);
> ++	strcpy(base, parentdir);
> ++	return true;
> ++}
> +diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
> +index 8f5874e..68f1a46 100644
> +--- a/support/nsm/Makefile.am
> ++++ b/support/nsm/Makefile.am
> +@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
> + EXTRA_DIST	= sm_inter.x
> +
> + noinst_LIBRARIES = libnsm.a
> +-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
> ++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> new file mode 100644
> index 00000000000..906ac0f9054
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> @@ -0,0 +1,50 @@
> +From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 15:19:41 +0800
> +Subject: [PATCH] Makefile.am: update the path of libnfs.a
> +
> +The libnfs.a is under ../support/nfs/.libs/ now,
> +update the reference path accordingly to fix below
> +build error when run "make -C tests statdb_dump":
> +| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
> +
> +And below error when run "make -C tests/nsm_client nsm_client"
> +| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502636522745&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + tests/Makefile.am            | 2 +-
> + tests/nsm_client/Makefile.am | 2 +-
> + 2 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/Makefile.am b/tests/Makefile.am
> +index 1f96264..74aa629 100644
> +--- a/tests/Makefile.am
> ++++ b/tests/Makefile.am
> +@@ -3,7 +3,7 @@
> + check_PROGRAMS = statdb_dump
> + statdb_dump_SOURCES = statdb_dump.c
> +
> +-statdb_dump_LDADD = ../support/nfs/libnfs.a \
> ++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
> + 		    ../support/nsm/libnsm.a $(LIBCAP)
> +
> + SUBDIRS = nsm_client
> +diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
> +index a8fc131..43db9c2 100644
> +--- a/tests/nsm_client/Makefile.am
> ++++ b/tests/nsm_client/Makefile.am
> +@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
> + nsm_client_SOURCES = $(GENFILES) nsm_client.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +-nsm_client_LDADD = ../../support/nfs/libnfs.a \
> ++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
> + 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
> +
> + if CONFIG_RPCGEN
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
> new file mode 100644
> index 00000000000..17aabb9e4dc
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
> @@ -0,0 +1,43 @@
> +From 66471fbf7106917da7a1536b18a0a77d07479779 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Mon, 17 Dec 2018 15:29:47 +0800
> +Subject: [PATCH] configure.ac: Do not fatalize -Wmissing-prototypes
> +
> +There comes below error when run "make -C tests/nsm_client nsm_client"
> +| nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
> +
> +It is because rpcgen doesn't generate -Wmissing-prototypes
> +free code for nlm_sm_inter_svc.c with below logic
> +in tests/nsm_client/Makefile.am
> +[snip]
> +GENFILES_SVC    = nlm_sm_inter_svc.c
> +[snip]
> +$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
> +        test -f $@ && rm -rf $@ || true
> +        $(RPCGEN) -m -o $@ $<
> +
> +So add the logic not to fatalize -Wmissing-prototypes.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154503260323936&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + configure.ac | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/configure.ac b/configure.ac
> +index e82ff14..d0cc5d5 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -548,7 +548,7 @@ my_am_cflags="\
> +  -Wall \
> +  -Wextra \
> +  -Werror=strict-prototypes \
> +- -Werror=missing-prototypes \
> ++ -Wmissing-prototypes \
> +  -Werror=missing-declarations \
> +  -Werror=format=2 \
> +  -Werror=undef \
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> index 6be2aab47c1..52c609adb45 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> @@ -33,7 +33,10 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>              file://0001-cacheio-use-intmax_t-for-formatted-IO.patch \
>              file://0001-Do-not-pass-null-pointer-to-freeaddrinfo.patch \
>              file://clang-format-string.patch \
> +           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
> +           file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
>   "
> +SRC_URI_append_libc-glibc = " file://0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch"
>   SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
>
>   SRC_URI[md5sum] = "b6c9c032995af1c08fea9fbcc1ce33e9"
>


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

* Re: [PATCH v2] nfs-utils: fix build error under tests folder
  2018-12-18  5:21   ` [PATCH v2] " mingli.yu
  2018-12-27  6:53     ` Yu, Mingli
  2019-01-03  2:22     ` Yu, Mingli
@ 2019-01-11  6:51     ` Yu, Mingli
  2 siblings, 0 replies; 10+ messages in thread
From: Yu, Mingli @ 2019-01-11  6:51 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

Ping.

On 2018年12月18日 13:21, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
>
> * Redefine the reference path of libnfs.a to
>    ../support/nfs/.libs/libnfs.a to fix below
>    error when run "make -C tests statdb_dump".
>    | make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
>    | make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
>
> * The function generic_make_pathname is introduced in
>    nfs-utils 2.3.1.
>    Add the source file which defines function generic_make_pathname to
>    libnsm_a_SOURCES of libnsm.a to fix the undefined reference
>    when run "make -C tests statdb_dump"
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
>    | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
>    | /usr/src/debug/nfs-utils/2.3.1-r0/nfs-utils-2.3.1/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
>    | collect2: error: ld returned 1 exit status
>
> * After the logic of commit[dbb643e Removed missing-prototypes warnings.]
>    introduced, there comes below error when run
>    "make -C tests/nsm_client nsm_client"
>    | nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
>
>    It is because rpcgen doesn't generate -Wmissing-prototypes
>    free code for nlm_sm_inter_svc.c with below logic
>    in tests/nsm_client/Makefile.am
>    [snip]
>    GENFILES_SVC    = nlm_sm_inter_svc.c
>    [snip]
>    $(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
>          test -f $@ && rm -rf $@ || true
>          $(RPCGEN) -m -o $@ $<
>   So add the patch to not fatalize -Wmissing-prototypes.
>
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>   ...-fix-undefined-function-for-libnsm.a.patch | 295 ++++++++++++++++++
>   ...efile.am-update-the-path-of-libnfs.a.patch |  50 +++
>   ...-Do-not-fatalize-Wmissing-prototypes.patch |  43 +++
>   .../nfs-utils/nfs-utils_2.3.3.bb              |   3 +
>   4 files changed, 391 insertions(+)
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
>   create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
>
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
> new file mode 100644
> index 00000000000..aa551ebd191
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
> @@ -0,0 +1,295 @@
> +From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Fri, 14 Dec 2018 17:44:32 +0800
> +Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
> +
> +The source file of libnsm.a uses some function
> +in ../support/misc/file.c, add ../support/misc/file.c
> +to libnsm_a_SOURCES to fix build error when run
> +"make -C tests statdb_dump":
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
> +| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
> +| /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
> +| collect2: error: ld returned 1 exit status
> +
> +As there is already one source file named file.c
> +as support/nsm/file.c in support/nsm/Makefile.am,
> +so rename ../support/misc/file.c to ../support/misc/misc.c.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + support/misc/Makefile.am |   2 +-
> + support/misc/file.c      | 111 -----------------------------------------------
> + support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
> + support/nsm/Makefile.am  |   2 +-
> + 4 files changed, 113 insertions(+), 113 deletions(-)
> + delete mode 100644 support/misc/file.c
> + create mode 100644 support/misc/misc.c
> +
> +diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
> +index 8936b0d..d4c1f76 100644
> +--- a/support/misc/Makefile.am
> ++++ b/support/misc/Makefile.am
> +@@ -1,6 +1,6 @@
> + ## Process this file with automake to produce Makefile.in
> +
> + noinst_LIBRARIES = libmisc.a
> +-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
> ++libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
> +
> + MAINTAINERCLEANFILES = Makefile.in
> +diff --git a/support/misc/file.c b/support/misc/file.c
> +deleted file mode 100644
> +index e7c3819..0000000
> +--- a/support/misc/file.c
> ++++ /dev/null
> +@@ -1,111 +0,0 @@
> +-/*
> +- * Copyright 2009 Oracle.  All rights reserved.
> +- * Copyright 2017 Red Hat, Inc.  All rights reserved.
> +- *
> +- * This file is part of nfs-utils.
> +- *
> +- * nfs-utils is free software; you can redistribute it and/or modify
> +- * it under the terms of the GNU General Public License as published by
> +- * the Free Software Foundation; either version 2 of the License, or
> +- * (at your option) any later version.
> +- *
> +- * nfs-utils is distributed in the hope that it will be useful,
> +- * but WITHOUT ANY WARRANTY; without even the implied warranty of
> +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +- * GNU General Public License for more details.
> +- *
> +- * You should have received a copy of the GNU General Public License
> +- * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> +- */
> +-
> +-#include <sys/stat.h>
> +-
> +-#include <string.h>
> +-#include <libgen.h>
> +-#include <stdio.h>
> +-#include <errno.h>
> +-#include <dirent.h>
> +-#include <stdlib.h>
> +-#include <stdbool.h>
> +-#include <limits.h>
> +-
> +-#include "xlog.h"
> +-#include "misc.h"
> +-
> +-/*
> +- * Returns a dynamically allocated, '\0'-terminated buffer
> +- * containing an appropriate pathname, or NULL if an error
> +- * occurs.  Caller must free the returned result with free(3).
> +- */
> +-__attribute__((__malloc__))
> +-char *
> +-generic_make_pathname(const char *base, const char *leaf)
> +-{
> +-	size_t size;
> +-	char *path;
> +-	int len;
> +-
> +-	size = strlen(base) + strlen(leaf) + 2;
> +-	if (size > PATH_MAX)
> +-		return NULL;
> +-
> +-	path = malloc(size);
> +-	if (path == NULL)
> +-		return NULL;
> +-
> +-	len = snprintf(path, size, "%s/%s", base, leaf);
> +-	if ((len < 0) || ((size_t)len >= size)) {
> +-		free(path);
> +-		return NULL;
> +-	}
> +-
> +-	return path;
> +-}
> +-
> +-
> +-/**
> +- * generic_setup_basedir - set up basedir
> +- * @progname: C string containing name of program, for error messages
> +- * @parentdir: C string containing pathname to on-disk state, or NULL
> +- * @base: character buffer to contain the basedir that is set up
> +- * @baselen: size of @base in bytes
> +- *
> +- * This runs before logging is set up, so error messages are directed
> +- * to stderr.
> +- *
> +- * Returns true and sets up our basedir, if @parentdir was valid
> +- * and usable; otherwise false is returned.
> +- */
> +-_Bool
> +-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> +-		      const size_t baselen)
> +-{
> +-	static char buf[PATH_MAX];
> +-	struct stat st;
> +-	char *path;
> +-
> +-	/* First: test length of name and whether it exists */
> +-	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> +-		(void)fprintf(stderr, "%s: Directory name too long: %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-	if (lstat(parentdir, &st) == -1) {
> +-		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> +-				progname, parentdir, strerror(errno));
> +-		return false;
> +-	}
> +-
> +-	/* Ensure we have a clean directory pathname */
> +-	strncpy(buf, parentdir, sizeof(buf)-1);
> +-	path = dirname(buf);
> +-	if (*path == '.') {
> +-		(void)fprintf(stderr, "%s: Unusable directory %s",
> +-				progname, parentdir);
> +-		return false;
> +-	}
> +-
> +-	xlog(D_CALL, "Using %s as the state directory", parentdir);
> +-	strcpy(base, parentdir);
> +-	return true;
> +-}
> +diff --git a/support/misc/misc.c b/support/misc/misc.c
> +new file mode 100644
> +index 0000000..e7c3819
> +--- /dev/null
> ++++ b/support/misc/misc.c
> +@@ -0,0 +1,111 @@
> ++/*
> ++ * Copyright 2009 Oracle.  All rights reserved.
> ++ * Copyright 2017 Red Hat, Inc.  All rights reserved.
> ++ *
> ++ * This file is part of nfs-utils.
> ++ *
> ++ * nfs-utils is free software; you can redistribute it and/or modify
> ++ * it under the terms of the GNU General Public License as published by
> ++ * the Free Software Foundation; either version 2 of the License, or
> ++ * (at your option) any later version.
> ++ *
> ++ * nfs-utils is distributed in the hope that it will be useful,
> ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ++ * GNU General Public License for more details.
> ++ *
> ++ * You should have received a copy of the GNU General Public License
> ++ * along with nfs-utils.  If not, see <http://www.gnu.org/licenses/>.
> ++ */
> ++
> ++#include <sys/stat.h>
> ++
> ++#include <string.h>
> ++#include <libgen.h>
> ++#include <stdio.h>
> ++#include <errno.h>
> ++#include <dirent.h>
> ++#include <stdlib.h>
> ++#include <stdbool.h>
> ++#include <limits.h>
> ++
> ++#include "xlog.h"
> ++#include "misc.h"
> ++
> ++/*
> ++ * Returns a dynamically allocated, '\0'-terminated buffer
> ++ * containing an appropriate pathname, or NULL if an error
> ++ * occurs.  Caller must free the returned result with free(3).
> ++ */
> ++__attribute__((__malloc__))
> ++char *
> ++generic_make_pathname(const char *base, const char *leaf)
> ++{
> ++	size_t size;
> ++	char *path;
> ++	int len;
> ++
> ++	size = strlen(base) + strlen(leaf) + 2;
> ++	if (size > PATH_MAX)
> ++		return NULL;
> ++
> ++	path = malloc(size);
> ++	if (path == NULL)
> ++		return NULL;
> ++
> ++	len = snprintf(path, size, "%s/%s", base, leaf);
> ++	if ((len < 0) || ((size_t)len >= size)) {
> ++		free(path);
> ++		return NULL;
> ++	}
> ++
> ++	return path;
> ++}
> ++
> ++
> ++/**
> ++ * generic_setup_basedir - set up basedir
> ++ * @progname: C string containing name of program, for error messages
> ++ * @parentdir: C string containing pathname to on-disk state, or NULL
> ++ * @base: character buffer to contain the basedir that is set up
> ++ * @baselen: size of @base in bytes
> ++ *
> ++ * This runs before logging is set up, so error messages are directed
> ++ * to stderr.
> ++ *
> ++ * Returns true and sets up our basedir, if @parentdir was valid
> ++ * and usable; otherwise false is returned.
> ++ */
> ++_Bool
> ++generic_setup_basedir(const char *progname, const char *parentdir, char *base,
> ++		      const size_t baselen)
> ++{
> ++	static char buf[PATH_MAX];
> ++	struct stat st;
> ++	char *path;
> ++
> ++	/* First: test length of name and whether it exists */
> ++	if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
> ++		(void)fprintf(stderr, "%s: Directory name too long: %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++	if (lstat(parentdir, &st) == -1) {
> ++		(void)fprintf(stderr, "%s: Failed to stat %s: %s",
> ++				progname, parentdir, strerror(errno));
> ++		return false;
> ++	}
> ++
> ++	/* Ensure we have a clean directory pathname */
> ++	strncpy(buf, parentdir, sizeof(buf)-1);
> ++	path = dirname(buf);
> ++	if (*path == '.') {
> ++		(void)fprintf(stderr, "%s: Unusable directory %s",
> ++				progname, parentdir);
> ++		return false;
> ++	}
> ++
> ++	xlog(D_CALL, "Using %s as the state directory", parentdir);
> ++	strcpy(base, parentdir);
> ++	return true;
> ++}
> +diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
> +index 8f5874e..68f1a46 100644
> +--- a/support/nsm/Makefile.am
> ++++ b/support/nsm/Makefile.am
> +@@ -10,7 +10,7 @@ GENFILES	= $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
> + EXTRA_DIST	= sm_inter.x
> +
> + noinst_LIBRARIES = libnsm.a
> +-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
> ++libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> new file mode 100644
> index 00000000000..906ac0f9054
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-update-the-path-of-libnfs.a.patch
> @@ -0,0 +1,50 @@
> +From fcece65d1b713eaeef41706898440302f8ce92d9 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Thu, 12 Jul 2018 15:19:41 +0800
> +Subject: [PATCH] Makefile.am: update the path of libnfs.a
> +
> +The libnfs.a is under ../support/nfs/.libs/ now,
> +update the reference path accordingly to fix below
> +build error when run "make -C tests statdb_dump":
> +| make: *** No rule to make target '../support/nfs/libnfs.a', needed by 'statdb_dump'.  Stop.
> +
> +And below error when run "make -C tests/nsm_client nsm_client"
> +| make: *** No rule to make target '../../support/nfs/libnfs.a', needed by 'nsm_client'.  Stop.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502636522745&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + tests/Makefile.am            | 2 +-
> + tests/nsm_client/Makefile.am | 2 +-
> + 2 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/Makefile.am b/tests/Makefile.am
> +index 1f96264..74aa629 100644
> +--- a/tests/Makefile.am
> ++++ b/tests/Makefile.am
> +@@ -3,7 +3,7 @@
> + check_PROGRAMS = statdb_dump
> + statdb_dump_SOURCES = statdb_dump.c
> +
> +-statdb_dump_LDADD = ../support/nfs/libnfs.a \
> ++statdb_dump_LDADD = ../support/nfs/.libs/libnfs.a \
> + 		    ../support/nsm/libnsm.a $(LIBCAP)
> +
> + SUBDIRS = nsm_client
> +diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
> +index a8fc131..43db9c2 100644
> +--- a/tests/nsm_client/Makefile.am
> ++++ b/tests/nsm_client/Makefile.am
> +@@ -13,7 +13,7 @@ check_PROGRAMS	= nsm_client
> + nsm_client_SOURCES = $(GENFILES) nsm_client.c
> +
> + BUILT_SOURCES = $(GENFILES)
> +-nsm_client_LDADD = ../../support/nfs/libnfs.a \
> ++nsm_client_LDADD = ../../support/nfs/.libs/libnfs.a \
> + 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
> +
> + if CONFIG_RPCGEN
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
> new file mode 100644
> index 00000000000..17aabb9e4dc
> --- /dev/null
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch
> @@ -0,0 +1,43 @@
> +From 66471fbf7106917da7a1536b18a0a77d07479779 Mon Sep 17 00:00:00 2001
> +From: Mingli Yu <Mingli.Yu@windriver.com>
> +Date: Mon, 17 Dec 2018 15:29:47 +0800
> +Subject: [PATCH] configure.ac: Do not fatalize -Wmissing-prototypes
> +
> +There comes below error when run "make -C tests/nsm_client nsm_client"
> +| nlm_sm_inter_svc.c:20:1: error: no previous prototype for 'nlm_sm_prog_3' [-Werror=missing-prototypes]
> +
> +It is because rpcgen doesn't generate -Wmissing-prototypes
> +free code for nlm_sm_inter_svc.c with below logic
> +in tests/nsm_client/Makefile.am
> +[snip]
> +GENFILES_SVC    = nlm_sm_inter_svc.c
> +[snip]
> +$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
> +        test -f $@ && rm -rf $@ || true
> +        $(RPCGEN) -m -o $@ $<
> +
> +So add the logic not to fatalize -Wmissing-prototypes.
> +
> +Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154503260323936&w=2]
> +
> +Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> +---
> + configure.ac | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/configure.ac b/configure.ac
> +index e82ff14..d0cc5d5 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -548,7 +548,7 @@ my_am_cflags="\
> +  -Wall \
> +  -Wextra \
> +  -Werror=strict-prototypes \
> +- -Werror=missing-prototypes \
> ++ -Wmissing-prototypes \
> +  -Werror=missing-declarations \
> +  -Werror=format=2 \
> +  -Werror=undef \
> +--
> +2.7.4
> +
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> index 6be2aab47c1..52c609adb45 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_2.3.3.bb
> @@ -33,7 +33,10 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
>              file://0001-cacheio-use-intmax_t-for-formatted-IO.patch \
>              file://0001-Do-not-pass-null-pointer-to-freeaddrinfo.patch \
>              file://clang-format-string.patch \
> +           file://0001-Makefile.am-update-the-path-of-libnfs.a.patch \
> +           file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
>   "
> +SRC_URI_append_libc-glibc = " file://0001-configure.ac-Do-not-fatalize-Wmissing-prototypes.patch"
>   SRC_URI_append_libc-musl = " file://nfs-utils-musl-res_querydomain.patch"
>
>   SRC_URI[md5sum] = "b6c9c032995af1c08fea9fbcc1ce33e9"
>


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

end of thread, other threads:[~2019-01-11  6:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-17  8:47 [PATCH] nfs-utils: fix build error under tests folder mingli.yu
2018-12-17 17:16 ` richard.purdie
2018-12-18  2:31   ` Yu, Mingli
2018-12-18  5:21   ` [PATCH v2] " mingli.yu
2018-12-27  6:53     ` Yu, Mingli
2019-01-03  2:22     ` Yu, Mingli
2019-01-11  6:51     ` Yu, Mingli
  -- strict thread matches above, loose matches on Subject: below --
2018-07-12  8:46 [PATCH] " mingli.yu
2018-07-30  2:15 ` Yu, Mingli
2018-07-30 14:20 ` Burton, Ross

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