Created attachment 377004 [details, diff] multilib support patch for gcc-4.8.2 Currently, you can not compiled with -m32 option. If you apply a patch, multilib is enabled, 32-bit libraries are created. $ gcc -m32 -o hello hello.c /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2/../../../../x86_64-gentoo-freebsd10.0/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2/libgcc.a when searching for -lgcc /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2/../../../../x86_64-gentoo-freebsd10.0/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2/../../../libgcc.a when searching for -lgcc <snip> collect2: error: ld returned 1 exit status Comments are welcome: * Better patch. * A good way to detect the libraries. Thanks in advance.
Created attachment 377006 [details, diff] patch for /etc/env.d/gcc/x86_64-gentoo-freebsd10.0-4.8.2 Known issue: After running emerge gcc, can not find the 64-bit library correctly. $ g++ -m64 -o hello hello.cpp $ ./hello /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2/32/libstdc++.so.6: unsupported file layout workaround, please apply the attached patch. # cd /etc/env.d/gcc # patch -p0 < patchfile # gcc-config [num] # . /etc/profile
Created attachment 377016 [details, diff] sample patch for freebsd-libexec-9.2.ebuild Needs to drop "${FILESDIR}/${PN}-9.2-no_ld32.patch" to enable LD_32_LIBRARY_PATH.
Created attachment 377064 [details, diff] patch for sys-apps/portage, pym/portage/util/env_update.py BAD patch... However, it works. Only 64-bit libraries should be included in /etc/ld.so.conf. $ cat /etc/ld.so.conf # ld.so.conf autogenerated by env-update; make all changes to # contents of /etc/env.d directory /lib /usr/lib /usr/local/lib /usr/lib/opengl/xorg-x11/lib /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2 /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.6.4 /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.6.4 /usr/x86_64-gentoo-freebsd10.0/lib /usr/lib/qca2 /usr/lib/qt4 It should be output to a separate file for 32-bit libraries. e.g.) /etc/ld32.so.conf $ cat /etc/ld32.so.conf /lib32 /usr/lib32 /usr/local/lib32 /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.2/32 /usr/lib32/qt4 Generate the hints for 32-bit ABI shared libraries # ldconfig -32 -elf -i -f /var/run/ld-elf32.so.hints /etc/ld32.so.conf FYI, FreeBSD man page (ldconfig) http://www.freebsd.org/cgi/man.cgi?query=ldconfig&apropos=0&sektion=0&manpath=FreeBSD+10.0-RELEASE&arch=default&format=html
Created attachment 377068 [details, diff] patch for sys-apps/openrc, init.d/bootmisc.in keep /var/run/ld-elf32.so.hints
dev-libs/libxml2 fails to build with the following error message: /bin/sh ./libtool --tag=CC --mode=link x86_64-gentoo-freebsd10.0-gcc -m32 -DCOMPAT_32BIT -B/usr/lib32 -L/usr/lib32 -D_REENTRANT -O2 -pipe -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -o xmllint xmllint.o ./libxml2.la -lpthread -lz -lm libtool: link: x86_64-gentoo-freebsd10.0-gcc -m32 -DCOMPAT_32BIT -B/usr/lib32 -D_REENTRANT -O2 -pipe -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -o .libs/xmllint xmllint.o -L/usr/lib32 ./.libs/libxml2.so -licui18n -licuuc -licudata -lpthread -lz -lm -Wl,-rpath -Wl,/usr/lib32 /usr/lib/gcc/x86_64-gentoo-freebsd10.0/4.8.3/../../../../x86_64-gentoo-freebsd10.0/bin/ld: warning: libstdc++.so.6, needed by /usr/lib32/libicui18n.so, not found (try using -rpath or -rpath-link) /usr/lib32/libicui18n.so: undefined reference to `operator delete(void*)@GLIBCXX_3.4' /usr/lib32/libicui18n.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info@CXXABI_1.3' /usr/lib32/libicui18n.so: undefined reference to `__gxx_personality_v0@CXXABI_1.3' /usr/lib32/libicuuc.so: undefined reference to `__cxa_call_unexpected@CXXABI_1.3' /usr/lib32/libicui18n.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info@CXXABI_1.3' /usr/lib32/libicui18n.so: undefined reference to `__cxa_pure_virtual@CXXABI_1.3' /usr/lib32/libicui18n.so: undefined reference to `__dynamic_cast@CXXABI_1.3' /usr/lib32/libicui18n.so: undefined reference to `vtable for __cxxabiv1::__class_type_info@CXXABI_1.3' collect2: error: ld returned 1 exit status Makefile:1099: recipe for target 'xmllint' failed gmake[2]: *** [xmllint] Error 1 gmake[2]: Leaving directory '/var/tmp/portage/dev-libs/libxml2-2.9.1-r4/work/libxml2-2.9.1-abi_x86_32.x86_fbsd' Makefile:1401: recipe for target 'all-recursive' failed Please add the following contents to /etc/portage/bashrc for a successful build. pre_pkg_setup() { GCC32PATH=`grep LDPATH /etc/env.d/gcc/.NATIVE | awk -F: '{print $2}' | sed 's:"::g'` export CFLAGS_x86_fbsd="${CFLAGS_x86_fbsd} -rpath /usr/lib32 -rpath /lib32 -rpath ${GCC32PATH}" }
Created attachment 469654 [details, diff] toolchain.eclass.patch I did a similar thing recently for gcc-4.9.4 and Gentoo/FreeBSD 10.3. But I also patched toolchain.eclass and took a bit different approach for env-update patch.
Created attachment 469656 [details, diff] gcc-4.9.4-freebsd-multilib.patch
Created attachment 469658 [details, diff] portage-freebsd-multilib-env.patch For this patch I chose to not make second env file, but to put directories for 32bit libraries and 64bit libraries into 2 separate arrays, form command line from strings from these arrays and call ldconfig with these strings as arguments. It may be further improved by bot guessing whether directory is 64bit or 32bit, but by using separate env entries, like LDPATH_m32, LDPATH_m64, and so on, but it'd be too much effort for this feature IMHO since this crude arch guessing logic works fine. 64bit multilib detection definitely may be improved for this patch.
@toolchain, how far you'd be interested in patching gcc to make multilib work on FreeBSD? We're trying to establish if it's a worthwhile effort at all or if we should mask gcc and focus on clang.
*-fbsd is gone.