Ver Fonte

libbacktrace: update to 2025.04.10 / use XMake buildsystem by default and provide auto-generated CMakeConfig/CMakeVersion files (#7658)

* libbacktrace: update to 2025.04.10

* libbacktrace: use autoconf solution, limit windows

* libbacktrace: use XMake as buildsystem

* libbacktrace: use win32ports unistd_h

* libbacktrace: fix win & validate mingw issue

* libbacktrace: try to make options working

* repair for MinGW
```
checkinfo: ...amdir\core\sandbox\modules\import\core\tool\compiler.lua:84: @programdir\modules\core\tools\gcc.lua:1035: <command-line>:warning: '__GNUC__' redefined
<built-in>: note: this is the location of the previous definition
C:\msys64\tmp\.xmake\250716\_784F4B8C61C543849F341EA5084843DC.c: In function 'main':
C:\msys64\tmp\.xmake\250716\_784F4B8C61C543849F341EA5084843DC.c:9:5: error: built-in function '__sync_synchronize' must be directly called
    9 |     volatile void* p__sync_synchronize = (void*)&__sync_synchronize; if (p__sync_synchronize) {};
      |     ^~~~~~~~
stack traceback:
```

* Do same workaround for HAVE_ATOMIC_FUNCTIONS
```
checkinfo: ...amdir\core\sandbox\modules\import\core\tool\compiler.lua:84: @programdir\modules\core\tools\gcc.lua:1035: C:\msys64\tmp\.xmake\250716\_50F7EE07F29B4102879F2DD383364DD1.c: In function 'main':
C:\msys64\tmp\.xmake\250716\_50F7EE07F29B4102879F2DD383364DD1.c:9:5: error: built-in function '__atomic_store_n' must be directly called
    9 |     volatile void* p__atomic_store_n = (void*)&__atomic_store_n; if (p__atomic_store_n) {};
      |     ^~~~~~~~
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1075]:
    [@programdir\modules\core\tools\gcc.lua:1035]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [@programdir\modules\core\tools\gcc.lua:976]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]:
    [@programdir\core\tool\compiler.lua:288]: in function 'compile'
    [...amdir\core\sandbox\modules\import\core\tool\compiler.lua:82]: in function 'compile'
    [@programdir\modules\lib\detect\check_cxsnippets.lua:244]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\lib\detect\check_cxsnippets.lua:237]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]:
    [@programdir\core\project\option.lua:212]: in function '_do_check_cxsnippets'
    [@programdir\core\project\option.lua:264]:
    [@programdir\core\project\option.lua:312]: in function '_check'
    [@programdir\core\project\option.lua:373]: in function 'check'
    [...dir\core\sandbox\modules\import\core\project\project.lua:109]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:247]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:230]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:406]:
```

* re

* resolve windows build

* drop wasm

* just trick wasm compiler

* trick gcc

* fixup

* clr

* Lazy cross limit

* set lang to c11

* simplify so it would reflect correctly

* fixup

* cls

* trick WASM compiler once again because of C11

* keep it always 1.0.0 version

* rename to bitswidth

* rename to bitswidth
Saikari há 1 mês atrás
pai
commit
0a730a4947
2 ficheiros alterados com 204 adições e 10 exclusões
  1. 172 0
      packages/l/libbacktrace/port/xmake.lua
  2. 32 10
      packages/l/libbacktrace/xmake.lua

+ 172 - 0
packages/l/libbacktrace/port/xmake.lua

@@ -0,0 +1,172 @@
+option("bitswidth", {default = "64", type = "string", values = {"64", "32"}})
+set_version("1.0.0")
+
+includes("@builtin/check")
+
+configvar_check_cfuncs("BACKTRACE_SUPPORTED", "backtrace", {includes = "execinfo.h"})
+configvar_check_cfuncs("BACKTRACE_SUPPORTS_THREADS", "backtrace_create_state", {includes = "execinfo.h"})
+configvar_check_cfuncs("BACKTRACE_SUPPORTS_DATA", "backtrace_syminfo", {includes = "execinfo.h"})
+
+configvar_check_cincludes("HAVE_DLFCN_H", "dlfcn.h")
+configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h")
+configvar_check_cincludes("HAVE_LINK_H", "link.h")
+configvar_check_cincludes("HAVE_MEMORY_H", "memory.h")
+configvar_check_cincludes("HAVE_STDINT_H", "stdint.h")
+configvar_check_cincludes("HAVE_STDLIB_H", "stdlib.h")
+configvar_check_cincludes("HAVE_STRINGS_H", "strings.h")
+configvar_check_cincludes("HAVE_STRING_H", "string.h")
+configvar_check_cincludes("HAVE_SYS_LDR_H", "sys/ldr.h")
+configvar_check_cincludes("HAVE_SYS_LINK_H", "sys/link.h")
+configvar_check_cincludes("HAVE_SYS_STAT_H", "sys/stat.h")
+configvar_check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h")
+configvar_check_cincludes("HAVE_TLHELP32_H", "tlhelp32.h")
+configvar_check_cincludes("HAVE_UNISTD_H", "unistd.h")
+
+configvar_check_cfuncs("HAVE_CLOCK_GETTIME", "clock_gettime", {includes = "time.h"})
+configvar_check_cfuncs("HAVE_FCNTL", "fcntl", {includes = "fcntl.h"})
+configvar_check_cfuncs("HAVE_LSTAT", "lstat", {includes = "sys/stat.h"})
+configvar_check_cfuncs("HAVE_READLINK", "readlink", {includes = "unistd.h"})
+
+configvar_check_cfuncs("HAVE_DECL_GETPAGESIZE", "getpagesize", {includes = "unistd.h"})
+configvar_check_cfuncs("HAVE_DECL_STRNLEN", "strnlen", {includes = "string.h"})
+configvar_check_cfuncs("HAVE_DECL__PGMPTR", "_pgmptr", {includes = {"stdlib.h", "stdio.h"}})
+configvar_check_csnippets("HAVE_ATOMIC_FUNCTIONS", [[#include <stdio.h>
+#include <stdatomic.h>
+#include <stdint.h>
+void test() { uint64_t *v;
+__atomic_store_n(&v, 0, __ATOMIC_ACQUIRE); }]])
+
+option("HAVE_GETIPINFO")
+    add_cincludes("unwind.h")
+    add_cfuncs("_Unwind_GetIPInfo")
+    set_configvar("HAVE_GETIPINFO", 1)
+    set_showmenu(false)
+option_end()
+
+if is_plat("wasm") then
+    set_configvar("HAVE_DL_ITERATE_PHDR", 0)
+else
+    option("HAVE_DL_ITERATE_PHDR")
+        add_cincludes("link.h")
+        add_cfuncs("dl_iterate_phdr")
+        add_defines("_GNU_SOURCE")
+        set_configvar("HAVE_DL_ITERATE_PHDR", 1)
+        set_showmenu(false)
+    option_end()
+end
+option("HAVE_MACH_O_DYLD_H")
+    add_cincludes("mach-o/dyld.h")
+    set_configvar("HAVE_MACH_O_DYLD_H", 1)
+    set_showmenu(false)
+option_end()
+
+option("HAVE_WINDOWS_H")
+    add_cincludes("windows.h")
+    set_configvar("HAVE_WINDOWS_H", 1)
+    set_showmenu(false)
+option_end()
+
+option("HAVE_LOADQUERY")
+    add_cincludes("sys/ldr.h")
+    add_defines("_GNU_SOURCE")
+    set_configvar("HAVE_LOADQUERY", 1)
+    set_showmenu(false)
+option_end()
+
+option("HAVE_SYS_MMAN_H")
+    add_cincludes("sys/mman.h")
+    set_configvar("HAVE_SYS_MMAN_H", 1)
+    set_showmenu(false)
+option_end()
+
+if has_config("HAVE_SYS_MMAN_H") then
+    set_configvar("BACKTRACE_USES_MALLOC", 0)
+else
+    set_configvar("BACKTRACE_USES_MALLOC", 1)
+end
+
+configvar_check_cfuncs("HAVE_GETEXECNAME", "getexecname", {includes = "stdlib.h"})
+configvar_check_cfuncs("HAVE_KERN_PROC", "KERN_PROC", {includes = "sys/sysctl.h"})
+configvar_check_cfuncs("HAVE_KERN_PROC_ARGS", "KERN_PROC_ARGS", {includes = "sys/sysctl.h"})
+configvar_check_csnippets("HAVE_SYNC_FUNCTIONS", [[#include <stdio.h>
+#include <pthread.h>
+void test() { __sync_synchronize(); }]])
+
+if has_config("bitswidth") then
+    if get_config("bitswidth") == "64" then
+        set_configvar("BACKTRACE_ELF_SIZE", 64)
+        set_configvar("BACKTRACE_XCOFF_SIZE", 64)
+    else
+        set_configvar("BACKTRACE_ELF_SIZE", 32)
+        set_configvar("BACKTRACE_XCOFF_SIZE", 32)
+    end
+end
+
+set_configvar("HAVE_LIBLZMA", 1)
+set_configvar("HAVE_ZLIB", 1)
+set_configvar("HAVE_ZSTD", 1)
+
+add_requires("xz", "zlib", "zstd")
+
+if is_plat("windows") then
+    add_requires("unistd_h")
+end
+
+set_languages("c11")
+add_rules("utils.install.cmake_importfiles")
+add_rules("mode.debug", "mode.release")
+
+target("libbacktrace")
+    set_kind("$(kind)")
+    add_options("HAVE_GETIPINFO", "HAVE_MACH_O_DYLD_H", "HAVE_WINDOWS_H", "HAVE_LOADQUERY", "HAVE_SYS_MMAN_H")
+    if not is_plat("wasm") then
+        add_options("HAVE_DL_ITERATE_PHDR")
+    else
+        add_defines("_POSIX_C_SOURCE=200809L", "_DEFAULT_SOURCE")
+    end
+    add_includedirs(".")
+    add_headerfiles("backtrace.h")
+    set_configdir(".")
+    add_configfiles("(config.h.in)", {filename = "config.h"})
+    add_configfiles("(backtrace-supported.h.in)", {filename = "backtrace-supported.h"})
+    add_files("atomic.c", "dwarf.c", "fileline.c", "posix.c", "print.c", "sort.c", "state.c")
+    add_packages("xz", "zlib", "zstd")
+    if is_plat("windows") then
+        add_packages("unistd_h")
+    end
+
+    if is_plat("linux", "bsd") then
+        add_syslinks("dl", "m", "pthread", "rt")
+    elseif is_plat("macosx", "iphoneos") then
+        add_defines("_DARWIN_USE_64_BIT_INODE=1")
+    end
+
+    if has_config("HAVE_GETIPINFO") and has_config("HAVE_DL_ITERATE_PHDR") then
+        add_files("backtrace.c")
+    elseif has_config("HAVE_DL_ITERATE_PHDR") then
+        add_files("simple.c")
+    else
+        add_files("nounwind.c")
+    end
+    
+    if has_config("HAVE_DL_ITERATE_PHDR") then
+        add_files("elf.c")
+    elseif has_config("HAVE_MACH_O_DYLD_H") then
+        add_files("macho.c")
+    elseif has_config("HAVE_WINDOWS_H") then
+        add_files("pecoff.c")
+    elseif has_config("HAVE_LOADQUERY") then
+        add_files("xcoff.c")
+    else
+        add_files("unknown.c")
+    end
+
+    if has_config("HAVE_SYS_MMAN_H") then
+        add_files("mmapio.c", "mmap.c")
+    else
+        add_files("read.c", "alloc.c")
+    end
+
+    if is_plat("windows") and is_kind("shared") then
+        add_rules("utils.symbols.export_all")
+    end

+ 32 - 10
packages/l/libbacktrace/xmake.lua

@@ -1,20 +1,42 @@
 package("libbacktrace")
-
     set_homepage("https://github.com/ianlancetaylor/libbacktrace")
     set_description("A C library that may be linked into a C/C++ program to produce symbolic backtraces")
+    set_license("BSD-3-Clause")
 
     add_urls("https://github.com/ianlancetaylor/libbacktrace.git")
-    add_versions("v1.0", "d0f5e95a87a4d3e0a1ed6c069b5dae7cbab3ed2a")
+    add_versions("2025.04.10", "793921876c981ce49759114d7bb89bb89b2d3a2d")
+
+    add_configs("bitswidth", {default = "64", type = "string", values = {"64", "32"}})
+
+    add_deps("xz", "zlib", "zstd")
+    if is_plat("windows") then
+        add_deps("unistd_h")
+    end
+
+    on_check("cross", function (package)
+        if not package:is_arch64() then
+            assert(false, "package(libbacktrace): Unsupported on non-arch64 cross.")
+        end
+    end)
 
-    on_install("linux", "macosx", function (package)
-        local configs = {}
-        local cxflags = {}
-        table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
-        table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
-        if package:config("pic") ~= false then
-            table.insert(cxflags, "-fPIC")
+    on_install(function (package)
+        if package:is_plat("windows") then
+            local internal_h_content = io.readfile("internal.h")
+            io.writefile("internal.h", internal_h_content .. [[
+    #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
+    # ifndef ssize_t
+    typedef intptr_t ssize_t;
+    # endif
+    # define SSIZE_MAX INTPTR_MAX
+    # define _SSIZE_T_
+    # define _SSIZE_T_DEFINED
+    #endif]])
         end
-        import("package.tools.autoconf").install(package, configs, {cxflags = cxflags})
+        local configs = {bitswidth = package:is_arch64() and "64" or "32"}
+        io.gsub("config.h.in", "# *undef (.-)\n", "${define %1}\n")
+        io.gsub("backtrace-supported.h.in", "# *define (.-)\n", "${define %1}\n")
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package, configs)
     end)
 
     on_test(function (package)