From 8a5b5da0582525d4d1f84daabc66e8f01ddceef6 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 19 Jan 2022 16:33:07 +0100 Subject: [PATCH 1/6] #8920 - Define HAVE_MSVC_INVALID_PARAMETER_HANDLER --- recipes/m4/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py index 685ff90eb2324..7310b428a5645 100644 --- a/recipes/m4/all/conanfile.py +++ b/recipes/m4/all/conanfile.py @@ -62,6 +62,9 @@ def _configure_autotools(self): elif self.settings.compiler == "clang": if tools.Version(self.version) < "1.4.19": autotools.flags.extend(["-rtlib=compiler-rt", "-Wno-unused-command-line-argument"]) + if self.settings.os == 'Windows': + conf_args.extend(["ac_cv_func__set_invalid_parameter_handler=yes"]) + autotools.configure(args=conf_args, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name) return autotools From 858c03db484dd15621a688ceab98b719f1ce7498 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 19 Jan 2022 15:31:23 +0100 Subject: [PATCH 2/6] #8920 - Add a patch to call _CrtSetReportMode early in main --- recipes/m4/all/conandata.yml | 2 ++ .../1.4.19-0003-msvc-debug-assertion.patch | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch diff --git a/recipes/m4/all/conandata.yml b/recipes/m4/all/conandata.yml index 38c663a660406..add3c40a064ae 100644 --- a/recipes/m4/all/conandata.yml +++ b/recipes/m4/all/conandata.yml @@ -11,6 +11,8 @@ patches: base_path: "source_subfolder" - patch_file: "patches/1.4.19-0002-ar-lib.patch" base_path: "source_subfolder" + - patch_file: "patches/1.4.19-0003-msvc-debug-assertion.patch" + base_path: "source_subfolder" "1.4.18": - patch_file: "patches/1.4.18-0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch" base_path: "source_subfolder" diff --git a/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch b/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch new file mode 100644 index 0000000000000..94a0810eb4c20 --- /dev/null +++ b/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch @@ -0,0 +1,31 @@ +diff --git a/src/m4.c b/src/m4.c +index 2bd57750..ca3ded62 100644 +--- a/src/m4.c ++++ b/src/m4.c +@@ -36,6 +36,10 @@ + # include "assert.h" + #endif + ++#ifdef WIN32_NATIVE ++# include ++#endif ++ + /* TRANSLATORS: This is a non-ASCII name: The first name is (with + Unicode escapes) "Ren\u00e9" or (with HTML entities) "René". */ + #define AUTHORS proper_name_utf8 ("Rene' Seindal", "Ren\xC3\xA9 Seindal") +@@ -423,6 +427,15 @@ main (int argc, char *const *argv) + textdomain (PACKAGE); + atexit (close_stdin); + ++#ifdef WIN32_NATIVE ++ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); ++ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); ++ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); ++ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); ++ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); ++ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); ++#endif ++ + include_init (); + debug_init (); + From cd0eb83c420c90363b00262975d8a8a05c4c490a Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 24 Jan 2022 16:34:23 +0100 Subject: [PATCH 3/6] Wrong macro check --- recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch b/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch index 94a0810eb4c20..8e3df03effab4 100644 --- a/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch +++ b/recipes/m4/all/patches/1.4.19-0003-msvc-debug-assertion.patch @@ -6,7 +6,7 @@ index 2bd57750..ca3ded62 100644 # include "assert.h" #endif -+#ifdef WIN32_NATIVE ++#ifdef _WIN32 +# include +#endif + @@ -17,7 +17,7 @@ index 2bd57750..ca3ded62 100644 textdomain (PACKAGE); atexit (close_stdin); -+#ifdef WIN32_NATIVE ++#ifdef _WIN32 + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); From 4b39370f6dc14a08b8695eae9cf0d2f9e1e19173 Mon Sep 17 00:00:00 2001 From: SSE4 Date: Thu, 10 Feb 2022 00:55:49 +0700 Subject: [PATCH 4/6] HELP2MAN=/bin/true? --- recipes/m4/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py index 7310b428a5645..5b926b40668e2 100644 --- a/recipes/m4/all/conanfile.py +++ b/recipes/m4/all/conanfile.py @@ -64,6 +64,7 @@ def _configure_autotools(self): autotools.flags.extend(["-rtlib=compiler-rt", "-Wno-unused-command-line-argument"]) if self.settings.os == 'Windows': conf_args.extend(["ac_cv_func__set_invalid_parameter_handler=yes"]) + conf_args.extend(["HELP2MAN=/bin/true"]) autotools.configure(args=conf_args, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name) return autotools From 7018aba6d4b3d3f135ab5bbb4013ccaaf40ec386 Mon Sep 17 00:00:00 2001 From: SSE4 Date: Sat, 5 Mar 2022 15:51:23 +0700 Subject: [PATCH 5/6] - workaround make calling help2man (don't care, as we are not interested in man pages) Signed-off-by: SSE4 --- recipes/m4/all/conanfile.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py index 5b926b40668e2..1ec838afeb7e9 100644 --- a/recipes/m4/all/conanfile.py +++ b/recipes/m4/all/conanfile.py @@ -64,13 +64,13 @@ def _configure_autotools(self): autotools.flags.extend(["-rtlib=compiler-rt", "-Wno-unused-command-line-argument"]) if self.settings.os == 'Windows': conf_args.extend(["ac_cv_func__set_invalid_parameter_handler=yes"]) - conf_args.extend(["HELP2MAN=/bin/true"]) autotools.configure(args=conf_args, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name) return autotools @contextmanager def _build_context(self): + env = dict() if self.settings.compiler == "Visual Studio": with tools.vcvars(self.settings): env = { @@ -83,9 +83,8 @@ def _build_context(self): "RANLIB": ":", "STRIP": ":", } - with tools.environment_append(env): - yield - else: + env["PATH"] = [os.path.abspath(self._source_subfolder)] + with tools.environment_append(env): yield def _patch_sources(self): @@ -93,6 +92,10 @@ def _patch_sources(self): tools.patch(**patch) def build(self): + with tools.chdir(self._source_subfolder): + tools.save("help2man", '#!/usr/bin/env bash\n:') + if os.name == 'posix': + os.chmod("help2man", os.stat("help2man").st_mode | 0o111) self._patch_sources() with self._build_context(): autotools = self._configure_autotools() From 5c694ed6ab3d51dc47046fe6bf66adcef607ef54 Mon Sep 17 00:00:00 2001 From: SSE4 Date: Sun, 6 Mar 2022 00:46:20 +0700 Subject: [PATCH 6/6] - fix MSVC Signed-off-by: SSE4 --- recipes/m4/all/conanfile.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py index 1ec838afeb7e9..1178fd830275a 100644 --- a/recipes/m4/all/conanfile.py +++ b/recipes/m4/all/conanfile.py @@ -27,7 +27,7 @@ def _settings_build(self): @property def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + return self.settings.compiler == "Visual Studio" or self.settings.compiler == "msvc" def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): @@ -46,7 +46,7 @@ def _configure_autotools(self): autotools = AutoToolsBuildEnvironment(self, win_bash=self._settings_build.os == "Windows") build_canonical_name = None host_canonical_name = None - if self.settings.compiler == "Visual Studio": + if self._is_msvc: # The somewhat older configure script of m4 does not understand the canonical names of Visual Studio build_canonical_name = False host_canonical_name = False @@ -70,10 +70,10 @@ def _configure_autotools(self): @contextmanager def _build_context(self): - env = dict() - if self.settings.compiler == "Visual Studio": + env = {"PATH": [os.path.abspath(self._source_subfolder)]} + if self._is_msvc: with tools.vcvars(self.settings): - env = { + env.update({ "AR": "{}/build-aux/ar-lib lib".format(tools.unix_path(self._source_subfolder)), "CC": "cl -nologo", "CXX": "cl -nologo", @@ -82,10 +82,12 @@ def _build_context(self): "OBJDUMP": ":", "RANLIB": ":", "STRIP": ":", - } - env["PATH"] = [os.path.abspath(self._source_subfolder)] - with tools.environment_append(env): - yield + }) + with tools.environment_append(env): + yield + else: + with tools.environment_append(env): + yield def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []):