From patchwork Sat May 18 09:03:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1101376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-501079-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="o/FDzdw+"; dkim-atps=neutral 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 455fNC6JcDz9s9N for ; Sat, 18 May 2019 19:03:47 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; q=dns; s=default; b=rEV55AxyUxS0vkr0daGMfPy br1HPwbTABJTzKYaYYmYH8k6FW+WW885D8pEmeDZXb0Bz23SqhS0D6stg2rLxnEO 6Fgxx+orHhWgDJgbapm/qIbAPrCqXyGRtLAecw7zh/3nUssd00Gy8PwC5P5w01fz 1huYEjEICMh0UIqdH8Yo= 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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; s=default; bh=kv7G9mCKXp424nDSvUJvmTdNbio=; b= o/FDzdw+5kSyach/OwbQnrCmHYF3FyM5YbAfYwuFx9MEcpc+H5iAuL5D0p+1rgbI akaw5QwCLZq4TAMKSqlpE3WR5qB7PfHiQjOj1q2DJJe6PfYXtYGioAvXn7mjJjRa wXVDF+2yTsHkFkPSxRjU9XsDXYYOkrfNgIT/B+DRsFw= Received: (qmail 119087 invoked by alias); 18 May 2019 09:03:40 -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 119073 invoked by uid 89); 18 May 2019 09:03:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=!strncmp, our, HX-Spam-Relays-External:ESMTPA X-HELO: smtp2.wavenetuk.net Received: from smtp.wavenetuk.net (HELO smtp2.wavenetuk.net) (195.26.37.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 May 2019 09:03:38 +0000 Received: from euterpe-sie.home (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp2.wavenetuk.net (Postfix) with ESMTPA id CA9F2600252 for ; Sat, 18 May 2019 10:03:34 +0100 (BST) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH, Darwin, objective-c] Register gnu-runtime headers correctly. Message-Id: <416D8540-A04D-4BC7-91CC-5DA50399CFBD@sandoe.co.uk> Date: Sat, 18 May 2019 10:03:31 +0100 To: GCC Patches Darwin is able to use two runtimes for objective-c; the default is its native "NeXT" runtime, but also it can build code using the "gnu-runtime". In order to do this, we have to be able to find the gnu-runtime headers (which are installed into the compiler's tree). The process to do this has been erroneously prepending the sysroot to this when a sysroot is in force. The gnu-runtime headers have never been installed in a Darwin (macOS) SDK so we must make sure that they are found local to the compiler. tested on powerpc-darwin9, x86_64-darwin16 applied to mainline Iain gcc/ 2019-05-18 Iain Sandoe * config/darwin-c.c (darwin_register_objc_includes): Do not prepend the sysroot when building gnu-runtime header search paths. diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 8331153..aa5d2f2 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -463,41 +463,32 @@ static const char *framework_defaults [] = /* Register the GNU objective-C runtime include path if STDINC. */ void -darwin_register_objc_includes (const char *sysroot, const char *iprefix, - int stdinc) +darwin_register_objc_includes (const char *sysroot ATTRIBUTE_UNUSED, + const char *iprefix, int stdinc) { - const char *fname; - size_t len; - /* We do not do anything if we do not want the standard includes. */ - if (!stdinc) - return; - - fname = GCC_INCLUDE_DIR "-gnu-runtime"; - - /* Register the GNU OBJC runtime include path if we are compiling OBJC - with GNU-runtime. */ + /* If we want standard includes; Register the GNU OBJC runtime include + path if we are compiling OBJC with GNU-runtime. + This path is compiler-relative, we don't want to prepend the sysroot + since it's not expected to find the headers there. */ - if (c_dialect_objc () && !flag_next_runtime) + if (stdinc && c_dialect_objc () && !flag_next_runtime) { + const char *fname = GCC_INCLUDE_DIR "-gnu-runtime"; char *str; - /* See if our directory starts with the standard prefix. + size_t len; + + /* See if our directory starts with the standard prefix. "Translate" them, i.e. replace /usr/local/lib/gcc... with IPREFIX and search them first. */ - if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0 && !sysroot + if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0 && !strncmp (fname, cpp_GCC_INCLUDE_DIR, len)) { str = concat (iprefix, fname + len, NULL); - /* FIXME: wrap the headers for C++awareness. */ - add_path (str, INC_SYSTEM, /*c++aware=*/false, false); + add_path (str, INC_SYSTEM, /*c++aware=*/true, false); } - /* Should this directory start with the sysroot? */ - if (sysroot) - str = concat (sysroot, fname, NULL); - else - str = update_path (fname, ""); - - add_path (str, INC_SYSTEM, /*c++aware=*/false, false); + str = update_path (fname, ""); + add_path (str, INC_SYSTEM, /*c++aware=*/true, false); } }