-
-
Notifications
You must be signed in to change notification settings - Fork 718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configure
脚本无法构建 .so
动态库,但 xmake f -k shared
可以
#214
Comments
tbox 应该还不支持动态库,xmake.lua 里面是走了 xmake 自动全量导出符号的,xmake 帮忙做了很多事情在里面,configure 是精简版,目前是不支持的,只能构建静态 tbox 库 ,建议使用静态库版本 |
I think we can package tbox as static library, though the Fedora packaging guidelines said that it is should be avoided as possible. Maybe later when xmake is packaged in Fedora repository, so it can attempt to use xmake to build tbox as shared library? Ref: https://docs.fedoraproject.org/en-US/packaging-guidelines/#_packaging_static_libraries |
I have support shared library for xmake.sh
|
cflags 需要添加 diff --git a/src/xmake.sh b/src/xmake.sh
index f6fea02c..3d7c7440 100755
--- a/src/xmake.sh
+++ b/src/xmake.sh
@@ -22,6 +22,8 @@ else
set_strip "all"
if ! is_kind "shared"; then
set_symbols "hidden"
+ elif is_kind "shared"; then
+ add_cxflags "-fPIC"
fi
set_optimizes "smallest"
fi |
试下 应该可以了 |
For the building of shared library, it needs to be set soname versioning. |
@topazus: |
Considering adding |
这有点跟系统平台相关了,这边不太好内置添加,也许其他发行版不是约定的这种 soname 格式呢,例如有可能是 libtbox.1.7.so 呢。。没有统一的规范,像 android 上通常也只需要 libtbox.so 不需要加版本。。 要么你们加个 patch ,仅仅对 fedora 处理这个。
|
其實是統一的,DT_SONAME 這個字段在 Android 上也是有相同語義的。 |
但是通常构建的 jni so 库,对 app 加载来讲,是不需要这个的,也不需要加版本,我说的不是 android 系统库 另外 macos 上又是 libtbox.1.7.3.dylib ,又不同 |
DT_SONAME 不影響你
那就 |
加了,再试试 |
xmake.lua 的部分是不是要同步一下這個行為? |
好像還是。。不太對? soname 後面好像是只有一位 major version,但是最終文件上應該是完整的版本號 能考慮一下 build .so 的時候最終生成 |
所以 这个平台相关性太强了。。暂时不考虑内部搞了。。soname 那个我打算先去了,,要不你外面打个 patch 吧。。 |
也行吧,那issue先挂这,我先自己patch了 |
那我 soname 那个先 revert 了 |
我稍微研究了一下 CMake 构建 shared lib 的行为: (尖括号内的均为 CMake target property,箭头表示 symlink)
ref: cmake.org/... GNU autotools 的处理行为见上条。 |
所以感觉,如果要确保 shared libs 没兼容性问题的话得实现一下 |
So I feel that if you want to ensure that shared libs has no compatibility issues, you have to implement it |
diff --git a/configure b/configure
index fc11bd2b..9810e98e 100755
--- a/configure
+++ b/configure
@@ -1443,6 +1443,24 @@ _get_target_filename() {
_ret="${filename}"
}
+# get target soname
+_get_target_soname() {
+ local name="${1}"
+ _get_target_item "${name}" "filename"; local filename="${_ret}"
+ if test_z "${filename}"; then
+ _get_target_basename "${name}"; local basename="${_ret}"
+ _get_target_extension "${name}"; local extension="${_ret}"
+ _get_target_prefixname "${name}"; local prefixname="${_ret}"
+ filename="${prefixname}${basename}${extension}"
+ fi
+ _get_target_item "${name}" "soversion"; local soversion="${_ret}"
+ if test_nz "${soversion}"; then
+ filename="${filename}.${soversion}"
+ fi
+
+ _ret="${filename}"
+}
+
# get target directory
_get_targetdir() {
local name="${1}"
@@ -1594,6 +1612,13 @@ _get_target_toolchain_flags_for_gcc() {
flags="${flags} -fPIC"
fi
fi
+ # add soname, https://github.com/tboox/tbox/issues/214#issuecomment-1608882997
+ if test_eq "${targetkind}" "shared" && test_eq "${toolkind}" "sh" && is_plat "linux"; then
+ _get_target_soname "${name}"; local soname="${_ret}"
+ if test_nz "${soname}"; then
+ flags="${flags} -Wl,-soname,${soname}"
+ fi
+ fi
_ret="${flags}"
}
@@ -1613,6 +1638,11 @@ _get_target_toolchain_flags_for_clang() {
flags="${flags} -fPIC"
fi
fi
+ # add soname, https://github.com/tboox/tbox/issues/214#issuecomment-1608882997
+ if test_eq "${targetkind}" "shared" && test_eq "${toolkind}" "sh" && is_plat "linux"; then
+ _get_target_soname "${name}"; local soname="${_ret}"
+ flags="${flags} -Wl,-soname,${soname}"
+ fi
if is_plat "macosx"; then
_os_iorunv "xcrun" "-sdk" "macosx" "--show-sdk-path"; local sdkdir="${_ret}"
if test_nz "${sdkdir}"; then
@@ -1946,8 +1976,10 @@ set_version() {
fi
local version="${1}"
local version_build="${2}"
+ local soversion="${3:-${version%%.*}}"
_set_target_item "${_xmake_sh_target_current}" "version" "${version}"
_set_target_item "${_xmake_sh_target_current}" "version_build" "${version_build}"
+ _set_target_item "${_xmake_sh_target_current}" "soversion" "${soversion}"
}
# set default in target 简单写了一下 soname 支持,symlink 和 targetfile 的重命名没写 |
暂时不考虑,另外即使要做,这个也应该是在安装时候处理,而不是构建阶段 |
I don't think about it for the time being, and even if it is done, this should be processed during installation, not during the construction phase |
macOScmake
autoconf
meson
各家还是有差异的,cmake 搞了两层软链,autoconf/meson 一层软链。。感觉也没有统一的规范。。 |
macOScmake
autoconf
meson
各家 still have differences,cmake 搞了two layers of soft chain,autoconf/meson one layer of soft chain。。 Feels like there is no unified specification。。 |
xmake.lua 上我先做了支持,xmake-io/xmake#4002 等没问题了,后面会同步相关api 和实现到 xmake.sh |
@mochaaP xmake.sh 里面我也支持上了,可以试试 xmake-io/xmake.sh#5 tbox 上也更新了 ddb2a4f |
描述问题
https://github.com/tboox/tbox/blob/master/src/tbox/xmake.sh?plain=1#L4
static
改为shared
后:期待的结果
与
xmake f -k shared && xmake b
相同:相关环境
其他信息
请提供其他附加信息帮助我们诊断问题。
The text was updated successfully, but these errors were encountered: