[haiku-development] Re: Cross-compiling Haiku with jam under Freebsd: fails consistently on undefined references

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 14 Aug 2017 08:55:22 +0200

On Sun, Aug 13, 2017 at 10:09:02PM +0000, Thomas Mueller wrote:

I seem to fail to build Haiku from FreeBSD 11.1-STABLE amd64; failure is 
consistent on x86-x86_gcc2 hybrid and x86_64.

C++ 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/build/libbe/support/ZlibCompressionAlgorithm.o
 
MergeObjectFromObjects1 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/build/libbe/support/support_kit.o
 
Link 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libbe_build.so 
Chmod1 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libbe_build.so 
Link 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libpackage_build.so
 
Chmod1 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libpackage_build.so
 
Link 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/package
 
/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_checksum.o:
 In function `ChecksumIO::Digest()':
/home/nbarlene/haiku/haiku/src/bin/package/command_checksum.cpp:(.text._ZN10ChecksumIO6DigestEv[_ZN10ChecksumIO6DigestEv]+0x90):
 undefined reference to `std::bad_alloc::bad_alloc()'

[...]


/usr/local/gcc5-aux/bin/gcc -Xlinker --no-as-needed -lm -L/usr/local/lib -lz 
-o 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/package"
   
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_add.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_checksum.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_create.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_dump.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_extract.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_info.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/command_list.o"
 "/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/
 tools/package/command_recompress.o" 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/package.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/PackageWriterListener.o"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/tools/package/PackageWritingUtils.o"
 \
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/x86_64/release/build/libroot/libroot_build_function_remapper.a"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libroot_build.so"
 "/usr/lib/libgnuregex.so" 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libpackage_build.so"
 
"/home/nbarlene/myhaiku/fb64generated.amd64/objects/freebsd/lib/libbe_build.so"
 -lstdc++  \

Perhaps FreeBSD is not up to cross-compiling Haiku, or possibly there could 
be a bug in the haiku source tree or buildtools tree, which was recently 
updated for binutils.

You did not even get to the step where the build system is
cross-compiling things.

As you can see from the generated paths (objects/freebsd/x86_64), what
the build system is doing is building some tools to be run on FreeBSD
during the build. More specifically, it is building the "package" tool,
which is later used for building hpkg files for Haiku.

The failures are various undefined references to things that we expect
in the C++ standard library. From the command line used we can see that:
- The compiler used is /usr/local/gcc5-aux/bin/gcc, and
- There is a -lstdc++ added to the command line (at the end), which
  would normally be enough for this to work.

On Haiku side, it would be cleaner to use g++ rather than gcc to perform
the linking, as that should automatically link in the correct libraries.
If that is not possible, then we should know where the C++ standard
library is and replace the -lstdc++ with appropriate linker flags to get
thing working.

However, I don't know enough about FreeBSD to tell you which libraries
should be linked in exactly.

-- 
Adrien.

Other related posts: