Skip to contentSkip to conversation

c-ares: use our compilation flags

PATCH Superseded [email protected] 3 participants 5 messages Jul 15, 2016 – Jul 21, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 c-ares: use our compilation flags

From: André Draszik <[email protected]>

If not requested otherwise as ./configure option, c-ares will strip any -g from CFLAGS / CPPFLAGS and add -g0 instead, disabling all debug info.
Similarly, it will try to enable optimisation (but bail out since in that case it honors an existing -O in CFLAGS / CPPFLAGS)

Since we want to control code generation, patch out the code mangling -g (and -O for consistency). Alternatively, if we were to pass --enable-debug to ./configure, c-ares would at the same time assume that we don't want optimisation anymore.

---
 ...configure.ac-don-t-override-passed-cflags.patch | 26 ++++++++++++++++++++++
 .../recipes-support/c-ares/c-ares_1.11.0.bb        |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 meta-networking/recipes-support/c-ares/c-ares/0001-configure.ac-don-t-override-passed-cflags.patch
meta-networking/recipes-support/c-ares/c-ares/0001-configure.ac-don-t-override-passed-cflags.patch new file +26 -0
new file mode 100644
index 0000000..10fad4e
@@ -0,0 +1,26 @@
+From 2a7236d2a7bb9c3d3c3f44ebf59404bf7134fcb3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <[email protected]>
+Date: Tue, 12 Apr 2016 11:37:28 +0100
+Subject: [PATCH] configure.ac: don't override passed cflags
+
+We are controlling debug and optimiser flags from OE
+---
+ configure.ac | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 5c02450..3cf9fcd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -147,8 +147,6 @@ dnl **********************************************************************
+ 
+ CARES_CHECK_COMPILER
+ CARES_SET_COMPILER_BASIC_OPTS
+-CARES_SET_COMPILER_DEBUG_OPTS
+-CARES_SET_COMPILER_OPTIMIZE_OPTS
+ CARES_SET_COMPILER_WARNING_OPTS
+ 
+ if test "$compiler_id" = "INTEL_UNIX_C"; then
+-- 
+2.8.0.rc3
+
meta-networking/recipes-support/c-ares/c-ares_1.11.0.bb +3 -1
index 2f72ab4..c98be7d 100644
@@ -6,7 +6,9 @@ SECTION = "libs"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://ares_init.c;beginline=1;endline=3;md5=53f5ecf4c22c37cf1ddd1ef8f8eccce0"
 
-SRC_URI = "http://c-ares.haxx.se/download/${BP}.tar.gz"
+SRC_URI = "http://c-ares.haxx.se/download/${BP}.tar.gz \
+           file://0001-configure.ac-don-t-override-passed-cflags.patch \
+"
 SRC_URI[md5sum] = "d5c6d522cfc54bb6f215a0b7912d46be"
 SRC_URI[sha256sum] = "b3612e6617d9682928a1d50c1040de4db6519f977f0b25d40cf1b632900b3efd"
 
Signature · 1 line
2.8.1
#1 lore raw

PATCH 2/2 meta-networking: override SECURITY_CFLAGS for c-ares

From: André Draszik <[email protected]>

c-ares doesn't build if the distro has enabled usage of the security_flags.inc file as it is picky about what is placed into CPPFLAGS and CFLAGS. It complains and errors out if any preprocessor options appear in CFLAGS.

Fix this by providing an additional include file that is require'd from conf/layer.conf.

---
 .../conf/distro/include/meta_networking_security_flags.inc          | 6 ++++++
 meta-networking/conf/layer.conf                                     | 3 +++
 2 files changed, 9 insertions(+)
 create mode 100644 meta-networking/conf/distro/include/meta_networking_security_flags.inc
meta-networking/conf/distro/include/meta_networking_security_flags.inc new file +6 -0
new file mode 100644
index 0000000..06802d6
@@ -0,0 +1,6 @@
+# configure righteously complains:
+# | configure:3479: using CFLAGS:  -O2 -pipe -g -feliminate-unused-debug-types -fstack-protector-strong -pie -fpie -D_FORTIFY_SOURCE=2
+# | configure:3485: CFLAGS error: CFLAGS may only be used to specify C compiler flags, not macro definitions. Use CPPFLAGS for: -D_FORTIFY_SOURCE=2
+# | configure:3516: error: Can not continue. Fix errors mentioned immediately above this line.
+TARGET_CFLAGS_remove_pn-c-ares = "${lcl_maybe_fortify}"
+TARGET_CPPFLAGS_append_pn-c-ares = "${lcl_maybe_fortify}"
meta-networking/conf/layer.conf +3 -0
index 5fd636a..c09ba4a 100644
@@ -21,3 +21,6 @@ LICENSE_PATH += "${LAYERDIR}/licenses"
 
 # used by waf-samba.bbclass
 WAF_CROSS_ANSWERS_PATH = "${LAYERDIR}/files/waf-cross-answers"
+
+# Override security flags
+require conf/distro/include/meta_networking_security_flags.inc
Signature · 1 line
2.8.1
#2 lore raw

Re: [meta-networking][PATCH 2/2] meta-networking: override SECURITY_CFLAGS for c-ares

Quoted 7 lines · On Fri, Jul 15, 2016 at 5:54 AM, <[email protected]> wrote:

From: André Draszik <[email protected]>

c-ares doesn't build if the distro has enabled usage of the security_flags.inc file as it is picky about what is placed into CPPFLAGS and CFLAGS. It complains and errors out if any preprocessor options appear in CFLAGS.

Quoted 5 lines

Fix this by providing an additional include file that is require'd from conf/layer.conf.

This commit message is a little misleading. The fact that you added a .inc isn't what fixed the problem, the move of the defines from CFLAGS to CPPFLAGS was.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#3 lore raw

Re: [meta-networking][PATCH 2/2] meta-networking: override SECURITY_CFLAGS for c-ares

Quoted 13 lines · Christopher Larson
Quoted 10 lines · On Fri, Jul 15, 2016 at 5:54 AM, <[email protected]> wrote:

From: André Draszik <[email protected]>

c-ares doesn't build if the distro has enabled usage of the security_flags.inc file as it is picky about what is placed into CPPFLAGS and CFLAGS. It complains and errors out if any preprocessor options appear in CFLAGS.

Fix this by providing an additional include file that is require'd from conf/layer.conf.

Quoted 6 lines
Quoted 2 lines

This commit message is a little misleading. The fact that you added a .inc isn't what fixed the problem, the move of the defines from CFLAGS to CPPFLAGS was.

Well, I copied that part of the commit message from the commit that added a similar .inc file to to meta-oe. I'll rewrite it.

A.

#4 lore raw

Re: [meta-networking][PATCH 2/2] meta-networking: override SECURITY_CFLAGS for c-ares

In reply to [email protected]
Quoted 23 lines · On Fri, Jul 15, 2016 at 01:54:21PM +0100, [email protected] wrote:

From: André Draszik <[email protected]>

c-ares doesn't build if the distro has enabled usage of the security_flags.inc file as it is picky about what is placed into CPPFLAGS and CFLAGS. It complains and errors out if any preprocessor options appear in CFLAGS.

Fix this by providing an additional include file that is require'd from conf/layer.conf.

---
 .../conf/distro/include/meta_networking_security_flags.inc          | 6 ++++++
 meta-networking/conf/layer.conf                                     | 3 +++
 2 files changed, 9 insertions(+)
 create mode 100644 meta-networking/conf/distro/include/meta_networking_security_flags.inc
meta-networking/conf/distro/include/meta_networking_security_flags.inc new file +0 -0
new file mode 100644
index 0000000..06802d6

meta-networking/conf/distro/include/meta_networking_security_flags.inc line 6

Quoted 6 lines
meta-networking/conf/distro/include/meta_networking_security_flags.inc new file +6 -0
@@ -0,0 +1,6 @@
+# configure righteously complains:
+# | configure:3479: using CFLAGS:  -O2 -pipe -g -feliminate-unused-debug-types -fstack-protector-strong -pie -fpie -D_FORTIFY_SOURCE=2
+# | configure:3485: CFLAGS error: CFLAGS may only be used to specify C compiler flags, not macro definitions. Use CPPFLAGS for: -D_FORTIFY_SOURCE=2
+# | configure:3516: error: Can not continue. Fix errors mentioned immediately above this line.
+TARGET_CFLAGS_remove_pn-c-ares = "${lcl_maybe_fortify}"
+TARGET_CPPFLAGS_append_pn-c-ares = "${lcl_maybe_fortify}"

This actually breaks builds which don't include conf/distro/include/security_flags.inc
with:
lcl_maybe_fortify = "${@base_conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=2',d)}"

because then lcl_maybe_fortify isn't defined and gcc in c-ares do_configure gets it unexpaned and fails:

configure:3926: checking whether the C compiler works
configure:3948: arm-oe-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=softfp -mcpu=cortex-a9 -mtune=cortex-a9 -funwind-tables -rdynamic -Os --sysroot=/OE/sysroots/MACHINE -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/OE/work/MACHINE-oe-linux-gnueabi/c-ares/1.10.0-r0=/usr/src/debug/c-ares/1.10.0-r0 -fdebug-prefix-map=/OE/sysroots/x86_64-linux= -fdebug-prefix-map=/OE/sysroots/MACHINE= -Os ${lcl_maybe_fortify} -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed conftest.c >&5
arm-oe-linux-gnueabi-gcc: error: ${lcl_maybe_fortify}: No such file or directory

I'll send a patch to add weak assignment before using lcl_maybe_fortify

Quoted 19 lines
meta-networking/conf/layer.conf +3 -0
index 5fd636a..c09ba4a 100644
@@ -21,3 +21,6 @@ LICENSE_PATH += "${LAYERDIR}/licenses"
 
 # used by waf-samba.bbclass
 WAF_CROSS_ANSWERS_PATH = "${LAYERDIR}/files/waf-cross-answers"
+
+# Override security flags
+require conf/distro/include/meta_networking_security_flags.inc
Signature · 7 lines
2.8.1

-- 
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]