On Thu, Feb 24, 2022 at 6:48 PM Joe Slater <joe.sla...@windriver.com> wrote:
>
> Use the correct $CPP to test if match.S is buildable,
> and do not build it if QA checks require PIC code.
>
> Signed-off-by: Joe Slater <joe.sla...@windriver.com>
> ---
>  .../0001-configure-use-correct-CPP.patch      | 47 +++++++++++++++++++
>  ...002-configure-support-PIC-code-build.patch | 34 ++++++++++++++
>  meta/recipes-extended/zip/zip_3.0.bb          |  3 ++
>  3 files changed, 84 insertions(+)
>  create mode 100644 
> meta/recipes-extended/zip/zip-3.0/0001-configure-use-correct-CPP.patch
>  create mode 100644 
> meta/recipes-extended/zip/zip-3.0/0002-configure-support-PIC-code-build.patch
>
> diff --git 
> a/meta/recipes-extended/zip/zip-3.0/0001-configure-use-correct-CPP.patch 
> b/meta/recipes-extended/zip/zip-3.0/0001-configure-use-correct-CPP.patch
> new file mode 100644
> index 0000000000..02253f968c
> --- /dev/null
> +++ b/meta/recipes-extended/zip/zip-3.0/0001-configure-use-correct-CPP.patch
> @@ -0,0 +1,47 @@
> +From 7a2729ee7f5d9b9d4a0d9b83fe641a2ab03c4ee0 Mon Sep 17 00:00:00 2001
> +From: Joe Slater <joe.sla...@windriver.com>
> +Date: Thu, 24 Feb 2022 17:36:59 -0800
> +Subject: [PATCH 1/2] configure: use correct CPP
> +
> +configure uses CPP to test that two assembler routines
> +can be built. Unfortunately, it will use /usr/bin/cpp
> +if it exists, invalidating the tests.  We use the $CC
> +passed to configure.
> +
> +Upstream-Status: Inappropriate [openembedded specific]
> +
> +Signed-off-by: Joe Slater <joe.sla...@windriver.com>
> +---
> + unix/configure | 15 +++++++++------
> + 1 file changed, 9 insertions(+), 6 deletions(-)
> +
> +diff --git a/unix/configure b/unix/configure
> +index 73ba803..7e21070 100644
> +--- a/unix/configure
> ++++ b/unix/configure
> +@@ -220,13 +220,16 @@ fi
> + echo Check for the C preprocessor
> + # on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
> + CPP="${CC} -E"
> ++
> ++# We should not change CPP for yocto builds.
> ++#
> + # solaris as(1) needs -P, maybe others as well ?
> +-[ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
> +-[ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
> +-[ -f /lib/cpp ] && CPP=/lib/cpp
> +-[ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
> +-[ -f /xenix ] && CPP="${CC} -E"
> +-[ -f /lynx.os ] && CPP="${CC} -E"
> ++# [ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
> ++# [ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
> ++# [ -f /lib/cpp ] && CPP=/lib/cpp
> ++# [ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
> ++# [ -f /xenix ] && CPP="${CC} -E"
> ++# [ -f /lynx.os ] && CPP="${CC} -E"
> +
> + echo "#include <stdio.h>" > conftest.c
> + $CPP conftest.c >/dev/null 2>/dev/null || CPP="${CC} -E"
> +--
> +2.24.1
> +
> diff --git 
> a/meta/recipes-extended/zip/zip-3.0/0002-configure-support-PIC-code-build.patch
>  
> b/meta/recipes-extended/zip/zip-3.0/0002-configure-support-PIC-code-build.patch
> new file mode 100644
> index 0000000000..6e0879616a
> --- /dev/null
> +++ 
> b/meta/recipes-extended/zip/zip-3.0/0002-configure-support-PIC-code-build.patch
> @@ -0,0 +1,34 @@
> +From b0492506d2c28581193906e9d260d4f0451e2c39 Mon Sep 17 00:00:00 2001
> +From: Joe Slater <joe.sla...@windriver.com>
> +Date: Thu, 24 Feb 2022 17:46:03 -0800
> +Subject: [PATCH 2/2] configure: support PIC code build
> +
> +Disable building match.S. The code requires
> +relocation in .text.
> +
> +Upstream-Status: Inappropriate [openembedded specific]
> +
> +Signed-off-by: Joe Slater <joe.sla...@windriver.com>
> +---
> + unix/configure | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/unix/configure b/unix/configure
> +index 7e21070..1bc698b 100644
> +--- a/unix/configure
> ++++ b/unix/configure
> +@@ -242,8 +242,9 @@ if eval "$CPP match.S > _match.s 2>/dev/null"; then
> +   if test ! -s _match.s || grep error < _match.s > /dev/null; then
> +     :
> +   elif eval "$CC -c _match.s >/dev/null 2>/dev/null" && [ -f _match.o ]; 
> then
> +-    CFLAGS="${CFLAGS} -DASMV"
> +-    OBJA="match.o"
> ++    # disable match.S for PIC code
> ++    # CFLAGS="${CFLAGS} -DASMV"
> ++    # OBJA="match.o"

you could convert this to do a runtime check for pic'ness

is_pic=$(echo | $CPP -dM - | grep -i __pic__)
if [ "$is_pic" = "" ]; then
compile match.o
else
fi

This will also mean you dont have to do the check you are doing in
recipe while applying this patch

> +     echo "int foo() { return 0;}" > conftest.c
> +     $CC -c conftest.c >/dev/null 2>/dev/null
> +     echo Check if compiler generates underlines
> +--
> +2.24.1
> +
> diff --git a/meta/recipes-extended/zip/zip_3.0.bb 
> b/meta/recipes-extended/zip/zip_3.0.bb
> index 18b5d8648e..42a17f9450 100644
> --- a/meta/recipes-extended/zip/zip_3.0.bb
> +++ b/meta/recipes-extended/zip/zip_3.0.bb
> @@ -14,6 +14,9 @@ SRC_URI = 
> "${SOURCEFORGE_MIRROR}/infozip/Zip%203.x%20%28latest%29/3.0/zip30.tar.
>             file://fix-security-format.patch \
>             file://10-remove-build-date.patch \
>             file://zipnote-crashes-with-segfault.patch \
> +           file://0001-configure-use-correct-CPP.patch \
> +           ${@bb.utils.contains('ERROR_QA', 'textrel', \
> +               'file://0002-configure-support-PIC-code-build.patch', '', d)} 
> \

I think its fine to apply it unconditionally since OE toolchain
generates PIC by default.

>             "
>  UPSTREAM_VERSION_UNKNOWN = "1"
>
> --
> 2.24.1
>
>
> 
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#162336): 
https://lists.openembedded.org/g/openembedded-core/message/162336
Mute This Topic: https://lists.openembedded.org/mt/89381221/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to