Source: libime
Version: 1.1.1-1
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

libime fails to cross build from source, because it fails running built
tools such as LibIME::pinyindict. Actually, CMake is clever here in that
it recognizes that it cannot run those things and fails with "not
found". When looking into this, I noticed that all of the affected tools
are packaged in libime-bin, so in principle a very simple solution is
adding a build dependency on that and just running the installed tools.
That is ok if all of tools that are used have architecture-independent
output. I'm really not sure whether that's right and unfortunately
libime-bin entirely lacks documentation that would assist in figuring
this out. Can you help here? Do you understand what the tools in
libime-bin do and whether their output depends on the architecture used
to run them? If their output artifacts are textual, the answer probably
is that they are architecture-independent. If their output is binary,
more inspection is needed. Does the output depend on the number of bits
a pointer has? Does the output depend on the endianess? If we determine
that libime-bin really has tools that are not architecture-independent,
please do *not* apply the attached patch. Rather explicitly mark
libime-bin as "Multi-Arch: no" instead and close this bug.

So now we assume that libime-bin only has tools that are
architecture-independent. Then it should be marked "Multi-Arch: foreign"
instead. Then my patch can be used to use the installed libime-bin and
that makes the cross build succeed. It is not clear to me whether the
result actually is working or how I could test for that.

Note that the patch adds a dependency on libime-bin:native. This is
necessary, because currently libime-bin is not Multi-Arch: foreign. Once
you add that, the :native annotation must be deleted.

I hope you can help me figure this out.

Helmut
diff --minimal -Nru libime-1.1.1/debian/changelog libime-1.1.1/debian/changelog
--- libime-1.1.1/debian/changelog       2023-08-22 19:21:32.000000000 +0200
+++ libime-1.1.1/debian/changelog       2023-09-10 11:42:12.000000000 +0200
@@ -1,3 +1,10 @@
+libime (1.1.1-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: Run native tools. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sun, 10 Sep 2023 11:42:12 +0200
+
 libime (1.1.1-1) unstable; urgency=medium
 
   * New upstream release.
diff --minimal -Nru libime-1.1.1/debian/control libime-1.1.1/debian/control
--- libime-1.1.1/debian/control 2023-08-20 02:46:15.000000000 +0200
+++ libime-1.1.1/debian/control 2023-09-10 11:42:12.000000000 +0200
@@ -13,6 +13,7 @@
  libboost-iostreams-dev (>= 1.61),
  libdouble-conversion-dev (>= 3.1.5-5~),
  libfcitx5utils-dev (>= 5.1~),
+ libime-bin:native <cross>,
 Standards-Version: 4.6.2
 Rules-Requires-Root: no
 Homepage: https://github.com/fcitx/libime
diff --minimal -Nru libime-1.1.1/debian/patches/cross.patch 
libime-1.1.1/debian/patches/cross.patch
--- libime-1.1.1/debian/patches/cross.patch     1970-01-01 01:00:00.000000000 
+0100
+++ libime-1.1.1/debian/patches/cross.patch     2023-09-10 11:42:12.000000000 
+0200
@@ -0,0 +1,52 @@
+--- libime-1.1.1.orig/tools/CMakeLists.txt
++++ libime-1.1.1/tools/CMakeLists.txt
+@@ -2,17 +2,14 @@
+ target_link_libraries(libime_slm_build_binary kenlm)
+ 
+ install(TARGETS libime_slm_build_binary DESTINATION ${CMAKE_INSTALL_BINDIR})
+-add_executable(LibIME::slm_build_binary ALIAS libime_slm_build_binary)
+ 
+ add_executable(libime_prediction libime_prediction.cpp)
+ target_link_libraries(libime_prediction LibIME::Core)
+ install(TARGETS libime_prediction DESTINATION ${CMAKE_INSTALL_BINDIR})
+-add_executable(LibIME::prediction ALIAS libime_prediction)
+ 
+ add_executable(libime_pinyindict libime_pinyindict.cpp)
+ target_link_libraries(libime_pinyindict LibIME::Pinyin)
+ install(TARGETS libime_pinyindict DESTINATION ${CMAKE_INSTALL_BINDIR})
+-add_executable(LibIME::pinyindict ALIAS libime_pinyindict)
+ 
+ add_executable(libime_history libime_history.cpp)
+ target_link_libraries(libime_history LibIME::Core)
+@@ -22,7 +19,6 @@
+ add_executable(libime_tabledict libime_tabledict.cpp)
+ target_link_libraries(libime_tabledict LibIME::Table)
+ install(TARGETS libime_tabledict DESTINATION ${CMAKE_INSTALL_BINDIR})
+-add_executable(LibIME::tabledict ALIAS libime_tabledict)
+ 
+ add_executable(libime_migrate_fcitx4_table libime_migrate_fcitx4_table.cpp)
+ target_link_libraries(libime_migrate_fcitx4_table LibIME::Table 
Boost::iostreams Boost::filesystem)
+@@ -33,3 +29,23 @@
+ target_link_libraries(libime_migrate_fcitx4_pinyin LibIME::Pinyin 
Boost::iostreams Boost::filesystem)
+ install(TARGETS libime_migrate_fcitx4_pinyin DESTINATION 
${CMAKE_INSTALL_BINDIR})
+ add_executable(LibIME::migrate_fcitx4_pinyin ALIAS 
libime_migrate_fcitx4_pinyin)
++
++if(CMAKE_CROSSCOMPILING)
++find_program(native_slm_build_binary NAMES libime_slm_build_binary REQUIRED)
++add_executable(LibIME::slm_build_binary IMPORTED GLOBAL)
++set_target_properties(LibIME::slm_build_binary PROPERTIES IMPORTED_LOCATION 
"${native_slm_build_binary}")
++find_program(native_prediction NAMES libime_prediction REQUIRED)
++add_executable(LibIME::prediction IMPORTED GLOBAL)
++set_target_properties(LibIME::prediction PROPERTIES IMPORTED_LOCATION 
"${native_prediction}")
++find_program(native_pinyindict NAMES libime_pinyindict REQUIRED)
++add_executable(LibIME::pinyindict IMPORTED GLOBAL)
++set_target_properties(LibIME::pinyindict PROPERTIES IMPORTED_LOCATION 
"${native_pinyindict}")
++find_program(native_tabledict NAMES libime_tabledict REQUIRED)
++add_executable(LibIME::tabledict IMPORTED GLOBAL)
++set_target_properties(LibIME::tabledict PROPERTIES IMPORTED_LOCATION 
"${native_tabledict}")
++else()
++add_executable(LibIME::slm_build_binary ALIAS libime_slm_build_binary)
++add_executable(LibIME::prediction ALIAS libime_prediction)
++add_executable(LibIME::pinyindict ALIAS libime_pinyindict)
++add_executable(LibIME::tabledict ALIAS libime_tabledict)
++endif()
diff --minimal -Nru libime-1.1.1/debian/patches/series 
libime-1.1.1/debian/patches/series
--- libime-1.1.1/debian/patches/series  2023-08-20 02:46:29.000000000 +0200
+++ libime-1.1.1/debian/patches/series  2023-09-10 11:42:12.000000000 +0200
@@ -1,2 +1,3 @@
 0001-use-kenlm-from-debian-dir.patch
 0002-use-system-library-in-kenlm.patch
+cross.patch

Reply via email to