Skip to content

MAMBO fails to build on Arch Linux #99

@IgWod

Description

@IgWod

It looks like MAMBO fails to build on the recent versions of Arch Linux. The problem has been initially reported by @ijan1.

The compilation error can be seen below:

MAMBO: detected architecture "aarch64"
PIE: detected architecture "aarch64"
make --no-print-directory ARCH=a64 pie
ruby generate_decoder.rb a64  > pie-a64-decoder.c
ruby generate_decoder.rb a64 header  > pie-a64-decoder.h
cc -c -Os -Wall -g -std=c99  pie-a64-decoder.c -o pie-a64-decoder.o
ruby generate_encoder.rb a64  > pie-a64-encoder.c
ruby generate_encoder.rb a64 header  > pie-a64-encoder.h
cc -c -Os -Wall -g -std=c99  pie-a64-encoder.c -o pie-a64-encoder.o
ruby generate_field-decoder.rb a64  > pie-a64-field-decoder.c
ruby generate_field-decoder.rb a64 header  > pie-a64-field-decoder.h
cc -c -Os -Wall -g -std=c99  pie-a64-field-decoder.c -o pie-a64-field-decoder.o
ruby api/generate_emit_wrapper.rb pie/pie-a64-encoder.c header > api/emit_a64.h
cc -D_GNU_SOURCE -g -std=gnu99 -O2 -Wunused-variable -DVERSION=\"583f3b7e-dirty\" -c -o elf/elf_loader.o elf/elf_loader.c
cc -D_GNU_SOURCE -g -std=gnu99 -O2 -Wunused-variable -DVERSION=\"583f3b7e-dirty\"   -c -o elf/symbol_parser.o elf/symbol_parser.c
ruby api/generate_emit_wrapper.rb pie/pie-a64-encoder.c > api/emit_a64.c
cc -D_GNU_SOURCE -g -std=gnu99 -O2 -Wunused-variable -DVERSION=\"583f3b7e-dirty\" -static -ldl -Wl,-Ttext-segment=0x7000000000 -DDBM_LINK_UNCOND_IMM -DDBM_INLINE_UNCOND_IMM -DDBM_LINK_COND_IMM -DDBM_LINK_CBZ -DDBM_LINK_TBZ -DDBM_TB_DIRECT  -DLINK_BX_ALT -DDBM_INLINE_HASH -DDBM_TRACES  -I/usr/include/libelf -I. -o dbm common.c dbm.c traces.c syscalls.c dispatcher.c signals.c util.S api/helpers.c api/plugin_support.c api/branch_decoder_support.c api/load_store.c api/internal.c api/hash_table.c elf/elf_loader.o elf/symbol_parser.o arch/aarch64/dispatcher_aarch64.S arch/aarch64/dispatcher_aarch64.c arch/aarch64/scanner_a64.c api/emit_a64.c  pie/pie-a64-field-decoder.o pie/pie-a64-encoder.o pie/pie-a64-decoder.o -lelf -lz -pthread 
/sbin/ld: /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../lib/libelf.a(elf_compress.o): in function `__libelf_compress':
(.text+0xe8): undefined reference to `ZSTD_createCCtx'
/sbin/ld: (.text+0xec): undefined reference to `ZSTD_createCCtx'
/sbin/ld: (.text+0xf4): undefined reference to `ZSTD_isError'
/sbin/ld: (.text+0xf8): undefined reference to `ZSTD_isError'
/sbin/ld: (.text+0x118): undefined reference to `ZSTD_compressStream2'
/sbin/ld: (.text+0x11c): undefined reference to `ZSTD_compressStream2'
/sbin/ld: (.text+0x424): undefined reference to `ZSTD_freeCCtx'
/sbin/ld: (.text+0x428): undefined reference to `ZSTD_freeCCtx'
/sbin/ld: (.text+0x4f4): undefined reference to `ZSTD_freeCCtx'
/sbin/ld: (.text+0x4f8): undefined reference to `ZSTD_freeCCtx'
/sbin/ld: (.text+0x520): undefined reference to `ZSTD_freeCCtx'
/sbin/ld: /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../lib/libelf.a(elf_compress.o):(.text+0x524): more undefined references to `ZSTD_freeCCtx' follow
/sbin/ld: /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../lib/libelf.a(elf_compress.o): in function `__libelf_decompress':
(.text+0x9c8): undefined reference to `ZSTD_decompress'
/sbin/ld: (.text+0x9cc): undefined reference to `ZSTD_decompress'
/sbin/ld: (.text+0x9e0): undefined reference to `ZSTD_isError'
/sbin/ld: (.text+0x9e4): undefined reference to `ZSTD_isError'
collect2: error: ld returned 1 exit status
make[1]: *** [makefile:73: dbm] Error 1
make: *** [makefile:64: all] Error 2

To fix this problem, we first need to add libzstd to the makefile:

-LIBS=-lelf -lpthread -lz
+LIBS=-lelf -lz -lzstd -pthread

However, this still fails, as static libzstd cannot be found. The root cause of it is that Arch Linux removed the static version of libzstd from its packages: https://bugs.archlinux.org/task/78526.

To get it to work, libzstd has to be built locally (https://github.com/facebook/zstd), and libzstd.a installed in /usr/lib. This enables MAMBO to build and run.

Since MAMBO relies on libelf, that relies on libz and libzstd, removing the dependency is not simple.

We need to discuss it, how to handle it properly. Any suggestions are welcome! (cc @jkressel @GuillermoCallaghan)

EDIT:

Tested in chroot on Zenfone 9 with following Arch Linux configuration:

NAME="Arch Linux ARM"
PRETTY_NAME="Arch Linux ARM"
ID=archarm
ID_LIKE=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinuxarm.org/"
DOCUMENTATION_URL="https://archlinuxarm.org/wiki"
SUPPORT_URL="https://archlinuxarm.org/forum"
BUG_REPORT_URL="https://github.com/archlinuxarm/PKGBUILDs/issues"
LOGO=archlinux-logo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions