From patchwork Thu Sep 4 21:40:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 386022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0648A140183 for ; Fri, 5 Sep 2014 07:40:54 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=ZkZg48cm/tJz+7St tiojr8aWjSNpaczSOb3q6gMsUrFi+0DFB+Z/cq7Xc9Yo+28vVyqH+ZmptIsUdUkf T7UIiQps70I4x0bsA6CxnwlMRZIp0QpL0KlTaItBmxCIYAAtcUt9AX93/7m3pQpd 8R9lDiqP32bv/rCUiRTYxwhZ4nY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject:mime-version:content-type :content-transfer-encoding; s=default; bh=nYniRCzHvd4F2VZSeQ5gTf mTZZU=; b=dnK1oo27U2qyQ8IuHmOWl0Wb5LKinlGjKD/II+FE7C5C7+dYn/z9wG jvZ9j+7oKoz4bvnAcGskcOPsjp9YUMoSmAb23UywVzsm/10vgsqoGvfPHYEH1xoJ H1/uYHD1w64hG10p5Minoi0hRL/Z14563DIOS2aJafQCMMggLuLm8= Received: (qmail 9491 invoked by alias); 4 Sep 2014 21:40:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9476 invoked by uid 89); 4 Sep 2014 21:40:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: bes.se.axis.com Received: from bes.se.axis.com (HELO bes.se.axis.com) (195.60.68.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Sep 2014 21:40:46 +0000 Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id 3F62F2E3BD for ; Thu, 4 Sep 2014 23:40:43 +0200 (CEST) Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id 33lb-p5zzNnJ for ; Thu, 4 Sep 2014 23:40:40 +0200 (CEST) Received: from boulder.se.axis.com (boulder.se.axis.com [10.0.2.104]) by bes.se.axis.com (Postfix) with ESMTP id 78D082E393 for ; Thu, 4 Sep 2014 23:40:40 +0200 (CEST) Received: from boulder.se.axis.com (localhost [127.0.0.1]) by postfix.imss71 (Postfix) with ESMTP id 60818112B for ; Thu, 4 Sep 2014 23:40:40 +0200 (CEST) Received: from seth.se.axis.com (seth.se.axis.com [10.0.2.172]) by boulder.se.axis.com (Postfix) with ESMTP id 4B2CA10A0 for ; Thu, 4 Sep 2014 23:40:40 +0200 (CEST) Received: from ignucius.se.axis.com (ignucius.se.axis.com [10.88.21.50]) by seth.se.axis.com (Postfix) with ESMTP id 4900A3E048; Thu, 4 Sep 2014 23:40:40 +0200 (CEST) Received: from ignucius.se.axis.com (localhost [127.0.0.1]) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) with ESMTP id s84LeeQD006206; Thu, 4 Sep 2014 23:40:40 +0200 Received: (from hp@localhost) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) id s84Lee8Y006202; Thu, 4 Sep 2014 23:40:40 +0200 Date: Thu, 4 Sep 2014 23:40:40 +0200 Message-Id: <201409042140.s84Lee8Y006202@ignucius.se.axis.com> From: Hans-Peter Nilsson To: gcc-patches@gcc.gnu.org Subject: [RFA 1/2]: Don't ignore target_header_dir when deciding inhibit_libc MIME-Version: 1.0 The directory at $target_header_dir is already inspected in gcc/configure, for e.g. glibc version and stack protector support, but not for setting inhibit_libc. This is just inconsistent and the obvious resolution to me is to inhibit inhibit_libc when a target *does* "have its own set of headers", to quote the comment above the inhibit_libc setting. There is nothing in the build log for "make all-gcc" that shows a difference with/without --with-headers, if headers are actually present anyway! It may seem that libgcc/configure.ac would be the appropriate place to patch and test, but it is gcc/configure.ac which tests various things about target headers and makes the inhibit_libc decision, exporting it through the generated obj/gcc/libgcc.mvars that is included in libgcc/Makefile. Tested before/after by "make all-gcc" on native x86_64-linux (*a) and seeing it still set (for the peace of most users) in gcc/Makefile, and cross to mipsel-linux "make all-gcc" with/without (*b,c) a pre-installed set of headers just implied by --prefix and --target to observe the intended difference and the same with (*d) --with-sysroot (but no headers at the sysroot) and (*e) --with-build-sysroot and both (*f) (note that --with-build-sysroot=... without --with-sysroot also got inhibit_libc) to observe no change for the --with-sysroot one (still no inhibit_libc). The same with --with-headers (*g). Also, I checked that nothing other than the inhibit_libc code uses target_header_dir or sets the used variables in the block of code involved in the move. Ok to commit? gcc: * configure.ac (target_header_dir): Move block defining this to before the block setting inhibit_libc. (inhibit_libc): When considering $with_headers, just check it it's explicitly "no". If not, also check if $target_header_dir/stdio.h is present. If not, set inhibit_libc=true. * configure: Regenerate. brgds, H-P Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 214736) +++ gcc/configure.ac (working copy) @@ -1924,6 +1924,22 @@ elif test "x$TARGET_SYSTEM_ROOT" != x; t SYSTEM_HEADER_DIR=$build_system_header_dir fi +if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then + if test "x$with_headers" != x; then + target_header_dir=$with_headers + elif test "x$with_sysroot" = x; then + target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" + elif test "x$with_build_sysroot" != "x"; then + target_header_dir="${with_build_sysroot}${native_system_header_dir}" + elif test "x$with_sysroot" = xyes; then + target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" + else + target_header_dir="${with_sysroot}${native_system_header_dir}" + fi +else + target_header_dir=${native_system_header_dir} +fi + # If this is a cross-compiler that does not # have its own set of headers then define # inhibit_libc @@ -1935,7 +1951,7 @@ fi : ${inhibit_libc=false} if { { test x$host != x$target && test "x$with_sysroot" = x ; } || test x$with_newlib = xyes ; } && - { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then + { test "x$with_headers" = xno || test ! -f "$target_header_dir/stdio.h"; } ; then inhibit_libc=true fi AC_SUBST(inhibit_libc) @@ -4441,22 +4457,6 @@ if test x$with_sysroot = x && test x$hos && test "$prefix" != "NONE"; then AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include", [Define to PREFIX/include if cpp should also search that directory.]) -fi - -if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then - if test "x$with_headers" != x; then - target_header_dir=$with_headers - elif test "x$with_sysroot" = x; then - target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" - elif test "x$with_build_sysroot" != "x"; then - target_header_dir="${with_build_sysroot}${native_system_header_dir}" - elif test "x$with_sysroot" = xyes; then - target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" - else - target_header_dir="${with_sysroot}${native_system_header_dir}" - fi -else - target_header_dir=${native_system_header_dir} fi # Determine the version of glibc, if any, used on the target.