From patchwork Fri Dec 27 11:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4021 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:998b:b0:5e7:b9eb:58e8 with SMTP id d11csp6149287mav; Fri, 27 Dec 2024 03:22:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWoi5Tss/sfrSX/WdzPJuh+9XZ6b489oCJ+IysfHS9OU2aUNa6DfNB+QfcNpGLUWoEeQcY9cl2Fh/o=@openvpn.net X-Google-Smtp-Source: AGHT+IGu6J+DHMtt4jkNxg7OilsHenudjUcwXda869fVK1e3KOq3hZ0ZEPoDZD63fa6B6D/K95uJ X-Received: by 2002:a05:6808:3510:b0:3eb:3190:152 with SMTP id 5614622812f47-3ed88f9b0a4mr16619604b6e.21.1735298544579; Fri, 27 Dec 2024 03:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735298544; cv=none; d=google.com; s=arc-20240605; b=ARX4vNXmviwUPqqIOVmRPbEx87jKi3jyVyGrMD86n8Bdt6FGCru6VXdUZmZ/fZAVxy z5Fj+DypO7m+C7iElsE2Xfl2gE/kVEtzWuPPcgVC/zWtIFNZDv1Lb39BXnb9r4vB5O9D PJQ3fRiBrO4fCVjR35QQHFO0nDZ7jrHwEWblyby+j3lbSGogbR8LDYzDaeHm380sRJN1 XsZw3DeySqoqx+cjmyVeKvglTUTQKhn+rW9ZZKyDl34yRN4DI1XxHwvsnfpsi4Ohvxzb MpAZYK0i0a9YxyTqpc/0id7X8Be0RBAt2L49rhZGoPmRqeQ4+Gx0pklC1ScjO7XvvvDr 4HvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=76kyuqXr49S39g8N5xCZ34riXlqjzWiiuxNHQYhdLoI=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=dXWK8NMpC5YewD/jJwlv9W2mjAqqkITXz37axeVYWo4HRsvsi0tIpLM4ay+qWsWlSB Ov5IMdKtTJdAdmpiNbr4y9s6BVgQmxUik+pPWxTUS+S20HnZvfnL29CTiZCNvvL/n3ce OnjbjIR0/CLMk/H6iIKsyqCKqVFhn5dad0addt5bjyv9t1yDBZltA4+bCP7aP2HCOsV9 lzphIx21o6+tZ7TpK2d0wsK188n6HXSkT6GZ0rfLJL9CIaCXXGHoWjR8gSTUmYeMfcC3 hOWh1rFJAumdP/Aqfpq46h9CQFUq74a16saMUDVVdUVxt8kJg4iEaURTPOZttj/8mybv h5Xw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iFGMfLjj; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="UThkOO/F"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-3ece268391fsi11550313b6e.214.2024.12.27.03.22.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Dec 2024 03:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iFGMfLjj; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="UThkOO/F"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tR8Q8-0008B1-DS; Fri, 27 Dec 2024 11:22:21 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tR8Q6-0008As-L9 for openvpn-devel@lists.sourceforge.net; Fri, 27 Dec 2024 11:22:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WTmKwhRaf2/6njKCMEHwE2bZTB+Ch6La3SsF39tTFlI=; b=iFGMfLjjBO0smXV1aZf4/Sd+1q GooHaLSxDb3b78MAO4ixNYOhdbPI1kR0hEcLAp86FjmpPWnL2KdbYmStpCI3Jnq0uXn57twrIxoUJ Jimi7lBlcVJR0V3ptxFMu+aANuJ9vGdDIFvbvTN+yGMe05S+/J3yz3ozcvyBDFXYkspE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WTmKwhRaf2/6njKCMEHwE2bZTB+Ch6La3SsF39tTFlI=; b=UThkOO/FjAgwOIsR4VsrofkpWD 1IS3psmjx5cylW6D3i+DzVCdyJn8R6TymKxSs+qqy6FUeJESzEaSEo+OLZQDuzdmzEtT94hI92cDZ vKMXZ7M/xZi5+1uZB4oKrhva7Gop9hGsTQ3/Ioi3CAl0Km5Bhci66Pzx28QAmhz/sQj4=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tR8Q5-0008Fw-6z for openvpn-devel@lists.sourceforge.net; Fri, 27 Dec 2024 11:22:19 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 4BRBMAGU011630 for ; Fri, 27 Dec 2024 12:22:10 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 4BRBMA7n011629 for openvpn-devel@lists.sourceforge.net; Fri, 27 Dec 2024 12:22:10 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 27 Dec 2024 12:22:07 +0100 Message-ID: <20241227112209.11572-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Arne Schwabe The LLVM/clang compiler warning and error message are easier too read than their MSVC cl counterparts. Also compiling/running tests on Windows with a different compiler has the benefit of a better cov [...] Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in bl.score.senderscore.com] X-Headers-End: 1tR8Q5-0008Fw-6z Subject: [Openvpn-devel] [PATCH v6] Add building/testing with msbuild and the clang compiler X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1819592406297250730?= X-GMAIL-MSGID: =?utf-8?q?1819592406297250730?= From: Arne Schwabe The LLVM/clang compiler warning and error message are easier too read than their MSVC cl counterparts. Also compiling/running tests on Windows with a different compiler has the benefit of a better coverage. This includes a few minor changes to allow clang-cl to compile the project. Change-Id: I43d84034f3e920a45731c4aab4f851a60921290d Signed-off-by: Arne Schwabe Acked-by: Lev Stipakov --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/751 This mail reflects revision 6 of this Change. Acked-by according to Gerrit (reflected above): Lev Stipakov diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3958ef0..767de0b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -259,7 +259,7 @@ strategy: fail-fast: false matrix: - arch: [amd64, x86, arm64] + arch: [amd64, x86, arm64, amd64-clang, x86-clang] name: "msbuild - ${{ matrix.arch }} - openssl" env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 61f0cc5..5b5b7ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,7 +627,8 @@ check_linker_flag(C -Wl,--wrap=parse_line LD_SUPPORTS_WRAP) endif() - if (${LD_SUPPORTS_WRAP}) + # Clang-cl (which is also MSVC) is wrongly detected to support wrap + if (NOT MSVC AND "${LD_SUPPORTS_WRAP}") list(APPEND unit_tests "test_argv" "test_tls_crypt" diff --git a/CMakePresets.json b/CMakePresets.json index 135b19d..b6ec201 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -122,6 +122,10 @@ } }, { + "name": "clangtoolset", + "toolset": "ClangCL" + }, + { "name": "mingw-x64", "inherits": [ "base", "base-mingw", "x64-mingw" ] }, @@ -134,6 +138,10 @@ "inherits": [ "base", "base-windows", "x64", "release" ] }, { + "name": "win-amd64-clang-release", + "inherits": [ "base", "base-windows", "clangtoolset", "x64", "release" ] + }, + { "name": "win-arm64-release", "inherits": [ "base", "base-windows", "arm64", "release" ] }, @@ -142,10 +150,18 @@ "inherits": [ "base", "base-windows", "x86", "release" ] }, { + "name": "win-x86-clang-release", + "inherits": [ "base", "base-windows", "clangtoolset", "x86", "release" ] + }, + { "name": "win-amd64-debug", "inherits": [ "base", "base-windows", "x64", "debug" ] }, { + "name": "win-amd64-clang-debug", + "inherits": [ "base", "base-windows", "clangtoolset", "x64", "debug" ] + }, + { "name": "win-arm64-debug", "inherits": [ "base", "base-windows", "arm64", "debug" ] }, @@ -154,6 +170,10 @@ "inherits": [ "base", "base-windows", "x86", "debug" ] }, { + "name": "win-x86-clang-debug", + "inherits": [ "base", "base-windows", "clangtoolset", "x86", "debug" ] + }, + { "name": "unix-native", "generator": "Ninja Multi-Config", "binaryDir": "out/build/unix" @@ -174,6 +194,11 @@ "configuration": "Release" }, { + "name": "win-amd64-clang-release", + "configurePreset": "win-amd64-clang-release", + "configuration": "Release" + }, + { "name": "win-arm64-release", "configurePreset": "win-arm64-release", "configuration": "Release" @@ -184,11 +209,21 @@ "configuration": "Release" }, { + "name": "win-x86-clang-release", + "configurePreset": "win-x86-clang-release", + "configuration": "Release" + }, + { "name": "win-amd64-debug", "configurePreset": "win-amd64-debug", "configuration": "Debug" }, { + "name": "win-amd64-clang-debug", + "configurePreset": "win-amd64-clang-debug", + "configuration": "Debug" + }, + { "name": "win-arm64-debug", "configurePreset": "win-arm64-debug", "configuration": "Debug" @@ -199,6 +234,11 @@ "configuration": "Debug" }, { + "name": "win-x86-clang-debug", + "configurePreset": "win-x86-clang-debug", + "configuration": "Debug" + }, + { "name": "unix-native", "configurePreset": "unix-native" } @@ -209,18 +249,34 @@ "configurePreset": "win-amd64-release" }, { + "name": "win-amd64-clang-release", + "configurePreset": "win-amd64-clang-release" + }, + { "name": "win-x86-release", "configurePreset": "win-x86-release" }, { + "name": "win-x86-clang-release", + "configurePreset": "win-x86-clang-release" + }, + { "name": "win-amd64-debug", "configurePreset": "win-amd64-debug" }, { + "name": "win-amd64-clang-debug", + "configurePreset": "win-amd64-clang-debug" + }, + { "name": "win-x86-debug", "configurePreset": "win-x86-debug" }, { + "name": "win-x86-clang-debug", + "configurePreset": "win-x86-clang-debug" + }, + { "name": "unix-native", "configurePreset": "unix-native" } diff --git a/config.h.cmake.in b/config.h.cmake.in index 3c517d7..74a53a6 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -439,8 +439,10 @@ # define _GNU_SOURCE 1 #endif - -#if defined(_WIN32) +/* if inttypes.h is included this breaks rc.exe when using the ClangCL + * Toolchain as it pulls in a inttypes.h variant for clang that rc.exe does + * not understand (#include_next preprocessor directive) */ +#if defined(_WIN32) && !defined(RC_INVOKED) #include typedef uint32_t in_addr_t; typedef uint16_t in_port_t; @@ -452,7 +454,7 @@ #define SIGTERM 15 #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(RC_INVOKED) #include typedef SSIZE_T ssize_t; #define strncasecmp strnicmp diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index 154fff4..17152e0 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -303,7 +303,7 @@ UINT __stdcall FindSystemInfo(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#ifdef DLLEXP_EXPORT #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -340,7 +340,7 @@ UINT __stdcall CloseOpenVPNGUI(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#ifdef DLLEXP_EXPORT #pragma comment(linker, DLLEXP_EXPORT) #endif UNREFERENCED_PARAMETER(hInstall); /* This CA is does not interact with MSI session (report errors, access properties, tables, etc.). */ @@ -363,7 +363,7 @@ UINT __stdcall StartOpenVPNGUI(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#ifdef DLLEXP_EXPORT #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -636,7 +636,7 @@ UINT __stdcall EvaluateTUNTAPAdapters(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#ifdef DLLEXP_EXPORT #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -789,7 +789,7 @@ { goto cleanup_szDisplayName; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) /* * warning: enumeration value ‘MSICONDITION_TRUE’ not handled in switch * warning: enumeration value ‘MSICONDITION_NONE’ not handled in switch @@ -809,7 +809,7 @@ free(szValue); goto cleanup_szDisplayName; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif free(szValue); @@ -965,7 +965,7 @@ UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#ifdef DLLEXP_EXPORT #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -1165,7 +1165,7 @@ UINT __stdcall CheckAndScheduleReboot(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#ifdef DLLEXP_EXPORT #pragma comment(linker, DLLEXP_EXPORT) #endif diff --git a/src/openvpnmsica/openvpnmsica.h b/src/openvpnmsica/openvpnmsica.h index 7aacdf3..761aa47 100644 --- a/src/openvpnmsica/openvpnmsica.h +++ b/src/openvpnmsica/openvpnmsica.h @@ -66,7 +66,11 @@ extern "C" { #endif -#ifdef __GNUC__ +/* Ensure that clang-cl, which does not understand the cl specific + * preprocessor defines like #pragma comment(linker, DLLEXP_EXPORT) + * is handled the same way as mingw and uses the alternative instead + * and does not define DLLEXP_EXPORT */ +#if defined(__GNUC__) || defined(__clang__) #define DLLEXP_DECL __declspec(dllexport) #else #define DLLEXP_DECL diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/openvpn/test_buffer.c index 0fb4697..06e8b98 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -389,8 +389,9 @@ /* Instead of trying to trick the compiler here, disable the warnings * for this unit test. We know that the results will be truncated - * and we want to test that */ -#if defined(__GNUC__) + * and we want to test that. Not we need the clang as clang-cl (msvc) does + * not define __GNUC__ like it does under UNIX(-like) platforms */ +#if defined(__GNUC__) || defined(__clang__) /* some clang version do not understand -Wformat-truncation, so ignore the * warning to avoid warnings/errors (-Werror) about unknown pragma/option */ #if defined(__clang__) @@ -418,7 +419,7 @@ assert_int_equal(ret, 10); assert_int_equal(buf[9], '\0'); -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #if defined(__clang__) #pragma clang diagnostic pop