Thomas-Tsai / partclone

Partclone provides utilities to backup a partition smartly and it is designed for higher compatibility of the file system by using existing library.
GNU General Public License v2.0
306 stars 104 forks source link

btrfs/crypto/crc32c-pcl-intel-asm_64.S:101: Error: unknown mnemonic 'pushq' -- 'pushq %rbx' #246

Closed robert-scheck closed 1 month ago

robert-scheck commented 1 month ago

Building partclone 0.3.28 on aarch64 fails like this:

gcc -DHAVE_CONFIG_H -I. -I..  -DLOCALEDIR=\"/usr/share/locale\" -D_FILE_OFFSET_BITS=64   -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -c -o btrfs/crypto/crc32c-pcl-intel-asm_64.o btrfs/crypto/crc32c-pcl-intel-asm_64.S
btrfs/crypto/crc32c-pcl-intel-asm_64.S: Assembler messages:
btrfs/crypto/crc32c-pcl-intel-asm_64.S:101: Error: unknown mnemonic `pushq' -- `pushq %rbx'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:102: Error: unknown mnemonic `pushq' -- `pushq %rdi'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:103: Error: unknown mnemonic `pushq' -- `pushq %rsi'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:106: Error: expected a register or register list at operand 1 -- `mov %rdx,%r8'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:112: Error: expected a register or register list at operand 1 -- `mov %rdi,%rcx#rdi=*buf'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:113: Error: expected a register at operand 1 -- `neg %rdi'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:114: Error: expected a register at operand 1 -- `and $7,%rdi#calculate the unalignment amount of'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:116: Error: unknown mnemonic `je' -- `je .Lproc_block#Skip if aligned'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:120: Error: expected a register at operand 1 -- `cmp $8,%rsi'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:121: Error: unknown mnemonic `jae' -- `jae .Ldo_align'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:124: Error: expected a register at operand 1 -- `shl $32-3+1,%esi'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:125: Error: unknown mnemonic `jmp' -- `jmp .Lless_than_8_post_shl1'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:129: Error: unknown mnemonic `movq' -- `movq (%rcx),%rbx#load a quadward from the buffer'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:130: Error: expected a register or register list at operand 1 -- `add %rdi,%rcx#align buffer pointer for quadword'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:132: Error: expected a register at operand 1 -- `sub %rdi,%rsi#update buffer length'
btrfs/crypto/crc32c-pcl-intel-asm_64.S:134: Error: expected an integer or zero register at operand 1 -- `crc32b %bl,%r8d#compute crc32 of 1-byte'
[…]
make[2]: *** [Makefile:2126: btrfs/crypto/crc32c-pcl-intel-asm_64.o] Error 1
robert-scheck commented 1 month ago

This build failure actually affects x86_32 aka i686, ARMv8 aka aarch64, POWER9/10 aka ppc64le, z-Series aka s390x.

robert-scheck commented 1 month ago

So, ripping out btrfs/crypto/crc32c-pcl-intel-asm_64.S from src/Makefile.am let's the builds succeed, but raises the question whether there maybe should be also assembler code for the other hardware architectures, too.

Thomas-Tsai commented 1 month ago

I would update configure.ac and Makefile.am and add conditions for CPU targets like btrfs do


ifeq ($(TARGET_CPU),x86_64) 
# FIXME: linkage is broken on musl for some reason 
ifeq ($(HAVE_GLIBC),1) 
CRYPTO_OBJECTS += crypto/crc32c-pcl-intel-asm_64.o 
ASFLAGS += -fPIC 
endif 
endif 
Thomas-Tsai commented 1 month ago

We only have the intel assembler code for x86_64 in the btrfs-progs project, so we will follow them.

The commit 1c72854 fixed this issue.

note: add --target i686 while host_cpu is x86_64. eg:

./configure --enable-btrfs --target i686 && make ... 
robert-scheck commented 1 month ago

Yes, commit 1c728540ca9373d2cdf2160ec6ac887ccd56d73a works - thank you.