kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
527 stars 239 forks source link

6.6.2 - undefined reference to `crc_pcl` #714

Open pomac303 opened 7 months ago

pomac303 commented 7 months ago
[LD]     btrfs

/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: crypto/crc32c.o: in function crc32c_pcl': /home/pomac/Projects/btrfs-progs/crypto/crc32c.c:25:(.text+0x97): undefined reference tocrc_pcl' collect2: error: ld returned 1 exit status make: *** [Makefile:679: btrfs] Error 1

kdave commented 7 months ago

Looks like the file crypto/crc32c-pcl-intel-asm_64.o is not among the linked objects. Can you please check (with V=1) that it gets built and also is present during the link phase? The reasons I see why it could not be there is reated to the target arch check (Makefile:390, TARGET_CPU), and for non-glibc build (e.g. Musl). This is verified in the CI but there may be some corner case unhandled.

pomac303 commented 7 months ago

Sorry for the delay...

make V=1 > build-log.txt /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: crypto/crc32c.o: in function crc32c_pcl': /home/pomac/Projects/btrfs-progs/crypto/crc32c.c:25:(.text+0x97): undefined reference tocrc_pcl' collect2: error: ld returned 1 exit status make: *** [Makefile:679: btrfs] Error 1

grep -c crc32c-pcl-intel-asm_64 build-log.txt 0

It's only mentioned in the Makefile once? Missing dependency? as? nasm?

kdave commented 7 months ago

The PCL implementation is used only with the builtin crypto backend (configure --with-crypto=builtin) and on glibc and when the target architecture is x86_64. There's probably some missing ifdef in the code but I need to know more about your setup. The logs above only say that the .o file is not passed on the command line.

kdave commented 5 months ago

Does this still happen? I can't reproduce that.

eloj commented 4 months ago

Does this still happen? I can't reproduce that.

Just FYI, at a42b07077f3897a I got this error before I installed libext2fs-dev (Debian 12.5 (bookworm))

make clean
./autogen.sh
./configure --disable-documentation --disable-python
...
checking for ext2fs... no
configure: error: Package requirements (ext2fs) were not met:

Normally I wouldn't try to build with an error like that obviously, but I have a script that does it unconditionally:

/usr/bin/ld: crypto/crc32c.static.o: in function `crc32c_pcl':
/usr/src/btrfs-progs/crypto/crc32c.c:25: undefined reference to `crc_pcl'
collect2: error: ld returned 1 exit status
make: *** [Makefile:685: btrfs.static] Error 1

After installing the library, immediately the crc32c object is built and linked:

root@triss:/usr/src/btrfs-progs# make
    [AS]     crypto/crc32c-pcl-intel-asm_64.o
    [LD]     btrfs

I went back and purged libext2fs-dev from my system and added --disable-convert and that built too.

So from here it doesn't seem to be an issue as long as the configure is clean, though perhaps missing ext2fs-dev could warn and disable convert instead of giving an error.

kdave commented 4 months ago

Thanks, that brings some new information but no explanation yet. I don't see any relation between the crc32c asm and convert, no shared macros or build targets. In Makefile it's just TARGET_CPU (configure time, always set) and glibc (not on debian and does not change between builds).

The convert build is by default autodetecting what's installed on the system but still expects ext2 (and the libs) as it's been like that for a long time and can be considered to be compiled in by default.

I'm on openSUSE and removing the ext2fs devel package does not expectedly get past the configure, continuing the build picks whatever was left from previous pass or it builds nothing.