Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p4j18-00041H-Mq for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2022 13:38:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p4j17-0002bZ-Jd for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2022 13:38:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p4j17-0002bQ-9P for pgsql-hackers@lists.postgresql.org; Mon, 12 Dec 2022 13:38:49 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p4j10-00057f-AC for pgsql-hackers@lists.postgresql.org; Mon, 12 Dec 2022 13:38:48 +0000 Received: by mail-wm1-x32c.google.com with SMTP id b24-20020a05600c4a9800b003d21efdd61dso3639583wmp.3 for ; Mon, 12 Dec 2022 05:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=y4VDF1IZ25eOJteqrUIsl0qAGa058Kqa6KJJIwLjLxc=; b=LAHnXtC1f3Jx0zlbo4UbrKjXskB7UXTIAuO++SbuHLownseWezZyaN6abPc1YYA3o0 4BMqBY63mI2IV+IRAG3XRKkDea31+aE9qcdwWdzGl3m0ER1xkNsGF/NmQNwh2xP66Puu A69iazerXow//+EvImDURFhcFoxd+rAUyjauNVpVo27Rvd+d/VIPl3Uj+sclTsMloGER LWM6JFfi+VcdvF93D2fge/XE1GTt9zoBmfmqsGc3iVJjeXrGhZOdbSBS8N+DCzX7/9W+ VOaGAxTobbnIZyFJkJZUxL5afA9FgRXCT9ASCgCHCzpf4droE2mNigVvkMCF9SQkOZqS FOsg== 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 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y4VDF1IZ25eOJteqrUIsl0qAGa058Kqa6KJJIwLjLxc=; b=yBxyT5NY7T8SlG7ASS6H+Hd7WQTV4ldlOq+u+uCawY/Z9D0N8+9s5kfKcU7SaKlEaf LYxLJ+rUFKhX2z3Sa4JKfBYpYa6XQ+9XLXCcvo0y8jXnMyQYF85pIhGIFr7l9sDPqA3q mfYovkQZ9vU/TNT55qVY8pyPs2MZI0fqU0Wvxf3lId8jfRjYR/SbHiWTJa/3EYXaZ4SH 3x2fB1612kHBryettJMpbg4vSMftkAW+KbjM7Nl5BBaCCxa0ar9wbtN6fkIXg94qIJCU PqyOBvi5pl6oeDukGHGJnCx8dH/NTlVCx+LaayHnJDglo/rDns3noyHwqy0uZf90EdlM R4Xw== X-Gm-Message-State: ANoB5pllF6gdccqpRAezAkr4ASi/H+0xANDFEFsXhCYCpVTdM48dLP5f VtS9jEf3BtSFDQ4pkuAZbbNuzA== X-Google-Smtp-Source: AA0mqf7bibRVci4doTSzQZ3NxNYaq+8v1i3GMu8QtO89FaxqO2oKcN4RHM4jHlUxpVHcmKBU2x2LdQ== X-Received: by 2002:a7b:c30e:0:b0:3c6:e63d:fcf6 with SMTP id k14-20020a7bc30e000000b003c6e63dfcf6mr13005703wmj.29.1670852320170; Mon, 12 Dec 2022 05:38:40 -0800 (PST) Received: from [192.168.1.166] ([212.228.7.114]) by smtp.gmail.com with ESMTPSA id f9-20020a05600c154900b003d2157627a8sm10140632wmg.47.2022.12.12.05.38.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 05:38:39 -0800 (PST) Message-ID: <6cfaaf3c-7fb5-51c8-92cf-ceac6303ef66@linaro.org> Date: Mon, 12 Dec 2022 13:38:37 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] Add native windows on arm64 support Content-Language: en-US To: Andres Freund , Michael Paquier Cc: Ian Lawrence Barwick , Tom Lane , Thomas Munro , Julien Rouhaud , PostgreSQL Hackers References: <271611.1661998926@sss.pgh.pa.us> <20221105183136.hfxyl5dclxdcoyih@awork3.anarazel.de> <7ff7c416-fdfe-517f-a65c-9e5bd8ff8cec@linaro.org> <8d46c46d-66d3-758b-b686-de371e0ba8ca@linaro.org> <20221205181449.47mhosidtmotemdl@awork3.anarazel.de> From: Niyas Sait In-Reply-To: <20221205181449.47mhosidtmotemdl@awork3.anarazel.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 05/12/2022 18:14, Andres Freund wrote: >> With meson gaining in maturity, perhaps that's not the most urgent >> thing as we will likely remove src/tools/msvc/ soon but I'd rather do >> that right anyway as much as I can to avoid an incorrect state in the >> tree at any time in its history. > > I'd actually argue that we should just not add win32 support to > src/tools/msvc/. > > I think the old build system specific part is really minimal in the patch. I can strip out those if that's preferred. >> --- a/src/include/storage/s_lock.h >> +++ b/src/include/storage/s_lock.h >> @@ -708,13 +708,21 @@ typedef LONG slock_t; >> #define SPIN_DELAY() spin_delay() >> >> /* If using Visual C++ on Win64, inline assembly is unavailable. >> - * Use a _mm_pause intrinsic instead of rep nop. >> + * Use _mm_pause (x64) or __isb (arm64) intrinsic instead of rep nop. >> */ >> #if defined(_WIN64) >> static __forceinline void >> spin_delay(void) >> { >> +#ifdef _M_ARM64 >> + /* >> + * See spin_delay aarch64 inline assembly definition above for details >> + * ref: https://learn.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics#BarrierRestrictions >> + */ >> + __isb(_ARM64_BARRIER_SY); >> +#else >> _mm_pause(); >> +#endif >> } >> #else >> static __forceinline void > > This looks somewhat wrong to me. We end up with some ifdefs on the function > defintion level, and some others inside the function body. I think it should > be either or. > Ok, I can add an MSVC/ARM64 specific function. >> diff --git a/meson.build b/meson.build >> index 725e10d815..e354ad7650 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -1944,7 +1944,13 @@ int main(void) >> >> elif host_cpu == 'arm' or host_cpu == 'aarch64' >> >> - prog = ''' >> + if cc.get_id() == 'msvc' >> + cdata.set('USE_ARMV8_CRC32C', false) >> + cdata.set('USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK', 1) >> + have_optimized_crc = true >> + else >> + >> + prog = ''' >> #include >> >> int main(void) > Why does this need to be hardcoded? The compiler probe should just work for > msvc. > There are couple of minor issues in the code probe with MSVC such as arm_acle.h needs to be removed and requires an explicit import of intrin.h. But even with those fixes, USE_ARMV8_CRC32C would be set and no runtime CRC extension check will be performed. Since CRC extension is optional in ARMv8, It would be better to use the CRC variant with runtime check. So I end up following the x64 variant and hardcoded the flags in case of ARM64 and MSVC. -- Niyas