From patchwork Thu Feb 4 16:22:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1436077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=k34wOjRd; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DWkNQ229Dz9sXb for ; Fri, 5 Feb 2021 03:22:27 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4DB63894C0C; Thu, 4 Feb 2021 16:22:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id 8998F3857021 for ; Thu, 4 Feb 2021 16:22:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8998F3857021 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x72c.google.com with SMTP id r77so3796729qka.12 for ; Thu, 04 Feb 2021 08:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=/pWXl6ZTkft99UjHBBV8OnFZCLrGRe8zMPAqqqTU8YY=; b=k34wOjRdxr0z2G3AjWD77PxYi4lA/HczEEke2cOAd/biWtJVCWAaUoDP8uHRX9k1+y cf6fNuMquWsoqPRzoTywJWBDlSr/jgdRwJLEbyIv5er2jx0gUILNWdig0ftVjl1gMvPb Mra9oT8wUh3BCDT7nsVKuioaozcUM4TaNOcwjTWdvVjVtdEclQ4CNOgDHQR2GTO/cCX6 P3o3ZqlrD1A3vyz0cQMhoNaTj7SOU7tOfKSziVQpbMAovOPI6HgzTaqa575bZ/NpuKEy QZGxheCo45dOpDZ3fYYcX5VSgDYdi/RrRMzO19bUCCkVADnp3iaTMEyFWoO5nt8k41av nvwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=/pWXl6ZTkft99UjHBBV8OnFZCLrGRe8zMPAqqqTU8YY=; b=hVN5QcnuI8r7ByC9a+YuP3308fUsYWOz+8uI0g53uJdbiNX6/ltQbcU41EGjbZlVis a8IeGZHGUbaCk5uHCqG1QSuCF14EhurXdjKKloesEQnvWcS5pJyOkd0ACEHAS9Y/15lb kR7JvC6ENqkPFLP0bVWvkfjWoK217irR2uyYMiYlxHqjY247AJ3/rcj6CkRxnwug6iLe 8e/xjGQz1zvg8R5Se4icYF9fkEJtYldoiH+w6NjGoQA+coyU6rS1LzlIaOhqr8IAvqKc IkTboIvo3xz/9PzkWs19ZtaNLZDN8Iz2WLlVelKY0SBWlOYB3sWi6Adrn8Uqkt/mlSfp RIhA== X-Gm-Message-State: AOAM531V33DUSf6c5gcDi3I2QcXS/iLTBQs08F5L7hb7kpvcR+If4JJW hE6MVfUtYKsKanq6lZoOGgo= X-Google-Smtp-Source: ABdhPJxyQLRyuPSVxxhyeIW//JM44kBN4ngXdt4EqLgecTXu57nay4SdpeQmdIGMmtoWKDU1MmnImQ== X-Received: by 2002:a05:620a:146a:: with SMTP id j10mr8179081qkl.166.1612455740118; Thu, 04 Feb 2021 08:22:20 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:6522:9449:89bb:c734? ([2620:10d:c091:480::1:1cbe]) by smtp.googlemail.com with ESMTPSA id v15sm5664263qkv.36.2021.02.04.08.22.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Feb 2021 08:22:18 -0800 (PST) To: GCC Patches , Joseph Myers From: Nathan Sidwell Subject: driver: error for nonexistent linker inputs [PR 98943] Message-ID: Date: Thu, 4 Feb 2021 11:22:17 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" We used to check all unknown input files, even when passing them to a compiler. But that caused problems. However, not erroring out on non-existent would-be-linker inputs confuses configure machinery that probes the compiler to see if it accepts various inputs. This restores the access check for things that are thought to be linker input files, when we're not linking. (If we are linking, we presume the linker will error out on its own accord.) We get a warning about not linking, and then an error about the file not being found. This seemed marginally better than a single error message conveying both pieces of information. devvm1702:30>./xg++ -B./ NOTAFILE -x c /dev/null -c xg++: warning: NOTAFILE: linker input file unused because linking not done xg++: error: NOTAFILE: linker input file not found: No such file or directory PR driver/98943 gcc/ * gcc.c (driver::maybe_run_linker): Check for input file accessibility if not linking. gcc/testsuite/ * c-c++-common/pr98943.c: New. booted & tested on x86_64-linux, ok? nathan diff --git c/gcc/gcc.c w/gcc/gcc.c index aa5774af7e7..96381a77dee 100644 --- c/gcc/gcc.c +++ w/gcc/gcc.c @@ -9020,8 +9020,15 @@ driver::maybe_run_linker (const char *argv0) const for (i = 0; (int) i < n_infiles; i++) if (explicit_link_files[i] && !(infiles[i].language && infiles[i].language[0] == '*')) - warning (0, "%s: linker input file unused because linking not done", - outfiles[i]); + { + warning (0, "%s: linker input file unused because linking not done", + outfiles[i]); + if (access (outfiles[i], F_OK) < 0) + /* This is can be an indication the user specifed an errorneous + separated option value, (or used the wrong prefix for an + option). */ + error ("%s: linker input file not found: %m", outfiles[i]); + } } /* The end of "main". */ diff --git c/gcc/testsuite/c-c++-common/pr98943.c w/gcc/testsuite/c-c++-common/pr98943.c new file mode 100644 index 00000000000..53d8838f242 --- /dev/null +++ w/gcc/testsuite/c-c++-common/pr98943.c @@ -0,0 +1,10 @@ +// { dg-do compile } +// PR 98943, compiler feature tests can get confused by not linking +// { dg-options "NOTAFILE" } + +int main () +{ + return 0; +} + +// { dg-regexp {[^\n:]*: warning: NOTAFILE: linker input file unused because linking not done\n[^\n:]*: error: NOTAFILE: linker input file not found: [^\n]*\n} }