diff mbox series

[03/27] package/libnss: use correct CFLAGS and LDFLAGS

Message ID 20190614210346.121013-4-giulio.benetti@micronovasrl.com
State Changes Requested
Headers show
Series [01/27] package/keyutils: re-enable package on microblaze | expand

Commit Message

Giulio Benetti June 14, 2019, 9:03 p.m. UTC
Actually libnss is configure with BUILD_OPT=1 that doesn't take into
account TARGET_CFLAGS nor TARGET_LDFLAGS resulting in pre-chosen
optimizations and debugging symbols.

Can't pass TARGET_CFLAGS through CFLAGS or similar otherwise other
iternal libnss will be overwritten(i.e. -fPIC), so prefer to append
TARGET_CFLAGS at the end of Linux.mk as well as TARGET_LDFLAGS according
to internal libnss Makefile system's names. And obviously remove
BUILD_OPT=1 from BUILD_VARS.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
 package/libnss/libnss.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Thomas Petazzoni June 19, 2019, 12:33 p.m. UTC | #1
Hello,

On Fri, 14 Jun 2019 23:03:22 +0200
Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:

> +# Need to pass down TARGET_CFLAGS and TARGET_LDFLAGS
> +define LIBNSS_FIXUP_LINUX_MK
> +	echo 'OS_CFLAGS += ${TARGET_CFLAGS}' >> $(@D)/nss/coreconf/Linux.mk
> +	echo 'LDFLAGS += ${TARGET_LDFLAGS}' >> $(@D)/nss/coreconf/Linux.mk

You should use $(...) and not ${...} to reference make variables.

But beyond that, this commit unfortunately breaks the build:

pqg.c: In function ‘PQG_VerifyParams’:
pqg.c:1806:27: error: ‘type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     if ((vfy->h.len == 1) && (type != FIPS186_1_TYPE)) {
                           ^
In file included from pqg.c:21:0:
secmpi.h:8:8: error: ‘hashtype’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     if (SECSuccess != (rv = func)) \
        ^
pqg.c:1624:19: note: ‘hashtype’ was declared here
     HASH_HashType hashtype;
                   ^
cc1: all warnings being treated as errors

And the reason why is because in a BR2_OPTIMIZE_S=y build (the
default), we pass -Os. This -Os is now correctly passed to libnss, but
this is what causes the build failure. Indeed, at -Os, gcc gets those
build failures, but not at -O2.

Could you have a look into this ?

Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/libnss/libnss.mk b/package/libnss/libnss.mk
index 89d614fe1c..484c79e9da 100644
--- a/package/libnss/libnss.mk
+++ b/package/libnss/libnss.mk
@@ -13,6 +13,14 @@  LIBNSS_DEPENDENCIES = libnspr sqlite zlib
 LIBNSS_LICENSE = MPL-2.0
 LIBNSS_LICENSE_FILES = nss/COPYING
 
+# Need to pass down TARGET_CFLAGS and TARGET_LDFLAGS
+define LIBNSS_FIXUP_LINUX_MK
+	echo 'OS_CFLAGS += ${TARGET_CFLAGS}' >> $(@D)/nss/coreconf/Linux.mk
+	echo 'LDFLAGS += ${TARGET_LDFLAGS}' >> $(@D)/nss/coreconf/Linux.mk
+endef
+
+LIBNSS_PRE_CONFIGURE_HOOKS += LIBNSS_FIXUP_LINUX_MK
+
 # --gc-sections triggers binutils ld segfault
 # https://sourceware.org/bugzilla/show_bug.cgi?id=21180
 ifeq ($(BR2_microblaze),y)
@@ -33,7 +41,6 @@  LIBNSS_BUILD_VARS = \
 	MOZILLA_CLIENT=1 \
 	NSPR_INCLUDE_DIR=$(STAGING_DIR)/usr/include/nspr \
 	NSPR_LIB_DIR=$(STAGING_DIR)/usr/lib \
-	BUILD_OPT=1 \
 	NS_USE_GCC=1 \
 	NSS_DISABLE_GTESTS=1 \
 	NSS_USE_SYSTEM_SQLITE=1 \
@@ -102,7 +109,6 @@  HOST_LIBNSS_BUILD_VARS = \
 	MOZILLA_CLIENT=1 \
 	NSPR_INCLUDE_DIR=$(HOST_DIR)/include/nspr \
 	NSPR_LIB_DIR=$(HOST_DIR)/lib \
-	BUILD_OPT=1 \
 	NS_USE_GCC=1 \
 	NSS_DISABLE_GTESTS=1 \
 	NSS_USE_SYSTEM_SQLITE=1 \