Parcourir la source

Add botan versions 3.6.0 to 3.7.1 (#6450)

* Add botan versions 3.6.0 to 3.7.1

* Fix whitespace

* Backport MSVC flags fix

* Use os_utils with 3.7.0 and later

* Add patch to fix response files with ar

* Fix patch

* Fix checksum

* Temporarily alias arm64-v8a to arm64
Aidan Sun il y a 6 mois
Parent
commit
304a040435

+ 28 - 0
packages/b/botan/patches/3.6.0/ar-response-files.patch

@@ -0,0 +1,28 @@
+diff --git a/src/build-data/ninja.in b/src/build-data/ninja.in
+index 414663a..b983a95 100644
+--- a/src/build-data/ninja.in
++++ b/src/build-data/ninja.in
+@@ -59,7 +59,7 @@ default all
+ rule link_static
+   rspfile = %{response_file_dir}/static.txt
+   rspfile_content = $in
+-  command = %{ar_command} %{ar_options} %{ar_output_to}$out @%{response_file_dir}/static.txt
++  command = xargs %{ar_command} %{ar_options} %{ar_output_to}$out < %{response_file_dir}/static.txt
+ 
+ build %{out_dir}/%{static_lib_name}: link_static %{join lib_objs}
+ 
+@@ -86,12 +86,12 @@ build %{out_dir}/%{soname_patch}: symlink %{out_dir}/%{shared_lib_name}
+ rule link_cli
+   rspfile = %{response_file_dir}/cli_${cli_name}.txt
+   rspfile_content = $in
+-  command = ${EXE_LINK_CMD} ${ABI_FLAGS} @%{response_file_dir}/cli_${cli_name}.txt ${BUILD_DIR_LINK_PATH} ${LANG_EXE_FLAGS} ${LDFLAGS} ${EXE_LINKS_TO} %{output_to_exe}$out
++  command = xargs ${EXE_LINK_CMD} ${ABI_FLAGS} ${BUILD_DIR_LINK_PATH} ${LANG_EXE_FLAGS} ${LDFLAGS} ${EXE_LINKS_TO} %{output_to_exe}$out < %{response_file_dir}/cli_${cli_name}.txt
+ 
+ rule link_tests
+   rspfile = %{response_file_dir}/tests.txt
+   rspfile_content = $in
+-  command = ${EXE_LINK_CMD} ${ABI_FLAGS} @%{response_file_dir}/tests.txt ${BUILD_DIR_LINK_PATH} ${LANG_EXE_FLAGS} ${LDFLAGS} %{test_exe_extra_ldflags} ${EXE_LINKS_TO} %{output_to_exe}$out
++  command = xargs ${EXE_LINK_CMD} ${ABI_FLAGS} ${BUILD_DIR_LINK_PATH} ${LANG_EXE_FLAGS} ${LDFLAGS} %{test_exe_extra_ldflags} ${EXE_LINKS_TO} %{output_to_exe}$out < %{response_file_dir}/tests.txt
+ 
+ # Executable targets
+ 

+ 159 - 0
packages/b/botan/patches/3.6.0/msvc-compiler-flags.patch

@@ -0,0 +1,159 @@
+From 4f0218bcc0e311e37dd191329a6757bddb2ea97b Mon Sep 17 00:00:00 2001
+From: Jack Lloyd <[email protected]>
+Date: Sun, 1 Dec 2024 13:51:19 -0500
+Subject: [PATCH] Don't implicitly/always pass CXXFLAGS into LDFLAGS
+
+This was done to handle LTO (#4196 #4200) but causes problems especially for
+MSVC which in some (unclear) circumstances treats unknown flags to the linker as
+a hard error (#4451). Instead only pass CXXFLAGS into LDFLAGS when an extra
+option `--lto-cxxflags-to-ldflags` is provided to opt into this behavior.
+---
+ configure.py               | 76 +++++++++++++++++++-------------------
+ src/build-data/makefile.in |  2 +-
+ src/build-data/ninja.in    |  2 +-
+ 3 files changed, 41 insertions(+), 39 deletions(-)
+
+diff --git a/configure.py b/configure.py
+index 8d8d85d56c9..35c78bc10f7 100755
+--- a/configure.py
++++ b/configure.py
+@@ -379,6 +379,9 @@ def add_enable_disable_pair(group, what, default, msg=optparse.SUPPRESS_HELP):
+     target_group.add_option('--extra-cxxflags', metavar='FLAGS', default=[], action='append',
+                             help='set extra compiler flags')
+ 
++    target_group.add_option('--lto-cxxflags-to-ldflags', default=False, action='store_true',
++                            help='set all compilation flags also during linking (for LTO)')
++
+     target_group.add_option('--ldflags', metavar='FLAGS',
+                             help='set linker flags', default=None)
+ 
+@@ -1515,48 +1518,50 @@ def cc_lang_flags(self):
+     def cc_lang_binary_linker_flags(self):
+         return self.lang_binary_linker_flags
+ 
+-    def cc_compile_flags(self, options, with_debug_info=None, enable_optimizations=None):
+-        def gen_flags(with_debug_info, enable_optimizations):
++    def ldflags(self, options):
++        if options.ldflags:
++            yield options.ldflags
++
++        if options.lto_cxxflags_to_ldflags:
++            yield from self.cc_compile_flags(options)
+ 
+-            sanitizers_enabled = options.with_sanitizers or (len(options.enable_sanitizers) > 0)
++    def cc_compile_flags(self, options):
++        sanitizers_enabled = options.with_sanitizers or (len(options.enable_sanitizers) > 0)
+ 
+-            if with_debug_info is None:
+-                with_debug_info = options.with_debug_info
+-            if enable_optimizations is None:
+-                enable_optimizations = not options.no_optimizations
++        if options.cxxflags:
++            # CXXFLAGS is assumed to be the entire set of desired compilation flags
++            # if not the case the user should have used --extra-cxxflags
++            yield options.cxxflags
++            return
+ 
+-            if with_debug_info:
+-                yield self.debug_info_flags
++        if options.with_debug_info:
++            yield self.debug_info_flags
+ 
+-            if enable_optimizations:
+-                if options.optimize_for_size:
+-                    if self.size_optimization_flags != '':
+-                        yield self.size_optimization_flags
+-                    else:
+-                        logging.warning("No size optimization flags set for current compiler")
+-                        yield self.optimization_flags
+-                elif sanitizers_enabled and self.sanitizer_optimization_flags != '':
+-                    yield self.sanitizer_optimization_flags
++        if not options.no_optimizations:
++            if options.optimize_for_size:
++                if self.size_optimization_flags != '':
++                    yield self.size_optimization_flags
+                 else:
++                    logging.warning("No size optimization flags set for current compiler")
+                     yield self.optimization_flags
++            elif sanitizers_enabled and self.sanitizer_optimization_flags != '':
++                yield self.sanitizer_optimization_flags
++            else:
++                yield self.optimization_flags
+ 
+-            if options.arch in self.cpu_flags:
+-                yield self.cpu_flags[options.arch]
+-
+-            if options.arch in self.cpu_flags_no_debug:
+-
+-                # Only enable these if no debug/sanitizer options enabled
+-
+-                if not (options.debug_mode or sanitizers_enabled):
+-                    yield self.cpu_flags_no_debug[options.arch]
++        if options.arch in self.cpu_flags:
++            yield self.cpu_flags[options.arch]
+ 
+-            for flag in options.extra_cxxflags:
+-                yield flag
++        if options.arch in self.cpu_flags_no_debug:
++            # Only enable these if no debug/sanitizer options enabled
++            if not (options.debug_mode or sanitizers_enabled):
++                yield self.cpu_flags_no_debug[options.arch]
+ 
+-            for definition in options.define_build_macro:
+-                yield self.add_compile_definition_option + definition
++        for flag in options.extra_cxxflags:
++            yield flag
+ 
+-        return (' '.join(gen_flags(with_debug_info, enable_optimizations))).strip()
++        for definition in options.define_build_macro:
++            yield self.add_compile_definition_option + definition
+ 
+     @staticmethod
+     def _so_link_search(osname, debug_info):
+@@ -2264,9 +2269,6 @@ def test_exe_extra_ldflags():
+ 
+         'sanitizer_types' : sorted(cc.sanitizer_types),
+ 
+-        'cc_compile_opt_flags': cc.cc_compile_flags(options, False, True),
+-        'cc_compile_debug_flags': cc.cc_compile_flags(options, True, False),
+-
+         'dash_o': cc.output_to_object,
+         'dash_c': cc.compile_flags,
+ 
+@@ -2274,8 +2276,8 @@ def test_exe_extra_ldflags():
+         'cc_lang_binary_linker_flags': cc.cc_lang_binary_linker_flags(),
+         'os_feature_macros': osinfo.macros(cc),
+         'cc_sysroot': sysroot_option(),
+-        'cc_compile_flags': options.cxxflags or cc.cc_compile_flags(options),
+-        'ldflags': options.ldflags or '',
++        'cc_compile_flags': ' '.join(cc.cc_compile_flags(options)).strip(),
++        'ldflags': ' '.join(cc.ldflags(options)).strip(),
+         'test_exe_extra_ldflags': test_exe_extra_ldflags(),
+         'extra_libs': extra_libs(options.extra_libs, cc),
+         'cc_warning_flags': cc.cc_warning_flags(options),
+diff --git a/src/build-data/makefile.in b/src/build-data/makefile.in
+index e59085667bb..9b3ac587477 100644
+--- a/src/build-data/makefile.in
++++ b/src/build-data/makefile.in
+@@ -16,7 +16,7 @@ LANG_EXE_FLAGS = %{cc_lang_binary_linker_flags}
+ CXXFLAGS       = %{cc_compile_flags}
+ WARN_FLAGS     = %{cc_warning_flags}
+ LIB_FLAGS      = %{lib_flags}
+-LDFLAGS        = %{ldflags} %{cc_compile_flags}
++LDFLAGS        = %{ldflags}
+ 
+ EXE_LINK_CMD   = %{exe_link_cmd}
+ 
+diff --git a/src/build-data/ninja.in b/src/build-data/ninja.in
+index a6279d3dea2..414663acfeb 100644
+--- a/src/build-data/ninja.in
++++ b/src/build-data/ninja.in
+@@ -10,7 +10,7 @@ LANG_EXE_FLAGS = %{cc_lang_binary_linker_flags}
+ CXXFLAGS       = %{cc_compile_flags}
+ WARN_FLAGS     = %{cc_warning_flags}
+ 
+-LDFLAGS        = %{ldflags} %{cc_compile_flags}
++LDFLAGS        = %{ldflags}
+ 
+ EXE_LINK_CMD   = %{exe_link_cmd}
+ 

+ 26 - 3
packages/b/botan/xmake.lua

@@ -6,15 +6,22 @@ package("botan")
     set_urls("https://github.com/randombit/botan/archive/refs/tags/$(version).tar.gz",
              "https://github.com/randombit/botan.git")
 
+    add_versions("3.7.1", "8d2a072c7cdca6cadd16f89bb966fce1b3ec77cb4614bf1d87dec1337a3d2330")
+    add_versions("3.7.0", "ebd1b965ed2afa12dfaf47650187142cbe870b99528185c88ca7c0ac19307c6c")
+    add_versions("3.6.1", "a6c4e8dcb6c7f4b9b67e2c8b43069d65b548970ca17847e3b1e031d3ffdd874a")
+    add_versions("3.6.0", "950199a891fab62dca78780b36e12f89031c37350b2a16a2c35f2e423c041bad")
     add_versions("3.5.0", "7d91d3349e6029e1a6929a50ab587f9fd4e29a9af3f3d698553451365564001f")
     add_versions("3.4.0", "6ef2a16a0527b1cfc9648a644877f7b95c4d07e8ef237273b030c623418c5e5b")
 
+    -- Backport MSVC flags regression after 3.5.0 (fixed in 3.7.0: https://github.com/randombit/botan/pull/4452)
+    add_patches(">=3.6.0 <3.7.0", "patches/3.6.0/msvc-compiler-flags.patch", "fc41a662f34a5fa52b232b25a396f595984698dc0029e4aa75423c8c4782028c")
+
     add_configs("tools", {description = "Build tools.", default = false, type = "boolean"})
     add_configs("python", {description = "Enable python module", default = false, type = "boolean"})
     add_configs("endian", {description = [[The  parameter should be either “little” or “big”. If not used then if the target architecture has a default, that is used. Otherwise left unspecified, which causes less optimal codepaths to be used but will work on either little or big endian.]], default = nil, type = "string", values = {"little", "big"}})
     add_configs("modules", {description = [[Enable modules, example: {configs = {modules = {"zlib", "lzma"}}}]], type = "table"})
-    if is_plat("wasm") then 
-          add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) 
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
     end
 
     add_deps("python 3.x", "ninja", {kind = "binary"})
@@ -69,6 +76,11 @@ package("botan")
                 end
             end
         end
+
+        if not package:is_plat("windows") then
+            -- Patch to support versions of ar that don't support response files (which are first used in 3.6.0)
+            package:add("patches", ">=3.6.0", "patches/3.6.0/ar-response-files.patch", "864443a77921d9da970cebe5b413e8ee18c60205011364b7bb422a65193ecb5f")
+        end
     end)
 
     on_install("windows", "linux", "macosx|native", "bsd", "mingw@windows", "msys", "wasm", function (package)
@@ -136,7 +148,11 @@ package("botan")
                 -- let configure.py detech bsd host name
                 table.insert(configs, "--os=" .. package:plat())
             end
-            table.insert(configs, "--cpu=" .. package:arch())
+            local arch = package:arch()
+            if arch == "arm64-v8a" then
+                arch = "arm64"
+            end
+            table.insert(configs, "--cpu=" .. arch)
         end
 
         if package:is_debug() then
@@ -149,9 +165,16 @@ package("botan")
         end
         table.insert(configs, "--build-targets=" .. targets)
 
+        -- necessary functions were moved to a separate module in 3.7.0
         local modules = package:config("modules")
+        local needs_os_utils = package:version():ge("3.7.0")
         if modules then
+            if needs_os_utils and not table.contains(modules, "os_utils") then
+                table.insert(modules, "os_utils")
+            end
             table.insert(configs, "--enable-modules=" .. table.concat(modules, ","))
+        elseif needs_os_utils then
+            table.insert(configs, "--enable-modules=os_utils")
         end
 
         if not package:config("python") then