[devel] Проблема с debugedit при сборке ghc-9.2.8 на aarch64

Evgeny Sinelnikov sin на altlinux.org
Пн Сен 25 17:26:33 MSK 2023


Приветствую.

сб, 23 сент. 2023 г. в 12:44, Ilya Kurdyukov <ilyakurdyukov at basealt.ru>:
>
> On 9/23/23 16:36, Dmitry V. Levin wrote:
> >>   > --ldflags=-Wl,--build-id=sha1
> > Этой истории уже много лет, поэтому удивительно, что где-то до сих пор
> > по умолчанию создаётся 64-битный build id.  С точки зрения репозитория
> > важно не столько, чтобы конкретный пакет был исправлен, сколько чтобы
> > этого не происходило по умолчанию.
> >
> ghc (смотрел спеку 8.6.4) для armh/aarch64 собирается через LLVM:
[...]
> Это опции LLD, линковщика из LLVM:
>
[...]
> Если девятый ghc собирается так же - значит проблема в конфигурации
> LLVM, наверное там указано --build-id, что превращается в --build-id=fast.

ghc/mk/config.mk.in:
[...]
# Set to YES if ld has the --build-id flag.  Sometimes we need to
# disable it with --build-id=none.
LdHasBuildId<-->        = @LdHasBuildId@
[...]

Далее в коде не так много упоминаний об этом:

ghc/compiler/GHC/Driver/Pipeline/Execute.hs
[...]
Note [Merging object files for GHCi]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GHCi can usually loads standard linkable object files using GHC's linker
implementation. However, most users build their projects with -split-sections,
meaning that such object files can have an extremely high number of sections.
As the linker must map each of these sections individually, loading such object
files is very inefficient.

To avoid this inefficiency, we use the linker's `-r` flag and a linker script
to produce a merged relocatable object file. This file will contain a singe
text section section and can consequently be mapped far more efficiently. As
gcc tends to do unpredictable things to our linker command line, we opt to
invoke ld directly in this case, in contrast to our usual strategy of linking
via gcc.
-}

-- | See Note [Object merging].
joinObjectFiles :: HscEnv -> [FilePath] -> FilePath -> IO ()
joinObjectFiles hsc_env o_files output_fn
  | can_merge_objs = do
  let toolSettings' = toolSettings dflags
      ldIsGnuLd = toolSettings_ldIsGnuLd toolSettings'
      ld_r args = GHC.SysTools.runMergeObjects (hsc_logger hsc_env)
(hsc_tmpfs hsc_env) (hsc_dflags hsc_env) (
                        map GHC.SysTools.Option ld_build_id
                     ++ [ GHC.SysTools.Option "-o",
                          GHC.SysTools.FileOption "" output_fn ]
                     ++ args)

      -- suppress the generation of the .note.gnu.build-id section,
      -- which we don't need and sometimes causes ld to emit a
      -- warning:
      ld_build_id | toolSettings_ldSupportsBuildId toolSettings' =
["--build-id=none"]
                  | otherwise                                    = []
[...]

Ну, то есть, немного наоборот, вероятно, получается. --build-id явно
не указывается, а если и указывается, то в виде --build-id=none.


При этом вот такой вывод от бинаря

$ debugedit -i ./rts/dist/build/libHSrts_thr-ghc9.2.8.so
debugedit: Cannot handle 8-byte build ID

[builder at localhost ghc9.2.8-9.2.8]$ eu-readelf -n
./rts/dist/build/libHSrts_thr-ghc9.2.8.so | head

Note section [ 1] '.note.gnu.build-id' of 24 bytes at offset 0x270:
  Owner          Data size  Type
  GNU                    8  GNU_BUILD_ID
    Build ID: ba79f50a6074df4d


--
Sin (Sinelnikov Evgeny)


Подробная информация о списке рассылки Devel