From bb0ac095bacb21f69777eb9e1a31b23b0c8daaa0 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 10 Aug 2022 00:39:41 +0800 Subject: fix python.library for macosx --- xmake/rules/python/xmake.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'xmake/rules/python') diff --git a/xmake/rules/python/xmake.lua b/xmake/rules/python/xmake.lua index d5649638b..01fe83c59 100644 --- a/xmake/rules/python/xmake.lua +++ b/xmake/rules/python/xmake.lua @@ -39,4 +39,22 @@ rule("python.library") target:set("extension", ".pyd") end end + -- fix segmentation fault for macosx + -- @see https://github.com/xmake-io/xmake/issues/2177#issuecomment-1209398292 + if target:is_plat("macosx") then + target:add("shflags", "-undefined dynamic_lookup", {force = true}) + local pybind11 = target:pkg("pybind11") + if pybind11 then + local links = pybind11:get("links") + if links then + local links_without_python = {} + for _, link in ipairs(links) do + if not link:startswith("python") then + table.insert(links_without_python, link) + end + end + pybind11:set("links", links_without_python) + end + end + end end) -- cgit v1.3.1