Skip to content
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

app-i18n/libime-1.0.17:5/5::gentoo-zh fail to build with clang-16.0.0 #3051

Closed
ArcheyChen opened this issue Mar 24, 2023 · 12 comments · Fixed by #3055
Closed

app-i18n/libime-1.0.17:5/5::gentoo-zh fail to build with clang-16.0.0 #3051

ArcheyChen opened this issue Mar 24, 2023 · 12 comments · Fixed by #3055

Comments

@ArcheyChen
Copy link

I update my clang to 16.0.0 yesterday, and found libime failed to build:

/var/tmp/portage/app-i18n/libime-1.0.17/work/libime-1.0.17/src/libime/core/kenlm/lm/../util/joint_sort.hh:104:68: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?

build log :https://bpa.st/DAPSQ

emerge info:https://bpa.st/FQXTO

@ArcheyChen
Copy link
Author

可能是clang升级之后默认使用了更新的C++标准的缘故?有好几个其他官方包也是升级之后由于c++标准不同寄了的

@peeweep
Copy link
Collaborator

peeweep commented Mar 24, 2023

@ArcheyChen 我认为可以通过patch 或者mycmakeargs参数指定C++11,并且报告给 https://github.com/fcitx/libime

@peeweep
Copy link
Collaborator

peeweep commented Mar 24, 2023

% cat /etc/portage/package.env/libime
app-i18n/libime clang
% cat /etc/portage/env/clang         
CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

LDFLAGS="${LDFLAGS} -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed"

我通过简单的设置 env 没有复现,你试试这样改能编过么?

diff --git a/app-i18n/libime/libime-1.0.17.ebuild b/app-i18n/libime/libime-1.0.17.ebuild
index 53995e0..3b1807f 100644
--- a/app-i18n/libime/libime-1.0.17.ebuild
+++ b/app-i18n/libime/libime-1.0.17.ebuild
@@ -37,6 +37,7 @@ src_configure() {
        local mycmakeargs=(
                -DCMAKE_INSTALL_LIBDIR="${EPREFIX}/usr/$(get_libdir)"
                -DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc"
+               -DCMAKE_CXX_STANDARD=11
        )
        cmake_src_configure
 }

@ArcheyChen
Copy link
Author

% cat /etc/portage/package.env/libime
app-i18n/libime clang
% cat /etc/portage/env/clang         
CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

LDFLAGS="${LDFLAGS} -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed"

我通过简单的设置 env 没有复现,你试试这样改能编过么?

diff --git a/app-i18n/libime/libime-1.0.17.ebuild b/app-i18n/libime/libime-1.0.17.ebuild
index 53995e0..3b1807f 100644
--- a/app-i18n/libime/libime-1.0.17.ebuild
+++ b/app-i18n/libime/libime-1.0.17.ebuild
@@ -37,6 +37,7 @@ src_configure() {
        local mycmakeargs=(
                -DCMAKE_INSTALL_LIBDIR="${EPREFIX}/usr/$(get_libdir)"
                -DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc"
+               -DCMAKE_CXX_STANDARD=11
        )
        cmake_src_configure
 }

你好,请问这个patch要如何使用?我才刚换到gentoo不久,我把文件放到 /etc/portage/patches/app-i18n/libime /libime.patch里面,但是提示打不上补丁

1 out of 1 hunk ignored                                                                                                                                                                                [ !! ]
 * ERROR: app-i18n/libime-1.0.17::gentoo-zh failed (prepare phase):
 *   patch -p1  failed with /etc/portage/patches/app-i18n/libime/libime.patch
 *
 * Call stack:
 *               ebuild.sh, line  136:  Called src_prepare
 *             environment, line 2075:  Called cmake_src_prepare
 *             environment, line 1008:  Called default_src_prepare
 *      phase-functions.sh, line  948:  Called __eapi8_src_prepare
 *             environment, line  333:  Called eapply_user
 *             environment, line 1204:  Called eapply '/etc/portage/patches/app-i18n/libime/libime.patch'
 *             environment, line 1164:  Called _eapply_patch '/etc/portage/patches/app-i18n/libime/libime.patch'
 *             environment, line 1102:  Called __helpers_die 'patch -p1  failed with /etc/portage/patches/app-i18n/libime/libime.patch'
 *   isolated-functions.sh, line  112:  Called die
 * The specific snippet of code:
 *              die "$@"

@ArcheyChen
Copy link
Author

刚刚我试图手动修改了/var/db/repo。。。。。中的ebuild文件,不知道这可能会产生什么后果。
但是修改之后,仍然提示joint_sort.hh:104:68: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?

@peeweep
Copy link
Collaborator

peeweep commented Mar 24, 2023

是改 ebuild。
我看你编译日志里边有用 ccache? 你试试清理 ccache 或者用 FEATURES="-ccache" emerge

@ArcheyChen
Copy link
Author

FEATURES="-ccache"

我现在的情况:1.修改了ebuild, 2.关闭了ccache。 但是仍然不能用。

我在https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91260这个网站里面找到了一些相关信息,说是binary_function在新版本的C++标准下,不应该在std命名空间内,但是libstdc++仍然支持。

我现在全局使用libc++,可能是产生问题的原因?

同时,我尝试使用CXXFLAGS="${COMMON_FLAGS} -stdlib=libstdc++"

(我默认是采用-stdlib=libc++参数)

成功编译通过了那几个报错的文件,但是后面lld进行连接的时候出错了。

编译日志在这 http://sprunge.us/FhICvX

@ArcheyChen
Copy link
Author

到周末下班了,可能需要周一才能继续反馈这问题的更多细节。希望我刚才提供的信息对您有用。

@peeweep
Copy link
Collaborator

peeweep commented Mar 24, 2023

我在 CXXFLAGS 加上 -stdlib=libc++ 复现到了,之前没注意到你的这个设置。

@peeweep
Copy link
Collaborator

peeweep commented Mar 24, 2023

我想可以有两种解决方法:

  1. 使用C++11 编译: 我尝试在各个地方 (ebuild/各个 CMakeLists.txt) 添加 CMAKE_CXX_STANDARD=11 CMAKE_CXX_FLAGS -std=gnu++11 都仍然会用 c++17 去编译,不知道为什么。所以这条路走不通了。
  2. 根据 libcxx 文档,https://libcxx.llvm.org/UsingLibcxx.html
    binary_function 的问题在使用 libc++ 时可以用 _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 来解决
--- a/app-i18n/libime/libime-1.0.17.ebuild
+++ b/app-i18n/libime/libime-1.0.17.ebuild
@@ -34,6 +34,10 @@ src_prepare() {
 }
 
 src_configure() {
+       if [[ $(tc-get-cxx-stdlib) == libc++ ]]; then
+               append-cxxflags -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+       fi
+
        local mycmakeargs=(
                -DCMAKE_INSTALL_LIBDIR="${EPREFIX}/usr/$(get_libdir)"
                -DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc"

fcitx 的 ld 问题我也遇到了,在我使用 clang 重编 app-i18n/fcitx-5.0.23 后解决了。 并且因为同样的原因,需要用 clang 重编 boost。

liangyongxiang pushed a commit that referenced this issue Mar 24, 2023
Closes: #3051
Signed-off-by: jinqiang zhang <peeweep@0x0.ee>
@peeweep
Copy link
Collaborator

peeweep commented Mar 28, 2023

在最新的 gentoo-zh 上还有问题吗?

@ArcheyChen
Copy link
Author

刚刚测试,已经能正常编译,感谢各位

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants