From: "cron2 (Code Review)" Date: Thu, 18 Sep 2025 12:49:29 +0000 In-Reply-To: References: Reply-To: gert@...1296..., 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="FRjvIk1FJVs="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --FRjvIk1FJVs= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1197?usp=3Demail to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review-1 by flichtenheld Change subject: fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw= builds ...................................................................... fix building of openvpnsrvmsg.dll from eventmsg.mc in mingw builds commit 06919a60ae61 introduces .mc files that need to be compiled to .h and .bin by the windows "mc.exe" tool, and from there into a new .dll. This worked for MSVC builds, did nothing for cmake/mingw builds, and broke compilation on autoconf/mingw builds. This patch consists of two parts: 1. add building of openvpnsrvmsg.dll to autoconf/mingw builds Add logic to configure.ac to find the "windmc" binary in the linux or mingw variants, add rules to src/openvpnserv/Makefile.am so make knows what to do. Libtool is getting in the way when "openvpnsrvmsg.dll" is created as anything listed in ...BIN or ...LIB, so decare it as "DATA" and make the necessary rules explicit. 2. fix building of openvpnsrvmsg.dll on cmake/mingw builds Fix "find_program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there). Change from "-Wl,--noentry" to linker invocation that works. See also: https://learn.microsoft.com/en-us/cpp/build/creating-a-resource-only-dll?vi= ew=3Dmsvc-170 Change-Id: I071e8190dac28f429257b8af1c6f9e68f8896bc0 Signed-off-by: Gert Doering --- M configure.ac M src/openvpnserv/CMakeLists.txt M src/openvpnserv/Makefile.am 3 files changed, 22 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/3 diff --git a/configure.ac b/configure.ac index 7059871..38b14a1 100644 --- a/configure.ac +++ b/configure.ac @@ -441,6 +441,7 @@ AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool]) AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool]) AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"],= [Path to systemd-ask-password tool]) +AC_CHECK_TOOLS([WINDMC], [windmc mc.exe],[no]) # # man page generation - based on python-docutils diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt index 82099f1..4496bae 100644 --- a/src/openvpnserv/CMakeLists.txt +++ b/src/openvpnserv/CMakeLists.txt @@ -41,7 +41,7 @@ file(MAKE_DIRECTORY ${MC_GEN_DIR}) set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eventmsg.mc) -find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i686-w6= 4-mingw32-windmc windmc) +find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i686-w64-m= ingw32-windmc windmc) if (NOT MC_COMPILER) message(FATAL_ERROR "No message compiler found.") @@ -58,12 +58,17 @@ add_custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GE= N_DIR}/eventmsg.h) add_library(openvpnservmsg SHARED ${MC_GEN_DIR}/eventmsg.rc) +add_dependencies(openvpnservmsg msg_mc_gen) if (MSVC) - set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "/NOENTRY") + set_target_properties(openvpnservmsg PRIVATE "/NOENTRY") else() - target_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry") + set_target_properties(openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTP= UT_NAME "openvpnservmsg") + target_link_options(openvpnservmsg PRIVATE + -Wl,--entry=3D0 + -nostdlib + -nostartfiles + ) endif() -add_dependencies(openvpnservmsg msg_mc_gen) add_dependencies(openvpnserv msg_mc_gen) diff --git a/src/openvpnserv/Makefile.am b/src/openvpnserv/Makefile.am index ef5f3f3..a27fbbf 100644 --- a/src/openvpnserv/Makefile.am +++ b/src/openvpnserv/Makefile.am @@ -28,6 +28,10 @@ openvpnserv_LDADD =3D \ -ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpcrt4 \ -lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32 +noinst_DATA =3D \ + MSG00409.bin eventmsg.h eventmsg.rc openvpnservmsg.dll +BUILT_SOURCES =3D \ + eventmsg.h endif openvpnserv_SOURCES =3D \ @@ -37,3 +41,11 @@ validate.c validate.h \ $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block= .h \ openvpnserv_resources.rc + +openvpnservmsg.dll: eventmsg.o + $(CC) -shared -Wl,--entry=3D0 -nostdlib -nostartfiles -o $@ $< + +eventmsg.o: eventmsg.rc + +eventmsg.h: eventmsg.mc + $(WINDMC) -U $< -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1197?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: I071e8190dac28f429257b8af1c6f9e68f8896bc0 Gerrit-Change-Number: 1197 Gerrit-PatchSet: 3 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --FRjvIk1FJVs= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: cron2, flichtenheld, plaisthos. <= /p>

cron2 uploaded patch set #3 to this change.

View Change

The following approvals got outdated and were removed: Code-Review-1 by flichtenheld

fix building of openvpnsrvmsg.dll from eventm=
sg.mc in mingw builds

commit 06919a60ae61 introduces .mc files that = need to be compiled to
.h and .bin by the windows "mc.exe" too= l, and from there into a new
.dll. This worked for MSVC builds, did not= hing for cmake/mingw builds,
and broke compilation on autoconf/mingw bui= lds.

This patch consists of two parts:

1. add building of ope= nvpnsrvmsg.dll to autoconf/mingw builds

Add logic to configure.ac= to find the "windmc" binary in the linux or
mingw variants= , add rules to src/openvpnserv/Makefile.am so make knows
what to do.<= br>
Libtool is getting in the way when "openvpnsrvmsg.dll" = is created as
anything listed in ...BIN or ...LIB, so decare it as &q= uot;DATA" and make
the necessary rules explicit.

2. fix b= uilding of openvpnsrvmsg.dll on cmake/mingw builds

Fix "find= _program()" invocation to avoid using "midnight commander" binary (mc) on Linux (called "windmc" there).

Chan= ge from "-Wl,--noentry" to linker invocation that works.

S= ee also:
https://learn.microsoft.com/en-us/cpp/build/creating-a-resource= -only-dll?view=3Dmsvc-170

Change-Id: I071e8190dac28f429257b8af1c6f9e= 68f8896bc0
Signed-off-by: Gert Doering <gert@...1296...>
---M configure.ac
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Ma= kefile.am
3 files changed, 22 insertions(+), 4 deletions(-)

gi=
t pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/1197/3
<= pre style=3D"font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/configure.ac b/configure.ac
index 7059871..3= 8b14a1 100644
--- a/configure.ac
+++ b/conf= igure.ac
@@ -441,6 +441,7 @@
AC_DEFINE_UNQ= UOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to= route tool])
AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PAT= H], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool= ])
+AC_CHECK_TOOLS([W= INDMC], [windmc mc.exe],[no])

# # man page generation - based on python-docutils
= diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.tx= t
index 82099f1..4496bae 100644
--- a/src/o= penvpnserv/CMakeLists.txt
+++ b/src/openvpnserv/CMakeLists.= txt
@@ -41,7 +41,7 @@
file(MAKE_DIRECTORY = ${MC_GEN_DIR})
set(MC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/eve= ntmsg.mc)

-find_program(MC_COMPILER NAMES mc mc.exe x86_64-w64-mingw32-windmc i6= 86-w64-mingw32-windmc windmc)
+find_program(MC_COMPILER NAMES mc.exe x86_64-w64-mingw32-windmc i= 686-w64-mingw32-windmc windmc)

if (NOT M= C_COMPILER)
message(FATAL_ERROR "No message compi= ler found.")
@@ -58,12 +58,17 @@
add_= custom_target(msg_mc_gen ALL DEPENDS ${MC_GEN_DIR}/eventmsg.rc ${MC_GEN_DIR= }/eventmsg.h)

add_library(openvpnservmsg= SHARED ${MC_GEN_DIR}/eventmsg.rc)
+add_dependencies(openvpnservmsg msg_mc_gen)
=
if (MSVC)
- set_target_properties(openvpnservmsg PROPERTIES LINK_FLAGS "= ;/NOENTRY")
+ = set_target_properties(openvpnservmsg PRIVATE "/NOENTRY")<= br> else()
- t= arget_link_options(openvpnservmsg PRIVATE "-Wl,--no-entry")
+ set_target_properties= (openvpnservmsg PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "openvpnservm= sg")
+ target= _link_options(openvpnservmsg PRIVATE
+ -Wl,--entry=3D0
+ -nostdlib
+ -nostartfiles
+ )
endif()

-add_dependencies(openvpnser= vmsg msg_mc_gen)
add_dependencies(openvpnserv msg_mc_gen)<= /span>
diff --git a/src/openvpnserv/Makefile.am b/src/openvpnserv/= Makefile.am
index ef5f3f3..a27fbbf 100644
-= -- a/src/openvpnserv/Makefile.am
+++ b/src/openvpnserv/Make= file.am
@@ -28,6 +28,10 @@
openvpnserv_LDA= DD =3D \
-ladvapi32 -luserenv -liphlpapi -lfwpuclnt -lrpc= rt4 \
-lshlwapi -lnetapi32 -lws2_32 -lntdll -lole32
+noinst_DATA =3D \<= br>+ MSG00409.bin eventmsg.h ev= entmsg.rc openvpnservmsg.dll
+BUILT_SOURCES =3D \
+ eventmsg.h
endif

openvpnserv_SOURCES =3D \

@@ -37,3 +41,11 @@
= validate.c validate.h \
$(top_srcdir)/src/openvpn= /wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \
open= vpnserv_resources.rc
= +
+openvpnservmsg.dll= : eventmsg.o
+ $(CC) = -shared -Wl,--entry=3D0 -nostdlib -nostartfiles -o $@ $<
+

+eventmsg.o: eventmsg.rc
+
+eventmsg.h: eventmsg.mc
+ $(WINDMC) -U $<

To view, = visit ch= ange 1197. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I071e8190dac28f429257b8af1c6= f9e68f8896bc0
Gerrit-Change-Number: 1197
Gerrit-PatchSet: 3
Gerrit-Owner: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--FRjvIk1FJVs=--