From: "plaisthos (Code Review)" Date: Tue, 17 Sep 2024 15:46:17 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="8gafk5LYZK8="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Add building/testing with msbuild and the clang compiler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --8gafk5LYZK8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld,=20 I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/751?usp=3Demail to look at the new patch set (#3). Change subject: Add building/testing with msbuild and the clang compiler ...................................................................... Add building/testing with msbuild and the clang compiler 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. Change-Id: I43d84034f3e920a45731c4aab4f851a60921290d Signed-off-by: Arne Schwabe --- M .github/workflows/build.yaml M CMakeLists.txt M CMakePresets.json M src/openvpnmsica/openvpnmsica.c M src/openvpnmsica/openvpnmsica.h 5 files changed, 67 insertions(+), 9 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/51/751/3 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 361d457..d326937 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -272,7 +272,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 6271574..a841590 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -624,7 +624,8 @@ check_linker_flag(C -Wl,--wrap=3Dparse_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..c53c960 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-release", + "configuration": "Release" + }, + { "name": "win-amd64-debug", "configurePreset": "win-amd64-debug", "configuration": "Debug" }, { + "name": "win-amd64-clang-debug", + "configurePreset": "win-amd64-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/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsic= a.c index 5ffb5b3..49d7944 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -300,7 +300,7 @@ UINT __stdcall FindSystemInfo(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -337,7 +337,7 @@ UINT __stdcall CloseOpenVPNGUI(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma comment(linker, DLLEXP_EXPORT) #endif UNREFERENCED_PARAMETER(hInstall); /* This CA is does not interact with= MSI session (report errors, access properties, tables, etc.). */ @@ -360,7 +360,7 @@ UINT __stdcall StartOpenVPNGUI(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -633,7 +633,7 @@ UINT __stdcall EvaluateTUNTAPAdapters(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -962,7 +962,7 @@ UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma comment(linker, DLLEXP_EXPORT) #endif @@ -1162,7 +1162,7 @@ UINT __stdcall CheckAndScheduleReboot(_In_ MSIHANDLE hInstall) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma comment(linker, DLLEXP_EXPORT) #endif diff --git a/src/openvpnmsica/openvpnmsica.h b/src/openvpnmsica/openvpnmsic= a.h index 6640d7e..76cba48 100644 --- a/src/openvpnmsica/openvpnmsica.h +++ b/src/openvpnmsica/openvpnmsica.h @@ -66,7 +66,8 @@ extern "C" { #endif -#ifdef __GNUC__ +/* Ensure that clang-cl, which defines __GNUC__ is not matched here */ +#if defined(__GNUC__) || defined(__clang__) #define DLLEXP_DECL __declspec(dllexport) #else #define DLLEXP_DECL -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/751?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I43d84034f3e920a45731c4aab4f851a60921290d Gerrit-Change-Number: 751 Gerrit-PatchSet: 3 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --8gafk5LYZK8= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos uploaded patch set #3 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/751?usp=3Demail">View Chang= e

Add building/testing with msbuild and the clang compiler

The L= LVM/clang compiler warning and error message are easier too read
than th= eir MSVC cl counterparts. Also compiling/running tests on Windows
with a= different compiler has the benefit of a better coverage.

Change-Id:= I43d84034f3e920a45731c4aab4f851a60921290d
Signed-off-by: Arne Schwabe &= lt;arne@...1227...>
---
M .github/workflows/build.yaml
M CMakeL= ists.txt
M CMakePresets.json
M src/openvpnmsica/openvpnmsica.c
M s= rc/openvpnmsica/openvpnmsica.h
5 files changed, 67 insertions(+), 9 dele= tions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/cha=
nges/51/751/3
diff --git a/.github/workflows/build.yaml b/.github/w=
orkflows/build.yaml
index 361d457..d326937 100644--- a/.github/workflows/build.yaml
+++ b/.github/wor= kflows/build.yaml
@@ -272,7 +272,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/CMak= eLists.txt b/CMakeLists.txt
index 6271574..a841590 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -624,7 +624,8 @@
check_linker_fla= g(C -Wl,--wrap=3Dparse_line LD_SUPPORTS_WRAP)
endif()<= /span>

- = if (${LD_SUPPORTS_WRAP})
+ # Clang-cl (which is also MSVC) is wrongly detected to support wra= p
+ if (NOT MSVC A= ND "${LD_SUPPORTS_WRAP}")
list(APPEND un= it_tests
"test_argv"
"test_tls_crypt"

diff --git a/CMake= Presets.json b/CMakePresets.json
index 135b19d..c53c960 100= 644
--- a/CMakePresets.json
+++ b/CMakePres= ets.json
@@ -122,6 +122,10 @@
= }
},
{
+ "name": "cl= angtoolset",
+ = "toolset": "ClangCL"
+ },
+ {
"name&quo= t;: "mingw-x64",
"inherits"= ;: [ "base", "base-mingw", "x64-mingw" ]
},
@@ -134,6 +138,10 @@
"inherits": [ "base", "base-windows= ", "x64", "release" ]

},<= /span>
{
+ "name": "win-amd64-clang-release",
+ "inh= erits": [ "base", "base-windows", "clangtools= et", "x64", "release" ]
+ },
+ {
"name"= : "win-arm64-release",
"inherit= s": [ "base", "base-windows", "arm64", &= quot;release" ]
},
@@ -142,10= +150,18 @@
"inherits": [ "base= ", "base-windows", "x86", "release" ]
},
{
+ "name": "win-x= 86-clang-release",
+ "inherits": [ "base", "base-window= s", "clangtoolset", "x86", "release" ]
+ },
= + {
= "name": "win-amd64-debug",
= "inherits": [ "base", "base-windows"= ;, "x64", "debug" ]
},<= br> {
+= "name": "win-amd64-clang-debug",
= + "inherits&quo= t;: [ "base", "base-windows", "clangtoolset",= "x64", "debug" ]
+ },
+ {
"name": "win= -arm64-debug",
"inherits": [ &q= uot;base", "base-windows", "arm64", "debug&qu= ot; ]
},
@@ -154,6 +170,10 @@
"inherits": [ "base", "ba= se-windows", "x86", "debug" ]
= },
{
+ "name": "win-x86-clang-debug"= ;,
+ "= ;inherits": [ "base", "base-windows", "clangt= oolset", "x86", "debug" ]
+ },
+ {
"name&quo= t;: "unix-native",
"generator&q= uot;: "Ninja Multi-Config",
"bi= naryDir": "out/build/unix"
@@ -174,6 +194,11= @@
"configuration": "Release&q= uot;
},
{
+ "name": "= ;win-amd64-clang-release",

+ "configurePreset": "win-amd64-clang-= release",
+ = "configuration": "Release"
+ },
+ {
"name&= quot;: "win-arm64-release",
"co= nfigurePreset": "win-arm64-release",
= "configuration": "Release"
@@ -18= 4,11 +209,21 @@
"configuration": &qu= ot;Release"
},
{
+ "name&= quot;: "win-x86-clang-release",
+ "configurePreset": "win-x8= 6-release",
+ = "configuration": "Release"
+ },
+ {
"nam= e": "win-amd64-debug",
"co= nfigurePreset": "win-amd64-debug",
= "configuration": "Debug"
}= ,
{
+ "name": "win-amd64-clang-debug",
+ "con= figurePreset": "win-amd64-debug",
+ "configuration": "D= ebug"
+ }= ,
+ { "name": "win-arm64-debug",<= br> "configurePreset": "win-arm64-debug&qu= ot;,
"configuration": "Debug&qu= ot;
@@ -199,6 +234,11 @@
"= ;configuration": "Debug"
},<= br> {
+= "name": "win-x86-clang-debug",
+ "configurePrese= t": "win-x86-clang-debug",

+ "configuration": "Debug&qu= ot;
+ },
+ {
"name": "unix-native",

= "configurePreset": "unix-native"
<= span> }

@@ -209,18 +249,34 @@
= "configurePreset": "win-amd64-release" },
{
+ "name": "win-amd64-cl= ang-release",
+ = "configurePreset": "win-amd64-clang-release"=
+ },+ {
= "name": "win-x86-release",
= "configurePreset": "win-x86-release"=
},
{
+ "name": "win-x86-cl= ang-release",
+ = "configurePreset": "win-x86-clang-release"
+ },
= + {
= "name": "win-amd64-debug",
= "configurePreset": "win-amd64-debug" },
{
+ "name": "win-amd64-cl= ang-debug",
+ = "configurePreset": "win-amd64-clang-debug"
+ },
+ {

= "name": "win-x86-debug",
= "configurePreset": "win-x86-debug"
},

{
+ "name": "win-x86-clang-debu= g",
+ = "configurePreset": "win-x86-clang-debug"
+ },

+ {
&q= uot;name": "unix-native",
"= ;configurePreset": "unix-native"
}<= /span>
diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnm= sica/openvpnmsica.c
index 5ffb5b3..49d7944 100644--- a/src/openvpnmsica/openvpnmsica.c
+++ b/src/open= vpnmsica/openvpnmsica.c
@@ -300,7 +300,7 @@
UINT __stdcall

FindSystemInfo(_In_ MSIHANDLE hInstall)
{
-#ifd= ef _MSC_VER
+#if defi= ned(_MSC_VER) && !defined(__clang__)
#pragma comme= nt(linker, DLLEXP_EXPORT)
#endif
<= br>@@ -337,7 +337,7 @@
UINT __stdcall
CloseOpenVPNGUI(_In_ MSIHANDLE hInstall)

{
-#ifdef _MSC_VER

+#if defined(_MSC_VER) && !defi= ned(__clang__)
#pragma comment(linker, DLLEXP_EXPORT)
#endif
UNREFERENCED_PARAMETER(hInstall); = /* This CA is does not interact with MSI session (report errors, access pro= perties, tables, etc.). */
@@ -360,7 +360,7 @@
UINT __stdcall

StartOpenVPNGUI(_In_ MSIHANDLE hInstal= l)
{
-= #ifdef _MSC_VER
+#if = defined(_MSC_VER) && !defined(__clang__)
#pragma c= omment(linker, DLLEXP_EXPORT)
#endif

@@ -633,7 +633,7 @@
UINT __stdcall
= EvaluateTUNTAPAdapters(_In_ MSIHANDLE hInstall)
{
-#ifdef _MSC_VER<= br>+#if defined(_MSC_VER) &= & !defined(__clang__)
#pragma comment(linker, DLLEXP_E= XPORT)
#endif

@@ -962,7 = +962,7 @@
UINT __stdcall
ProcessDeferredA= ction(_In_ MSIHANDLE hInstall)
{
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__= )
#pragma comment(linker, DLLEXP_EXPORT)
= #endif

@@ -1162,7 +1162,7 @@
UINT __stdcall

CheckAndScheduleReboot(_In_ MSIHANDLE = hInstall)
{
-#ifdef _MSC_VER
-#ifdef __GNUC__
+/* Ensure that clang-cl, which d= efines __GNUC__ is not matched here */

+#if defined(__GNUC__) || defined(__clang__)
<= span> #define DLLEXP_DECL __declspec(dllexport)

#else
#define DLLEXP_DECL

To vie= w, visit = change 751. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43d84034f3e920a45731c4aab4f= 851a60921290d
Gerrit-Change-Number: 751
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--8gafk5LYZK8=--