Bug 10586 - musl gcc has ifunc enabled when musl doesn't support it
Summary: musl gcc has ifunc enabled when musl doesn't support it
Status: RESOLVED NEEDINFO
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: Carlos Santos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-13 10:53 UTC by nathan.renniewaldock
Modified: 2019-09-07 01:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nathan.renniewaldock 2017-12-13 10:53:17 UTC
musl doesn't support ifunc[1], so needs to be specifically disabled as it defaults to enabled.

Test case[2]:

$ cat >a.c <<EOD
int main(){ return 0; }
EOD

$ gcc -o a a.c -latomic

$ ./a
Error relocating /lib/libatomic.so.1: __atomic_store_8: symbol not found
Error relocating /lib/libatomic.so.1: __atomic_exchange_8: symbol not found
Error relocating /lib/libatomic.so.1: __atomic_load_8: symbol not found
Error relocating /lib/libatomic.so.1: __atomic_compare_exchange_8: symbol not found


[1] http://www.openwall.com/lists/musl/2014/11/11/2
[2] http://www.openwall.com/lists/musl/2015/11/17/9

(tested buildroot 2017.11)
Comment 1 Carlos Santos 2019-08-12 01:33:27 UTC
Sorry for the late answer. I'm taking this bug.

I can't reproduce this on a system buit with the following defconfig:

BR2_x86_64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/x86-64-core-i7/tarballs/x86-64-core-i7--musl--bleeding-edge-2018.11-1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY=y
BR2_SYSTEM_DHCP="eth0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.16"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
BR2_TARGET_ROOTFS_EXT2=y
# BR2_TARGET_ROOTFS_TAR is not set

$ echo 'int main(){ return 0; }' > /tmp/a.c
$ host/bin/x86_64-linux-gcc -o target/root/a /tmp/a.c -latomic
$ host/bin/x86_64-linux-readelf -d target/root/a

Dynamic section at offset 0x2eb0 contains 16 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libatomic.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x000000000000000c (INIT)               0x401000
 0x000000000000000d (FINI)               0x401175
 0x0000000000000004 (HASH)               0x400290
 0x000000006ffffef5 (GNU_HASH)           0x4002b8
 0x0000000000000005 (STRTAB)             0x400340
 0x0000000000000006 (SYMTAB)             0x4002e0
 0x000000000000000a (STRSZ)              54 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x404000
 0x0000000000000002 (PLTRELSZ)           24 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x400378
 0x0000000000000000 (NULL)               0x0

$ make
$ qemu-kvm -M pc -m 1024 -kernel "images/bzImage" \
  -drive file=images/rootfs.ext2,if=virtio,format=raw \
  -append "root=/dev/vda console=ttyS0,115200n8 net.ifnames=0" \
  -net nic,model=virtio -net "user${hostfwd}" -nographic -enable-kvm \
  -rtc base=utc -device virtio-rng-pci -watchdog i6300esb
[...]
Welcome to Buildroot
buildroot login: root
# ./a
# 

Can you still see the error?

Could you please post a defconfig on which the problem happens?
Comment 2 Carlos Santos 2019-08-12 03:10:38 UTC
Patch submitted: https://patchwork.ozlabs.org/patch/1145462/
Comment 3 Carlos Santos 2019-08-12 03:17:28 UTC
(In reply to Carlos Santos from comment #2)

Please disregard it. That patch is for bug 10806.
Comment 4 Carlos Santos 2019-09-07 01:25:13 UTC
Closing, since it could not be reproduced and the submitter did not provide
additional information. Feel free to reopen if newer evidences raise.