From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by sourceware.org (Postfix) with ESMTPS id 0D7DB3858415 for ; Thu, 3 Nov 2022 14:17:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D7DB3858415 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-x82c.google.com with SMTP id s4so1276662qtx.6 for ; Thu, 03 Nov 2022 07:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=mTXA05wEClyQG2ISXcQI+OvTKKenJ1ust7JGj8T1UBE=; b=Glhbgirv8c090pWbei8e5UTFQM3sCbs64r9j3s1hovvr1ibzm8evOs8HAyiV//wGt0 69r998z78+9ccR0m/gOewRxUFGYGIZ6h1GifHoGx1H4PL9dhDL/pwtMXlbPnxH4FjhLX wsrVjfAwThzWufkiSZrrRyFNTxsAbmjIIbUCR/+Gqv4cctBCvFJaJgxUZ8BB1l61Syso PB+oyiv8YmeLTdSvyDGOG5Z2Yjwpt72FkSqnndzpkQFB+fDc2MuC5DlJFd0grpIINrOi 6g5UEpEspPzkezzKCEuAuGwvCBiC+x/Cc32AMpZCWkA7WGChZfrYAQoc3rWrt/ptjnH3 R4zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mTXA05wEClyQG2ISXcQI+OvTKKenJ1ust7JGj8T1UBE=; b=TsGAeH9sf0fotz4LB2+XtchHzfQ/NfnUTpxKxeNG47WstfMHWj8L4H90QsaLjxGn0u DQ2CNjAP+Iw2MWPwcCgIe80V6nXpYDL2UBg75NkmrPHdk9VbWuz3byKu/sPe0s0Wh4nY 9oA6R0gbop2naP/6Zzc41W6PFjZAdpwp8zA2f5IgBl9I316qnr7tQLtzKRrWRNBwdvMo dQ/DNYIffVe56vbd2KvVSI1o/TynOcAhSzoLxF20lDWAp6bS0UpnaaW8Qx3AHzBftz9D iWd0HCiWQxuh+DWMSba6Fun1FtGiVpQ8x5jeewYOi9bhyL8R1RjvbJ1NCz8L6+NaRQ10 vpcA== X-Gm-Message-State: ACrzQf36sg8pAh3wOG1U9ay0vxVcDbuSaj+4UHKpt1fFUCq/ELCjJALF 443EIIRro76hHk9x482O09U= X-Google-Smtp-Source: AMsMyM5CurNyUe8kAMxa/SZ63fP36zoP35aLg3fCrf4TV08qop6bEN8HIIqGc66TXu3LypwRJzlL+Q== X-Received: by 2002:ac8:7c7:0:b0:3a5:573f:4463 with SMTP id m7-20020ac807c7000000b003a5573f4463mr1910279qth.235.1667485054176; Thu, 03 Nov 2022 07:17:34 -0700 (PDT) Received: from ?IPV6:2601:19c:527f:bfd0::5? ([2601:19c:527f:bfd0::5]) by smtp.googlemail.com with ESMTPSA id d11-20020a05620a240b00b006b95b0a714esm871045qkn.17.2022.11.03.07.17.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 07:17:33 -0700 (PDT) Sender: Nathan Sidwell Message-ID: <6c6abd06-ae1a-059b-a376-db738af5506e@acm.org> Date: Thu, 3 Nov 2022 10:17:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH] c++: Allow module name to be a single letter on Windows Content-Language: en-US To: =?UTF-8?Q?Torbj=c3=b6rn_SVENSSON?= , gcc-patches@gcc.gnu.org Cc: yvan.roux@foss.st.com References: <20221028091500.2748920-1-torbjorn.svensson@foss.st.com> From: Nathan Sidwell In-Reply-To: <20221028091500.2748920-1-torbjorn.svensson@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3038.8 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,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/28/22 05:15, Torbjörn SVENSSON wrote: > On Windows, the ':' character is special and when the module name is > a single character, like 'A', then the flatname would be (for > example) 'A:Foo'. On Windows, 'A:Foo' is treated as an absolute > path by the module loader and is likely not found. > > Without this patch, the test case pr98944_c.C fails with: > > In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_b.C:7:1, > of module A:Foo, imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7: > A:Internals: error: header module expected, module 'A:Internals' found > A:Internals: error: failed to read compiled module: Bad file data > A:Internals: note: compiled module file is 'gcm.cache/A-Internals.gcm' > In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7:8: > A:Foo: error: failed to read compiled module: Bad import dependency > A:Foo: note: compiled module file is 'gcm.cache/A-Foo.gcm' > A:Foo: fatal error: returning to the gate for a mechanical issue > compilation terminated. > > include/ChangeLog: > > * filenames.h: Added IS_REAL_ABSOLUTE_PATH macro to check if > path is absolute and not semi-absolute on Windows. Hm, this is unfortunate. The current IS_ABSOLUTE_PATH, is really 'not relative to cwd', and even then that's untrue if the drive letter there is the drive letter of cwd, right? It's awkward to have a new macro for just this purpose and the new name isn't very indicative of the difference to the current IS_ABSOLUTE_PATH. Would it be better to not deal with drive letters here? How prevalent are they these days in windows? Would something like if (IS_DIR_SEPARATOR (ptr[ptr[0] == '.']) suffice? or, failing that perhaps put some explicit WINDOWS-specific #ifdef'd code there? It's a real corner case. nathan > > gcc/cp/ChangeLog: > > * module.cc: Use IS_REAL_ABSOLUTE_PATH macro. > > Co-Authored-By: Yvan ROUX > Signed-off-by: Torbjörn SVENSSON > --- > gcc/cp/module.cc | 2 +- > include/filenames.h | 4 ++++ > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc > index 9957df510e6..84680e183b7 100644 > --- a/gcc/cp/module.cc > +++ b/gcc/cp/module.cc > @@ -13958,7 +13958,7 @@ get_module (tree name, module_state *parent, bool partition) > static module_state * > get_module (const char *ptr) > { > - if (ptr[0] == '.' ? IS_DIR_SEPARATOR (ptr[1]) : IS_ABSOLUTE_PATH (ptr)) > + if (ptr[0] == '.' ? IS_DIR_SEPARATOR (ptr[1]) : IS_REAL_ABSOLUTE_PATH (ptr)) > /* A header name. */ > return get_module (build_string (strlen (ptr), ptr)); > > diff --git a/include/filenames.h b/include/filenames.h > index 6c72c422edd..d04fccfed64 100644 > --- a/include/filenames.h > +++ b/include/filenames.h > @@ -43,6 +43,7 @@ extern "C" { > # define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f) > # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c) > # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f) > +# define IS_REAL_ABSOLUTE_PATH(f) IS_DOS_REAL_ABSOLUTE_PATH (f) > #else /* not DOSish */ > # if defined(__APPLE__) > # ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM > @@ -52,6 +53,7 @@ extern "C" { > # define HAS_DRIVE_SPEC(f) (0) > # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c) > # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f) > +# define IS_REAL_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH (f) > #endif > > #define IS_DIR_SEPARATOR_1(dos_based, c) \ > @@ -67,6 +69,8 @@ extern "C" { > > #define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c) > #define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f) > +#define IS_DOS_REAL_ABSOLUTE_PATH(f) \ > + ((f)[0] && (f)[1] == ':' && ((f)[2] == '/' || (f)[2] == '\\')) > #define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f) > > #define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c) -- Nathan Sidwell