From patchwork Fri May 6 17:45:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Ovtchenkov X-Patchwork-Id: 53559 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF89D395443D for ; Fri, 6 May 2022 17:45:48 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from khan.localnet (unknown [185.44.68.223]) by sourceware.org (Postfix) with ESMTPS id F1C2A3857344 for ; Fri, 6 May 2022 17:45:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1C2A3857344 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=void-ptr.info Authentication-Results: sourceware.org; spf=none smtp.mailfrom=khan.localnet Received: from ptr by khan.localnet with local (Exim 4.94-23-08f2e6366) (envelope-from ) id 1nn21D-0002r8-Ms; Fri, 06 May 2022 20:45:31 +0300 From: Petr Ovtchenkov To: elfutils-devel@sourceware.org Subject: [PATCH 1/2] support cross compilation Date: Fri, 6 May 2022 20:45:03 +0300 Message-Id: <20220506174504.10952-2-ptr@void-ptr.info> X-Mailer: git-send-email 2.35.1.1.ge5a6898900 In-Reply-To: <20220506174504.10952-1-ptr@void-ptr.info> References: <20220506174504.10952-1-ptr@void-ptr.info> MIME-Version: 1.0 X-Spam-Status: No, score=-3494.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, KHOP_HELO_FCRDNS, MAY_BE_FORGED, NO_DNS_FOR_FROM, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Possible problem with out-of-tree build expected --- Makefile.am | 2 +- configure.ac | 6 ++++++ lib-host/Makefile.am | 47 ++++++++++++++++++++++++++++++++++++++++++++ libcpu/Makefile.am | 11 +++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 lib-host/Makefile.am diff --git a/Makefile.am b/Makefile.am index 8643312a..a9c6c1d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ AM_MAKEFLAGS = --no-print-directory pkginclude_HEADERS = version.h -SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \ +SUBDIRS = config lib lib-host libelf libcpu backends libebl libdwelf libdwfl libdw \ libasm debuginfod src po doc tests EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ diff --git a/configure.ac b/configure.ac index 11d1cf82..d0ad4678 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,7 @@ AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.]) AC_PROG_CC_C99 AC_PROG_CXX +AX_PROG_CC_FOR_BUILD AC_PROG_RANLIB AC_PROG_YACC AM_PROG_LEX @@ -98,6 +99,8 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_CHECK_TOOL([READELF], [readelf]) AC_CHECK_TOOL([NM], [nm]) +AM_CONDITIONAL([CROSS], [test "x$cross_compiling" = xyes]) + AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))], ac_cv_visibility, [dnl save_CFLAGS="$CFLAGS" @@ -608,6 +611,9 @@ AC_CONFIG_FILES([doc/Makefile]) dnl Support library. AC_CONFIG_FILES([lib/Makefile]) +dnl Support library. +AC_CONFIG_FILES([lib-host/Makefile]) + dnl ELF library. AC_CONFIG_FILES([libelf/Makefile]) diff --git a/lib-host/Makefile.am b/lib-host/Makefile.am new file mode 100644 index 00000000..9316c8ed --- /dev/null +++ b/lib-host/Makefile.am @@ -0,0 +1,47 @@ +## Process this file with automake to create Makefile.in +## +## Copyright (C) 1996-2011 Red Hat, Inc. +## This file is part of elfutils. +## +## This file is free software; you can redistribute it and/or modify +## it under the terms of either +## +## * the GNU Lesser General Public License as published by the Free +## Software Foundation; either version 3 of the License, or (at +## your option) any later version +## +## or +## +## * 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 +## +## or both in parallel, as here. +## +## elfutils 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 copies of the GNU General Public License and +## the GNU Lesser General Public License along with this program. If +## not, see . +## +if CROSS + +include $(top_srcdir)/config/eu.am +AM_CFLAGS += $(fpic_CFLAGS) +AM_CPPFLAGS += -D_GNU_SOURCE -I$(srcdir)/../lib -I$(srcdir)/../libelf + +noinst_LIBRARIES = libeu.a + +$(libeu_a_OBJECTS): CC=${CC_FOR_BUILD} + +libeu_a_SOURCES = ../lib/xstrdup.c ../lib/xstrndup.c ../lib/xmalloc.c ../lib/next_prime.c \ + ../lib/crc32.c ../lib/crc32_file.c \ + ../lib/color.c ../lib/printversion.c + +if !GPROF +xmalloc_CFLAGS = -ffunction-sections +endif +endif diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am index 57d0a164..8da743d4 100644 --- a/libcpu/Makefile.am +++ b/libcpu/Makefile.am @@ -27,6 +27,13 @@ ## the GNU Lesser General Public License along with this program. If ## not, see . ## + +if CROSS +i386_gendis_LINK = ${CC_FOR_BUILD} ${LDFLAGS} -o $@ + +$(i386_gendis_OBJECTS): CC=${CC_FOR_BUILD} +endif + include $(top_srcdir)/config/eu.am AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ -I$(srcdir)/../libdw -I$(srcdir)/../libasm @@ -87,7 +94,11 @@ endif i386_lex_no_Werror = yes +if CROSS +libeu = ../lib-host/libeu.a +else libeu = ../lib/libeu.a +endif i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \ -Wno-implicit-fallthrough From patchwork Fri May 6 17:45:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Ovtchenkov X-Patchwork-Id: 53560 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 188363954443 for ; Fri, 6 May 2022 17:45:54 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from khan.localnet (unknown [185.44.68.223]) by sourceware.org (Postfix) with ESMTPS id 22424385803E for ; Fri, 6 May 2022 17:45:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 22424385803E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=void-ptr.info Authentication-Results: sourceware.org; spf=none smtp.mailfrom=khan.localnet Received: from ptr by khan.localnet with local (Exim 4.94-23-08f2e6366) (envelope-from ) id 1nn21G-0002rC-SI; Fri, 06 May 2022 20:45:34 +0300 From: Petr Ovtchenkov To: elfutils-devel@sourceware.org Subject: [PATCH 2/2] drop _FORTIFY_SOURCE for host build Date: Fri, 6 May 2022 20:45:04 +0300 Message-Id: <20220506174504.10952-3-ptr@void-ptr.info> X-Mailer: git-send-email 2.35.1.1.ge5a6898900 In-Reply-To: <20220506174504.10952-1-ptr@void-ptr.info> References: <20220506174504.10952-1-ptr@void-ptr.info> MIME-Version: 1.0 X-Spam-Status: No, score=-3494.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, MAY_BE_FORGED, NO_DNS_FOR_FROM, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Check for _FORTIFY_SOURCE level was made for target, not for build host. This level may not satisfy to libc on host. Fortification for build tools looks insignificant, so just drop -D_FORTIFY_SOURCE=... definition for host compiler. --- lib-host/Makefile.am | 1 + libcpu/Makefile.am | 1 + 2 files changed, 2 insertions(+) diff --git a/lib-host/Makefile.am b/lib-host/Makefile.am index 9316c8ed..9b6ea77d 100644 --- a/lib-host/Makefile.am +++ b/lib-host/Makefile.am @@ -36,6 +36,7 @@ AM_CPPFLAGS += -D_GNU_SOURCE -I$(srcdir)/../lib -I$(srcdir)/../libelf noinst_LIBRARIES = libeu.a $(libeu_a_OBJECTS): CC=${CC_FOR_BUILD} +$(libeu_a_OBJECTS): CFLAGS=${CPPFLAGS} $(fpic_CFLAGS) libeu_a_SOURCES = ../lib/xstrdup.c ../lib/xstrndup.c ../lib/xmalloc.c ../lib/next_prime.c \ ../lib/crc32.c ../lib/crc32_file.c \ diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am index 8da743d4..9a1b4a8e 100644 --- a/libcpu/Makefile.am +++ b/libcpu/Makefile.am @@ -32,6 +32,7 @@ if CROSS i386_gendis_LINK = ${CC_FOR_BUILD} ${LDFLAGS} -o $@ $(i386_gendis_OBJECTS): CC=${CC_FOR_BUILD} +$(i386_gendis_OBJECTS): CFLAGS=$(CPPFLAGS) endif include $(top_srcdir)/config/eu.am