mold icon indicating copy to clipboard operation
mold copied to clipboard

mold fails to build on 32 bit (i586 & armv7)

Open soig opened this issue 3 years ago • 6 comments

Hi Both mold 1.0.0 & 1.0.1 fails to build on 32 bit (i586 & armv7) See https://pkgsubmit.mageia.org/uploads/failure/cauldron/core/release/20220102173806.tv.duvel.3477176/log/mold-1.0.1-1.mga9/build.i586.0.20220102173905.log

[ 10%] Building CXX object src/tbb/CMakeFiles/tbb.dir/arena.cpp.o cd /home/iurt/rpmbuild/BUILD/mold-1.0.1/out/tbb/src/tbb && /usr/bin/g++ -D__TBB_BUILD -D__TBB_USE_ITT_NOTIFY -I/home/iurt/rpmbuild/BUILD/mold-1.0.1/third-party/tbb/src/tbb/../../include -D__TBB_DYNAMIC_LOAD_ENABLED=0 -O2 -g -DNDEBUG -flifetime-dse=1 -Wall -Wextra -Wfatal-errors -std=c++11 -MD -MT src/tbb/CMakeFiles/tbb.dir/arena.cpp.o -MF CMakeFiles/tbb.dir/arena.cpp.o.d -o CMakeFiles/tbb.dir/arena.cpp.o -c /home/iurt/rpmbuild/BUILD/mold-1.0.1/third-party/tbb/src/tbb/arena.cpp In file included from /usr/lib/gcc/i586-mageia-linux/11/include/x86gprintrin.h:89, from /usr/lib/gcc/i586-mageia-linux/11/include/immintrin.h:27, from /home/iurt/rpmbuild/BUILD/mold-1.0.1/third-party/tbb/src/tbb/../../include/oneapi/tbb/detail/_machine.h:33, from /home/iurt/rpmbuild/BUILD/mold-1.0.1/third-party/tbb/src/tbb/../../include/oneapi/tbb/detail/_utils.h:26, from /home/iurt/rpmbuild/BUILD/mold-1.0.1/third-party/tbb/src/tbb/task_dispatcher.h:20, from /home/iurt/rpmbuild/BUILD/mold-1.0.1/third-party/tbb/src/tbb/arena.cpp:17: /usr/lib/gcc/i586-mageia-linux/11/include/waitpkgintrin.h: In function 'void tbb::detail::r1::prolonged_pause()': /usr/lib/gcc/i586-mageia-linux/11/include/waitpkgintrin.h:53:1: error: inlining failed in call to 'always_inline' 'unsigned char _tpause(unsigned int, long long unsigned int)': target specific option mismatch 53 | _tpause (unsigned int __A, unsigned long long __B) | ^~~~~~~ compilation terminated due to -Wfatal-errors. make[4]: *** [src/tbb/CMakeFiles/tbb.dir/build.make:104: src/tbb/CMakeFiles/tbb.dir/arena.cpp.o] Error 1 make[4]: Leaving directory '/home/iurt/rpmbuild/BUILD/mold-1.0.1/out/tbb' make[3]: *** [CMakeFiles/Makefile2:170: src/tbb/CMakeFiles/tbb.dir/all] Error 2 make[2]: *** [CMakeFiles/Makefile2:177: src/tbb/CMakeFiles/tbb.dir/rule] Error 2 make[1]: *** [Makefile:189: tbb] Error 2 make: *** [Makefile:144: out/tbb/libs/libtbb.a] Error 2 make: *** Waiting for unfinished jobs....

Using gcc-11.2.1. Thanks for fixing that

soig avatar Jan 04 '22 04:01 soig

Please build mold as a 64-bit application. Even if it is built as a 64-bit app, it can still be used to build 32-bit apps.

rui314 avatar Jan 04 '22 05:01 rui314

That's not the answer I was expecting. You are confusing building a 32bit program from a 64bit host with using a Linux distribution build system. Such a BS works by running everything on a build host of the proper architecture, not by using a cross compiler.

How can you expect distributions to ship mold if it cannot be compiled on !64bit architectures ? It'll never land in Debian, Fedora, ... Because other packages cannot rely on it if its usage depends on the actual architecture...

soig avatar Jan 06 '22 20:01 soig

Looks like this issue is related. https://github.com/oneapi-src/oneTBB/issues/370

OctopusET avatar Jan 07 '22 00:01 OctopusET

@soig Fedora is actually dropping the 32-bit x86 kernel. So is Ubuntu. Other distros may be following them. 32-bit only systems are less and less popular these days. This is a chicken-and-egg problem, but this situation causes bit-rotting to libraries on 32-bit systems, just like this OneTBB build failure on i386. So, I generally recommend building mold as a 64-bit application even for building 32-bit programs. That should work unless you are using a pure 32-bit system as a build machine. Chances are, as long as you are using an x86 PC shipped within ~20 years or an ARM machine with more than 4GB RAM, you are using a 64-bit machine that can run both 32-bit and 64-bit apps.

That being said, I guess there must be a reason that I don't know yet to stick with a pure 32-bit machine. I'd like to know that. @soig, are you using a 32-bit only machine as a build machine? If so, what is that machine? Small ARM computer or something?

I'm happy to support 32-bit hosts if it doesn't require too much work. Let me cherry pick the patch @OctopusET mentioned to see if it fixes our build failure issue.

rui314 avatar Jan 07 '22 01:01 rui314

Cross compiling is often troublesome. It's often easier to install a 32bit chroot or VM than convince various packages to compile for something else than the native host, especially on more homebrew build systems - especially considering chroot only needs to be configured once per architecture, no need to convince (or even investigate) each individual package. (A 64bit mold in a 32bit chroot should work, but I can think of a few hurdles there too.)

Dropping 32bit kernel doesn't necessarily mean dropping 32bit userspace. Wine will need its 32bit build long after 32bit-only hardware dies.

Alcaro avatar Jan 07 '22 01:01 Alcaro

@Alcaro mold behaves exactly the same whatever the host machine it is built for. Its behavior only depends on command line arguments and input object files. It is intentionally written that way to make cross-compilation easy. For the chroot environment, you may want to put a statically-linked 64-bit mold executable into your chroot directory.

So, if you successfully build mold for i386, what you'll get is a binary that works exactly the same as mold for x86-64. The only differences would be mold built for i386 is probably slower than x86-64 and can't handle a large number of input files due to 4GB virtual address size limitation.

rui314 avatar Jan 07 '22 01:01 rui314

Looks like this issue is related. oneapi-src/oneTBB#370

I have this issue on my machine. I'm using GCC11 and tbb won't build.

0x8A63F77D avatar Oct 24 '22 08:10 0x8A63F77D

Looks like this was fixed in 1.2. I guess it was fixed by the changes related to "The ARM32 target is now supported." BTW the above comment about Fedora kernel is off topic, Fedora is still building 32bit packages from their 64 bit hosts like other distros…

soig avatar Nov 17 '22 15:11 soig