<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>47117</bug_id>
          
          <creation_ts>2023-08-04 09:58:38 +0300</creation_ts>
          <short_desc>GHC: непростой FTBFS</short_desc>
          <delta_ts>2023-08-28 19:51:41 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>ghc8.6.4</component>
          <version>unstable</version>
          <rep_platform>aarch64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Anton Zhukharev">ancieg</reporter>
          <assigned_to name="Anton Zhukharev">ancieg</assigned_to>
          <cc>ancieg</cc>
    
    <cc>lav</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>230835</commentid>
    <comment_count>0</comment_count>
    <who name="Anton Zhukharev">ancieg</who>
    <bug_when>2023-08-04 09:58:38 +0300</bug_when>
    <thetext>GHC сейчас находится в состоянии FTBFS, которое вызвано обновлением autoconf до 2.71. Я это дело, вроде бы, починил: https://git.altlinux.org/tasks/326169/.


Но при сборке обнаружилась проблема, которая заключается в том, что на ARM&apos;е GHC использует LLVM для компиляции. Причём LLVM он хочет версии 6.0... (как для сборки себя, так и для сборки своих пакетов - т.е. в Requires и BuildRequires).

В целом, можно попробовать втупую подменить версию LLVM с 6.0, например, на 15.0, но, мне кажется, что просто так не сработает и понадобится долгая отладка.


Эта проблема, по всей видимости, была скрыта от глаз из-за того, что ночная пересборка пакетов происходит только на x86_64 и i586.


Теперь необходимо починить текущую версию GHC в Сизифе, заставив работать с последним LLVM, для того, чтобы потом его (GHC) обновить до более новой версии.

Чинить необходимо текущую версию, поскольку современный GHC собирается только с помощью GHC. Когда сборка текущей версии (8.6.4) будет исправлена на всех поддерживаемых архитектурах, тогда можно будет обновить его до последней версии, иначе мы рискуем остаться вообще без Haskell на ARM&apos;овых платформах навсегда.
Использование внешних бинарных сборок хочется максимально избежать.


Берусь за попытку исправить и отладить сборку GHC на aarch64 и armh, поскольку сейчас у пакета нет мейнтейнера:

ghc8.6.4	@nobody</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>231488</commentid>
    <comment_count>1</comment_count>
    <who name="Anton Zhukharev">ancieg</who>
    <bug_when>2023-08-15 23:16:42 +0300</bug_when>
    <thetext>Успешно удалось собрать для ARM на следующих версиях LLVM: 11.1, 12.0:
https://packages.altlinux.org/en/tasks/326169/

Отладочную сборку провожу локально на Orange Pi 5 8GB.

С более новыми версиями GHC не собирается из-за какой-то ошибки связанной с оптимизатором (если его отключить, то собирается).

На ARM&apos;ах GHC выглядит очень поломанным. Вот пример сборки простейшей программы:
================================================================================
ghc Main.hs -package ghc -O0 -o llvmver
[1 of 1] Compiling Main             ( Main.hs, Main.o )

&lt;no location info&gt;: error:
    Warning: Couldn&apos;t figure out LLVM version!
             Make sure you have installed LLVM 6.0
Linking llvmver ...
/usr/bin/ld.gold: error: cannot find -ltinfo
/usr/lib64/ghc-8.6.4/ghc-8.6.4/libHSghc-8.6.4.a(Terminal.o):ghc_3.ll:c5K9_info$def: error: undefined reference to &apos;set_curterm&apos;
/usr/lib64/ghc-8.6.4/ghc-8.6.4/libHSghc-8.6.4.a(Terminal.o):ghc_3.ll:c5Kh_info$def: error: undefined reference to &apos;set_curterm&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:caww_info$def: error: undefined reference to &apos;tigetnum&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_4.c:terminfozm0zi4zi1zi2_SystemziConsoleziTerminfoziBase_tigetnum_info: error: undefined reference to &apos;tigetnum&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:s9Kp_info$def: error: undefined reference to &apos;set_curterm&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:s9Kp_info$def: error: undefined reference to &apos;setupterm&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:ccoy_info$def: error: undefined reference to &apos;set_curterm&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:ccoG_info$def: error: undefined reference to &apos;setupterm&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:ccp3_info$def: error: undefined reference to &apos;del_curterm&apos;
/usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.ll:ccp3_info$def: error: undefined reference to &apos;del_curterm&apos;
collect2: error: ld returned 1 exit status
`gcc&apos; failed in phase `Linker&apos;. (Exit code: 1)
================================================================================


Сообщение
================================================================================
no location info&gt;: error:
    Warning: Couldn&apos;t figure out LLVM version!
             Make sure you have installed LLVM 6.0
================================================================================
в GHC из задания 326169 уже не появляется (там версия LLVM определяется нормальным способом).



А программка, которую я компилировал выше нужна для определения версии LLVM с которой собран GHC.
Это нужно по причине того, что при установке llvm12.0 подтягивается также llvm15.0, который сразу становится по-умолчанию, а с ним GHC работать отказывается...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>231555</commentid>
    <comment_count>2</comment_count>
    <who name="Anton Zhukharev">ancieg</who>
    <bug_when>2023-08-16 21:12:29 +0300</bug_when>
    <thetext>(In reply to Anton Zhukharev from comment #1)
&gt; ghc Main.hs -package ghc -O0 -o llvmver
&gt; [1 of 1] Compiling Main             ( Main.hs, Main.o )
&gt; 
&gt; &lt;no location info&gt;: error:
&gt;     Warning: Couldn&apos;t figure out LLVM version!
&gt;              Make sure you have installed LLVM 6.0
&gt; Linking llvmver ...
&gt; /usr/bin/ld.gold: error: cannot find -ltinfo
&gt; /usr/lib64/ghc-8.6.4/ghc-8.6.4/libHSghc-8.6.4.a(Terminal.o):ghc_3.ll:
&gt; c5K9_info$def: error: undefined reference to &apos;set_curterm&apos;
&gt; /usr/lib64/ghc-8.6.4/ghc-8.6.4/libHSghc-8.6.4.a(Terminal.o):ghc_3.ll:
&gt; c5Kh_info$def: error: undefined reference to &apos;set_curterm&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:caww_info$def: error: undefined reference to &apos;tigetnum&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_4.
&gt; c:terminfozm0zi4zi1zi2_SystemziConsoleziTerminfoziBase_tigetnum_info: error:
&gt; undefined reference to &apos;tigetnum&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:s9Kp_info$def: error: undefined reference to &apos;set_curterm&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:s9Kp_info$def: error: undefined reference to &apos;setupterm&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:ccoy_info$def: error: undefined reference to &apos;set_curterm&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:ccoG_info$def: error: undefined reference to &apos;setupterm&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:ccp3_info$def: error: undefined reference to &apos;del_curterm&apos;
&gt; /usr/lib64/ghc-8.6.4/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o):ghc_3.
&gt; ll:ccp3_info$def: error: undefined reference to &apos;del_curterm&apos;
&gt; collect2: error: ld returned 1 exit status
&gt; `gcc&apos; failed in phase `Linker&apos;. (Exit code: 1)
&gt; =============================================================================
&gt; ===

Проблема в том, что GHC линкуется с libtinfo.so (который предоставляется devel-пакетом).

&gt; Сообщение
&gt; =============================================================================
&gt; ===
&gt; no location info&gt;: error:
&gt;     Warning: Couldn&apos;t figure out LLVM version!
&gt;              Make sure you have installed LLVM 6.0
&gt; =============================================================================
&gt; ===
&gt; в GHC из задания 326169 уже не появляется (там версия LLVM определяется
&gt; нормальным способом).

Это была плохая идея.

&gt; А программка, которую я компилировал выше нужна для определения версии LLVM
&gt; с которой собран GHC.
&gt; Это нужно по причине того, что при установке llvm12.0 подтягивается также
&gt; llvm15.0, который сразу становится по-умолчанию, а с ним GHC работать
&gt; отказывается...

Правится установкой переменной:

    export ALTWRAP_LLVM_VERSION=&quot;12.0&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>231556</commentid>
    <comment_count>3</comment_count>
    <who name="Anton Zhukharev">ancieg</who>
    <bug_when>2023-08-16 21:27:21 +0300</bug_when>
    <thetext>(In reply to Anton Zhukharev from comment #2)
&gt; Проблема в том, что GHC линкуется с libtinfo.so (который предоставляется
&gt; devel-пакетом).

Это поспешный вывод, но проблема есть.


Воспроизведение:

==================================================
module Main where

import LlvmCodeGen.Base(supportedLlvmVersion)

main :: IO ()
main = let (maj,min) = supportedLlvmVersion
        in putStrLn $ show maj ++ &quot;.&quot; ++ show min
==================================================

$ ghc Main.hs -O0 -package ghc -o llvmver</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>232012</commentid>
    <comment_count>4</comment_count>
    <who name="Anton Zhukharev">ancieg</who>
    <bug_when>2023-08-28 19:51:41 +0300</bug_when>
    <thetext>ghc8.6.4 исправлен в Сизифе (думаю, что над версией 8.6.4 работа завершена).
Сейчас sin@ работает над обновлением GHC до более новых версий.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>